diff options
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/phpcomplete.vim | 74 | ||||
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 14 | ||||
-rw-r--r-- | runtime/autoload/provider/script_host.py | 8 | ||||
-rw-r--r-- | runtime/autoload/remote/host.vim | 16 |
4 files changed, 82 insertions, 30 deletions
diff --git a/runtime/autoload/phpcomplete.vim b/runtime/autoload/phpcomplete.vim index b014b4cdcf..5ddad88873 100644 --- a/runtime/autoload/phpcomplete.vim +++ b/runtime/autoload/phpcomplete.vim @@ -3,7 +3,7 @@ " Maintainer: Dávid Szabó ( complex857 AT gmail DOT com ) " Previous Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) " URL: https://github.com/shawncplus/phpcomplete.vim -" Last Change: 2014 Oct 02 +" Last Change: 2014 Dec 01 " " OPTIONS: " @@ -1172,11 +1172,11 @@ function! phpcomplete#GetCurrentInstruction(line_number, col_number, phpbegin) " " break if we are on a "naked" stop_char (operators, colon, openparent...) if index(stop_chars, current_char) != -1 let do_break = 1 - " dont break does not look like a "->" + " dont break if it does look like a "->" if (prev_char == '-' && current_char == '>') || (current_char == '-' && next_char == '>') let do_break = 0 endif - " dont break if its looks like a "::" + " dont break if it does look like a "::" if (prev_char == ':' && current_char == ':') || (current_char == ':' && next_char == ':') let do_break = 0 endif @@ -1356,8 +1356,12 @@ function! phpcomplete#GetCallChainReturnType(classname_candidate, class_candidat endif " make @return self, static, $this the same way " (not exactly what php means by these) - if returnclass == 'self' || returnclass == 'static' || returnclass == '$this' - let classname_candidate = a:classname_candidate + if returnclass == 'self' || returnclass == 'static' || returnclass == '$this' || returnclass == 'self[]' || returnclass == 'static[]' || returnclass == '$this[]' + if returnclass =~ '\[\]$' + let classname_candidate = a:classname_candidate.'[]' + else + let classname_candidate = a:classname_candidate + endif let class_candidate_namespace = a:class_candidate_namespace else let [classname_candidate, class_candidate_namespace] = phpcomplete#ExpandClassName(returnclass, fullnamespace, a:imports) @@ -1527,7 +1531,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor let function_boundary = phpcomplete#GetCurrentFunctionBoundaries() let search_end_line = max([1, function_boundary[0][0]]) " -1 makes us ignore the current line (where the completion was invoked - let lines = reverse(getline(search_end_line, line('.') - 1)) + let lines = reverse(getline(search_end_line, a:start_line - 1)) " check Constant lookup let constant_object = matchstr(a:context, '\zs'.class_name_pattern.'\ze::') @@ -1638,9 +1642,32 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor " assignment for the variable in question with a variable on the right hand side if line =~# '^\s*'.object.'\s*=&\?\s*'.variable_name_pattern - let tailing_semicolon = match(line, ';\s*$') - let tailing_semicolon = tailing_semicolon != -1 ? tailing_semicolon : strlen(getline(a:start_line - i)) - let prev_context = phpcomplete#GetCurrentInstruction(a:start_line - i, tailing_semicolon - 1, b:phpbegin) + + " try to find the next non-comment or string ";" char + let start_col = match(line, '^\s*'.object.'\C\s*=\zs&\?\s*'.variable_name_pattern) + let filelines = reverse(lines) + let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col]) + let chars_read = 1 + " read while end of the file + while char != 'EOF' && chars_read < 1000 + let last_pos = pos + let [pos, char] = s:getNextCharWithPos(filelines, pos) + let chars_read += 1 + " we got a candidate + if char == ';' + let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name') + " it's not a comment or string, end search + if synIDName !~? 'comment\|string' + break + endif + endif + endwhile + + let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin) + if prev_context == '' + " cannot get previous context give up + return + endif let prev_class = phpcomplete#GetClassName(a:start_line - i, prev_context, a:current_namespace, a:imports) if stridx(prev_class, '\') != -1 @@ -1656,9 +1683,32 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor " assignment for the variable in question with a function on the right hand side if line =~# '^\s*'.object.'\s*=&\?\s*'.function_invocation_pattern - let tailing_semicolon = match(line, ';\s*$') - let tailing_semicolon = tailing_semicolon != -1 ? tailing_semicolon : strlen(getline(a:start_line - i)) - let prev_context = phpcomplete#GetCurrentInstruction(a:start_line - i, tailing_semicolon - 1, b:phpbegin) + + " try to find the next non-comment or string ";" char + let start_col = match(line, '\C^\s*'.object.'\s*=\zs&\?\s*'.function_invocation_pattern) + let filelines = reverse(lines) + let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col]) + let chars_read = 1 + " read while end of the file + while char != 'EOF' && chars_read < 1000 + let last_pos = pos + let [pos, char] = s:getNextCharWithPos(filelines, pos) + let chars_read += 1 + " we got a candidate + if char == ';' + let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name') + " it's not a comment or string, end search + if synIDName !~? 'comment\|string' + break + endif + endif + endwhile + + let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin) + if prev_context == '' + " cannot get previous context give up + return + endif let function_name = matchstr(prev_context, '^'.function_invocation_pattern.'\ze') let function_name = matchstr(function_name, '^\zs.\+\ze\s*($') " strip the trailing ( diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index d20b3a9bf1..5d1ce7896d 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -55,13 +55,21 @@ endif let s:clipboard = {} function! s:clipboard.get(reg) - if s:selections[a:reg].owner > 0 - return s:selections[a:reg].data + let reg = a:reg == '"' ? '+' : a:reg + if s:selections[reg].owner > 0 + return s:selections[reg].data end - return s:try_cmd(s:paste[a:reg]) + return s:try_cmd(s:paste[reg]) endfunction function! s:clipboard.set(lines, regtype, reg) + if a:reg == '"' + call s:clipboard.set(a:lines,a:regtype,'+') + if s:copy['*'] != s:copy['+'] + call s:clipboard.set(a:lines,a:regtype,'*') + end + return 0 + end if s:cache_enabled == 0 call s:try_cmd(s:copy[a:reg], a:lines) return 0 diff --git a/runtime/autoload/provider/script_host.py b/runtime/autoload/provider/script_host.py index e0b9ee6012..0a7eb53a0e 100644 --- a/runtime/autoload/provider/script_host.py +++ b/runtime/autoload/provider/script_host.py @@ -32,10 +32,6 @@ class ScriptHost(object): # it seems some plugins assume 'sys' is already imported, so do it now exec('import sys', self.module.__dict__) self.legacy_vim = nvim.with_hook(LegacyEvalHook()) - if IS_PYTHON3: - self.legacy_vim = self.legacy_vim.with_hook( - neovim.DecodeHook( - encoding=nvim.options['encoding'])) sys.modules['vim'] = self.legacy_vim def setup(self, nvim): @@ -93,10 +89,6 @@ class ScriptHost(object): stop -= 1 fname = '_vim_pydo' - # Python3 code (exec) must be a string, mixing bytes with - # function_def would use bytes.__repr__ instead - if isinstance and isinstance(code, bytes): - code = code.decode(nvim.options['encoding']) # define the function function_def = 'def %s(line, linenr):\n %s' % (fname, code,) exec(function_def, self.module.__dict__) diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim index 5a3097af5d..64f6ddb759 100644 --- a/runtime/autoload/remote/host.vim +++ b/runtime/autoload/remote/host.vim @@ -40,7 +40,11 @@ function! remote#host#Require(name) endif let host = s:hosts[a:name] if !host.channel && !host.initialized - let host.channel = call(host.factory, [a:name]) + let host_info = { + \ 'name': a:name, + \ 'orig_name': get(host, 'orig_name', a:name) + \ } + let host.channel = call(host.factory, [host_info]) let host.initialized = 1 endif return host.channel @@ -77,7 +81,7 @@ function! remote#host#RegisterPlugin(host, path, specs) endif endfor - if remote#host#IsRunning(a:host) + if has_key(s:hosts, a:host) && remote#host#IsRunning(a:host) " For now we won't allow registration of plugins when the host is already " running. throw 'Host "'.a:host.'" is already running' @@ -189,16 +193,14 @@ endfunction " Registration of standard hosts " Python/Python3 {{{ -function! s:RequirePythonHost(name) - let ver_name = has_key(s:hosts[a:name], 'orig_name') ? - \ s:hosts[a:name].orig_name : a:name - let ver = (ver_name ==# 'python') ? 2 : 3 +function! s:RequirePythonHost(host) + let ver = (a:host.orig_name ==# 'python') ? 2 : 3 " Python host arguments let args = ['-c', 'import neovim; neovim.start_host()'] " Collect registered Python plugins into args - let python_plugins = remote#host#PluginsForHost(a:name) + let python_plugins = remote#host#PluginsForHost(a:host.name) for plugin in python_plugins call add(args, plugin.path) endfor |