aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/man.vim44
-rw-r--r--runtime/autoload/msgpack.vim4
-rw-r--r--runtime/autoload/phpcomplete.vim181
-rw-r--r--runtime/autoload/provider/clipboard.vim5
-rw-r--r--runtime/autoload/provider/python.vim4
-rw-r--r--runtime/autoload/provider/python3.vim4
-rw-r--r--runtime/autoload/provider/pythonx.vim26
-rw-r--r--runtime/autoload/provider/ruby.vim34
-rw-r--r--runtime/autoload/provider/script_host.py247
-rw-r--r--runtime/autoload/python3complete.vim3
-rw-r--r--runtime/autoload/remote/define.vim19
-rw-r--r--runtime/autoload/remote/host.vim69
-rw-r--r--runtime/autoload/spellfile.vim118
-rw-r--r--runtime/autoload/tohtml.vim4
14 files changed, 309 insertions, 453 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index 49663d7e5a..0dfcc424e2 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -11,6 +11,8 @@ catch /E145:/
" Ignore the error in restricted mode
endtry
+" Load man page {page} from {section}
+" call man#get_page([{section}, ]{page})
function man#get_page(...) abort
let invoked_from_man = (&filetype ==# 'man')
@@ -20,21 +22,14 @@ function man#get_page(...) abort
elseif a:0 > 2
echoerr 'too many arguments'
return
- elseif a:0 == 2
- let [page, sect] = [a:2, 0 + a:1]
- elseif type(1) == type(a:1)
- let [page, sect] = ['<cword>', a:1]
- else
- let [page, sect] = [a:1, '']
endif
- if page == '<cword>'
- let page = expand('<cword>')
- endif
+ let sect = get(a:000, 0)
+ let page = get(a:000, 1, sect)
let [page, sect] = s:parse_page_and_section(sect, page)
- if 0 + sect > 0 && s:find_page(sect, page) == 0
+ if !empty(sect) && s:find_page(sect, page) == 0
let sect = ''
endif
@@ -54,9 +49,9 @@ function man#get_page(...) abort
let thiswin = winnr()
wincmd b
if winnr() > 1
- exe "norm! " . thiswin . "\<C-W>w"
+ exec thiswin . 'wincmd w'
while 1
- if &filetype == 'man'
+ if &filetype ==# 'man'
break
endif
wincmd w
@@ -80,11 +75,11 @@ function man#get_page(...) abort
endif
silent exec 'r!/usr/bin/man '.s:cmd(sect, page).' | col -b'
" Remove blank lines from top and bottom.
- while getline(1) =~ '^\s*$'
- silent keepjumps norm! gg"_dd
+ while getline(1) =~# '^\s*$'
+ silent keepjumps 1delete _
endwhile
- while getline('$') =~ '^\s*$'
- silent keepjumps norm! G"_dd
+ while getline('$') =~# '^\s*$'
+ silent keepjumps $delete _
endwhile
setlocal nomodified
setlocal filetype=man
@@ -118,15 +113,11 @@ endfunction
" Expects a string like 'access' or 'access(2)'.
function s:parse_page_and_section(sect, str) abort
try
- let save_isk = &iskeyword
- setlocal iskeyword-=(,)
- let page = substitute(a:str, '(*\(\k\+\).*', '\1', '')
- let sect = substitute(a:str, '\(\k\+\)(\([^()]*\)).*', '\2', '')
- if sect == page || -1 == match(sect, '^[0-9 ]\+$')
+ let [page, sect] = matchlist(a:str, '\v\C([-.[:alnum:]_]+)%(\(([-.[:alnum:]_]+)\))?')[1:2]
+ if empty(sect)
let sect = a:sect
endif
catch
- let &l:iskeyword = save_isk
echoerr 'man.vim: failed to parse: "'.a:str.'"'
endtry
@@ -134,7 +125,7 @@ function s:parse_page_and_section(sect, str) abort
endfunction
function s:cmd(sect, page) abort
- if 0 + a:sect > 0
+ if !empty(a:sect)
return s:man_sect_arg.' '.a:sect.' '.a:page
endif
return a:page
@@ -142,10 +133,5 @@ endfunction
function s:find_page(sect, page) abort
let where = system('/usr/bin/man '.s:man_find_arg.' '.s:cmd(a:sect, a:page))
- if where !~ "^/"
- if matchstr(where, " [^ ]*$") !~ "^ /"
- return 0
- endif
- endif
- return 1
+ return (where =~# '^ */')
endfunction
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim
index 2bb7ec5b02..2e2697c57f 100644
--- a/runtime/autoload/msgpack.vim
+++ b/runtime/autoload/msgpack.vim
@@ -356,6 +356,8 @@ let s:MSGPACK_STANDARD_TYPES = {
\type(''): 'binary',
\type([]): 'array',
\type({}): 'map',
+ \type(v:true): 'boolean',
+ \type(v:null): 'nil',
\}
""
@@ -379,7 +381,7 @@ endfunction
""
" Dump boolean value.
function s:msgpack_dump_boolean(v) abort
- return a:v._VAL ? 'TRUE' : 'FALSE'
+ return (a:v is v:true || (a:v isnot v:false && a:v._VAL)) ? 'TRUE' : 'FALSE'
endfunction
""
diff --git a/runtime/autoload/phpcomplete.vim b/runtime/autoload/phpcomplete.vim
index 6dcddfd43e..7f25d9df33 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: 2015 Apr 02
+" Last Change: 2015 Jul 13
"
" OPTIONS:
"
@@ -318,7 +318,7 @@ function! phpcomplete#CompleteGeneral(base, current_namespace, imports) " {{{
\ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze')
if f_name =~? '^'.substitute(a:base, '\\', '\\\\', 'g')
let f_args = matchstr(i,
- \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|$\)')
+ \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|$\)')
let int_functions[f_name.'('] = f_args.')'
endif
endfor
@@ -646,7 +646,7 @@ function! phpcomplete#CompleteUnknownClass(base, context) " {{{
let f_name = matchstr(i,
\ '^&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze')
let f_args = matchstr(i,
- \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|$\)')
+ \ '^&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|$\)')
let int_functions[f_name.'('] = f_args.')'
endfor
@@ -981,7 +981,7 @@ function! phpcomplete#CompleteUserClass(context, base, sccontent, visibility) "
let f_name = matchstr(i,
\ 'function\s*&\?\zs[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\ze')
let f_args = matchstr(i,
- \ 'function\s*&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\({\|\_$\)')
+ \ 'function\s*&\?[a-zA-Z_\x7f-\xff][a-zA-Z_0-9\x7f-\xff]*\s*(\zs.\{-}\ze)\_s*\(;\|{\|\_$\)')
if f_name != '' && stridx(f_name, '__') != 0
let c_functions[f_name.'('] = f_args
if g:phpcomplete_parse_docblock_comments
@@ -1379,8 +1379,8 @@ function! phpcomplete#GetCallChainReturnType(classname_candidate, class_candidat
" Get Structured information of all classes and subclasses including namespace and includes
" try to find the method's return type in docblock comment
for classstructure in classcontents
- let doclock_target_pattern = 'function\s\+&\?'.method.'\|\(public\|private\|protected\|var\).\+\$'.method
- let doc_str = phpcomplete#GetDocBlock(split(classstructure.content, '\n'), doclock_target_pattern)
+ let docblock_target_pattern = 'function\s\+&\?'.method.'\|\(public\|private\|protected\|var\).\+\$'.method
+ let doc_str = phpcomplete#GetDocBlock(split(classstructure.content, '\n'), docblock_target_pattern)
if doc_str != ''
break
endif
@@ -1659,7 +1659,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
" function declaration line
if line =~? 'function\(\s\+'.function_name_pattern.'\)\?\s*('
- let function_lines = join(reverse(lines), " ")
+ let function_lines = join(reverse(copy(lines)), " ")
" search for type hinted arguments
if function_lines =~? 'function\(\s\+'.function_name_pattern.'\)\?\s*(.\{-}'.class_name_pattern.'\s\+'.object && !object_is_array
let f_args = matchstr(function_lines, '\cfunction\(\s\+'.function_name_pattern.'\)\?\s*(\zs.\{-}\ze)')
@@ -1700,10 +1700,12 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
" try to find the next non-comment or string ";" char
let start_col = match(line, '^\s*'.object.'\C\s*=\zs&\?\s\+\(clone\)\?\s*'.variable_name_pattern)
- let filelines = reverse(lines)
- let [pos, char] = s:getNextCharWithPos(filelines, [a:start_line - i - 1, start_col])
+ let filelines = reverse(copy(lines))
+ let [pos, char] = s:getNextCharWithPos(filelines, [len(filelines) - i, start_col])
let chars_read = 1
let last_pos = pos
+ " function_boundary == 0 if we are not in a function
+ let real_lines_offset = len(function_boundary) == 1 ? 1 : function_boundary[0][0]
" read while end of the file
while char != 'EOF' && chars_read < 1000
let last_pos = pos
@@ -1711,7 +1713,11 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
let chars_read += 1
" we got a candidate
if char == ';'
- let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name')
+ " pos values is relative to the function's lines,
+ " line 0 need to be offsetted with the line number
+ " where te function was started to get the line number
+ " in real buffer terms
+ let synIDName = synIDattr(synID(real_lines_offset + pos[0], pos[1] + 1, 0), 'name')
" it's not a comment or string, end search
if synIDName !~? 'comment\|string'
break
@@ -1719,7 +1725,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
endif
endwhile
- let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin)
+ let prev_context = phpcomplete#GetCurrentInstruction(real_lines_offset + last_pos[0], last_pos[1], b:phpbegin)
if prev_context == ''
" cannot get previous context give up
return
@@ -1739,13 +1745,14 @@ 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
-
" 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 filelines = reverse(copy(lines))
+ let [pos, char] = s:getNextCharWithPos(filelines, [len(filelines) - i, start_col])
let chars_read = 1
let last_pos = pos
+ " function_boundary == 0 if we are not in a function
+ let real_lines_offset = len(function_boundary) == 1 ? 1 : function_boundary[0][0]
" read while end of the file
while char != 'EOF' && chars_read < 1000
let last_pos = pos
@@ -1753,7 +1760,11 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
let chars_read += 1
" we got a candidate
if char == ';'
- let synIDName = synIDattr(synID(pos[0] + 1, pos[1] + 1, 0), 'name')
+ " pos values is relative to the function's lines,
+ " line 0 need to be offsetted with the line number
+ " where te function was started to get the line number
+ " in real buffer terms
+ let synIDName = synIDattr(synID(real_lines_offset + pos[0], pos[1] + 1, 0), 'name')
" it's not a comment or string, end search
if synIDName !~? 'comment\|string'
break
@@ -1761,7 +1772,7 @@ function! phpcomplete#GetClassName(start_line, context, current_namespace, impor
endif
endwhile
- let prev_context = phpcomplete#GetCurrentInstruction(last_pos[0] + 1, last_pos[1], b:phpbegin)
+ let prev_context = phpcomplete#GetCurrentInstruction(real_lines_offset + last_pos[0], last_pos[1], b:phpbegin)
if prev_context == ''
" cannot get previous context give up
return
@@ -1864,6 +1875,9 @@ function! phpcomplete#GetClassLocation(classname, namespace) " {{{
if has_key(g:php_builtin_classes, tolower(a:classname)) && (a:namespace == '' || a:namespace == '\')
return 'VIMPHP_BUILTINOBJECT'
endif
+ if has_key(g:php_builtin_interfaces, tolower(a:classname)) && (a:namespace == '' || a:namespace == '\')
+ return 'VIMPHP_BUILTINOBJECT'
+ endif
if a:namespace == '' || a:namespace == '\'
let search_namespace = '\'
@@ -1876,7 +1890,7 @@ function! phpcomplete#GetClassLocation(classname, namespace) " {{{
let i = 1
while i < line('.')
let line = getline(line('.')-i)
- if line =~? '^\s*\(abstract\s\+\|final\s\+\)*\s*\(class\|interface\|trait\)\s*'.a:classname.'\(\s\+\|$\)' && tolower(current_namespace) == search_namespace
+ if line =~? '^\s*\(abstract\s\+\|final\s\+\)*\s*\(class\|interface\|trait\)\s*'.a:classname.'\(\s\+\|$\|{\)' && tolower(current_namespace) == search_namespace
return expand('%:p')
else
let i += 1
@@ -2048,9 +2062,18 @@ function! phpcomplete#GetClassContentsStructure(file_path, file_lines, class_nam
let content = join(getline(cfline, endline), "\n")
" Catch extends
if content =~? 'extends'
- let extends_class = matchstr(content, 'class\_s\+'.a:class_name.'\_s\+extends\_s\+\zs'.class_name_pattern.'\ze')
+ let extends_string = matchstr(content, '\(class\|interface\)\_s\+'.a:class_name.'\_.\+extends\_s\+\zs\('.class_name_pattern.'\(,\|\_s\)*\)\+\ze\(extends\|{\)')
+ let extended_classes = map(split(extends_string, '\(,\|\_s\)\+'), 'substitute(v:val, "\\_s\\+", "", "g")')
+ else
+ let extended_classes = ''
+ endif
+
+ " Catch implements
+ if content =~? 'implements'
+ let implements_string = matchstr(content, 'class\_s\+'.a:class_name.'\_.\+implements\_s\+\zs\('.class_name_pattern.'\(,\|\_s\)*\)\+\ze')
+ let implemented_interfaces = map(split(implements_string, '\(,\|\_s\)\+'), 'substitute(v:val, "\\_s\\+", "", "g")')
else
- let extends_class = ''
+ let implemented_interfaces = []
endif
call searchpair('{', '', '}', 'W')
let class_closing_bracket_line = line('.')
@@ -2108,8 +2131,11 @@ function! phpcomplete#GetClassContentsStructure(file_path, file_lines, class_nam
\ })
let all_extends = used_traits
- if extends_class != ''
- call add(all_extends, extends_class)
+ if len(extended_classes) > 0
+ call extend(all_extends, extended_classes)
+ endif
+ if len(implemented_interfaces) > 0
+ call extend(all_extends, implemented_interfaces)
endif
if len(all_extends) > 0
for class in all_extends
@@ -2119,11 +2145,16 @@ function! phpcomplete#GetClassContentsStructure(file_path, file_lines, class_nam
endif
let classlocation = phpcomplete#GetClassLocation(class, namespace)
if classlocation == "VIMPHP_BUILTINOBJECT"
- let result += [phpcomplete#GenerateBuiltinClassStub(g:php_builtin_classes[tolower(class)])]
+ if has_key(g:php_builtin_classes, tolower(class))
+ let result += [phpcomplete#GenerateBuiltinClassStub('class', g:php_builtin_classes[tolower(class)])]
+ endif
+ if has_key(g:php_builtin_interfaces, tolower(class))
+ let result += [phpcomplete#GenerateBuiltinClassStub('interface', g:php_builtin_interfaces[tolower(class)])]
+ endif
elseif classlocation != '' && filereadable(classlocation)
let full_file_path = fnamemodify(classlocation, ':p')
let result += phpcomplete#GetClassContentsStructure(full_file_path, readfile(full_file_path), class)
- elseif tolower(current_namespace) == tolower(namespace)
+ elseif tolower(current_namespace) == tolower(namespace) && match(join(a:file_lines, "\n"), '\c\(class\|interface\|trait\)\_s\+'.class.'\(\>\|$\)') != -1
" try to find the declaration in the same file.
let result += phpcomplete#GetClassContentsStructure(full_file_path, a:file_lines, class)
endif
@@ -2144,43 +2175,53 @@ function! phpcomplete#GetClassContents(classlocation, class_name) " {{{
endfunction
" }}}
-function! phpcomplete#GenerateBuiltinClassStub(class_info) " {{{
- let re = 'class '.a:class_info['name']." {"
- for [name, initializer] in items(a:class_info.constants)
- let re .= "\n\tconst ".name." = ".initializer.";"
- endfor
- for [name, info] in items(a:class_info.properties)
- let re .= "\n\t// @var $".name." ".info.type
- let re .= "\n\tpublic $".name.";"
- endfor
- for [name, info] in items(a:class_info.static_properties)
- let re .= "\n\t// @var ".name." ".info.type
- let re .= "\n\tpublic static ".name." = ".info.initializer.";"
- endfor
- for [name, info] in items(a:class_info.methods)
- if name =~ '^__'
- continue
- endif
- let re .= "\n\t/**"
- let re .= "\n\t * ".name
- let re .= "\n\t *"
- let re .= "\n\t * @return ".info.return_type
- let re .= "\n\t */"
- let re .= "\n\tpublic function ".name."(".info.signature."){"
- let re .= "\n\t}"
- endfor
- for [name, info] in items(a:class_info.static_methods)
- let re .= "\n\t/**"
- let re .= "\n\t * ".name
- let re .= "\n\t *"
- let re .= "\n\t * @return ".info.return_type
- let re .= "\n\t */"
- let re .= "\n\tpublic static function ".name."(".info.signature."){"
- let re .= "\n\t}"
- endfor
+function! phpcomplete#GenerateBuiltinClassStub(type, class_info) " {{{
+ let re = a:type.' '.a:class_info['name']." {"
+ if has_key(a:class_info, 'constants')
+ for [name, initializer] in items(a:class_info.constants)
+ let re .= "\n\tconst ".name." = ".initializer.";"
+ endfor
+ endif
+ if has_key(a:class_info, 'properties')
+ for [name, info] in items(a:class_info.properties)
+ let re .= "\n\t// @var $".name." ".info.type
+ let re .= "\n\tpublic $".name.";"
+ endfor
+ endif
+ if has_key(a:class_info, 'static_properties')
+ for [name, info] in items(a:class_info.static_properties)
+ let re .= "\n\t// @var ".name." ".info.type
+ let re .= "\n\tpublic static ".name." = ".info.initializer.";"
+ endfor
+ endif
+ if has_key(a:class_info, 'methods')
+ for [name, info] in items(a:class_info.methods)
+ if name =~ '^__'
+ continue
+ endif
+ let re .= "\n\t/**"
+ let re .= "\n\t * ".name
+ let re .= "\n\t *"
+ let re .= "\n\t * @return ".info.return_type
+ let re .= "\n\t */"
+ let re .= "\n\tpublic function ".name."(".info.signature."){"
+ let re .= "\n\t}"
+ endfor
+ endif
+ if has_key(a:class_info, 'static_methods')
+ for [name, info] in items(a:class_info.static_methods)
+ let re .= "\n\t/**"
+ let re .= "\n\t * ".name
+ let re .= "\n\t *"
+ let re .= "\n\t * @return ".info.return_type
+ let re .= "\n\t */"
+ let re .= "\n\tpublic static function ".name."(".info.signature."){"
+ let re .= "\n\t}"
+ endfor
+ endif
let re .= "\n}"
- return { 'class': a:class_info['name'],
+ return { a:type : a:class_info['name'],
\ 'content': re,
\ 'namespace': '',
\ 'imports': {},
@@ -2204,8 +2245,11 @@ function! phpcomplete#GetDocBlock(sccontent, search) " {{{
" start backward serch for the comment block
while l != 0
let line = a:sccontent[l]
- " if comment end found save line position and end search
- if line =~? '^\s*\*/'
+ " if it's a one line docblock like comment and we can just return it right away
+ if line =~? '^\s*\/\*\*.\+\*\/\s*$'
+ return substitute(line, '\v^\s*(\/\*\*\s*)|(\s*\*\/)\s*$', '', 'g')
+ "... or if comment end found save line position and end search
+ elseif line =~? '^\s*\*/'
let comment_end = l
break
" ... or the line doesn't blank (only whitespace or nothing) end search
@@ -2227,6 +2271,7 @@ function! phpcomplete#GetDocBlock(sccontent, search) " {{{
endif
let l -= 1
endwhile
+
" no docblock comment start found
if comment_start == -1
return ''
@@ -2388,7 +2433,15 @@ function! phpcomplete#GetCurrentNameSpace(file_lines) " {{{
break
endif
let block_end_pos = searchpairpos('{', '', '}\|\%$', 'W', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')
- silent! exec block_start_pos[0].','.block_end_pos[0].'d'
+
+ if block_end_pos != [0, 0]
+ " end of the block found, just delete it
+ silent! exec block_start_pos[0].','.block_end_pos[0].'d _'
+ else
+ " block pair not found, use block start as beginning and the end
+ " of the buffer instead
+ silent! exec block_start_pos[0].',$d _'
+ endif
endwhile
normal! G
@@ -2407,8 +2460,8 @@ function! phpcomplete#GetCurrentNameSpace(file_lines) " {{{
while i < file_length
let line = file_lines[i]
- if line =~? '^\s*namespace\s*'.namespace_name_pattern
- let current_namespace = matchstr(line, '\c^\s*namespace\s*\zs'.namespace_name_pattern.'\ze')
+ if line =~? '^\(<?php\)\?\s*namespace\s*'.namespace_name_pattern
+ let current_namespace = matchstr(line, '\c^\(<?php\)\?\s*namespace\s*\zs'.namespace_name_pattern.'\ze')
break
endif
@@ -2571,7 +2624,7 @@ endfunction
function! phpcomplete#ExpandClassName(classname, current_namespace, imports) " {{{
" if there's an imported class, just use that class's information
- if has_key(a:imports, a:classname) && (a:imports[a:classname].kind == 'c' || a:imports[a:classname].kind == 'i')
+ if has_key(a:imports, a:classname) && (a:imports[a:classname].kind == 'c' || a:imports[a:classname].kind == 'i' || a:imports[a:classname].kind == 't')
let namespace = has_key(a:imports[a:classname], 'namespace') ? a:imports[a:classname].namespace : ''
return [a:imports[a:classname].name, namespace]
endif
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 5ea9df92fe..9f1737639b 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -47,6 +47,11 @@ elseif exists('$DISPLAY') && executable('xclip')
let s:paste['+'] = 'xclip -o -selection clipboard'
let s:copy['*'] = 'xclip -quiet -i -selection primary'
let s:paste['*'] = 'xclip -o -selection primary'
+elseif executable('lemonade')
+ let s:copy['+'] = 'lemonade copy'
+ let s:paste['+'] = 'lemonade paste'
+ let s:copy['*'] = 'lemonade copy'
+ let s:paste['*'] = 'lemonade paste'
else
echom 'clipboard: No clipboard tool available. See :help nvim-clipboard'
finish
diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim
index b769895357..cb9d5c5296 100644
--- a/runtime/autoload/provider/python.vim
+++ b/runtime/autoload/provider/python.vim
@@ -24,12 +24,10 @@ if s:prog == ''
finish
endif
-let s:plugin_path = expand('<sfile>:p:h').'/script_host.py'
-
" The Python provider plugin will run in a separate instance of the Python
" host.
call remote#host#RegisterClone('legacy-python-provider', 'python')
-call remote#host#RegisterPlugin('legacy-python-provider', s:plugin_path, [])
+call remote#host#RegisterPlugin('legacy-python-provider', 'script_host.py', [])
function! provider#python#Call(method, args)
if s:err != ''
diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim
index 2952f76b40..f4a751e7a2 100644
--- a/runtime/autoload/provider/python3.vim
+++ b/runtime/autoload/provider/python3.vim
@@ -24,12 +24,10 @@ if s:prog == ''
finish
endif
-let s:plugin_path = expand('<sfile>:p:h').'/script_host.py'
-
" The Python3 provider plugin will run in a separate instance of the Python3
" host.
call remote#host#RegisterClone('legacy-python3-provider', 'python3')
-call remote#host#RegisterPlugin('legacy-python3-provider', s:plugin_path, [])
+call remote#host#RegisterPlugin('legacy-python3-provider', 'script_host.py', [])
function! provider#python3#Call(method, args)
if s:err != ''
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 022ef19914..05815a4896 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -5,6 +5,32 @@ endif
let s:loaded_pythonx_provider = 1
+function! provider#pythonx#Require(host) abort
+ let ver = (a:host.orig_name ==# 'python') ? 2 : 3
+
+ " Python host arguments
+ let args = ['-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
+
+ " Collect registered Python plugins into args
+ let python_plugins = remote#host#PluginsForHost(a:host.name)
+ for plugin in python_plugins
+ call add(args, plugin.path)
+ endfor
+
+ try
+ let channel_id = rpcstart((ver == '2' ?
+ \ provider#python#Prog() : provider#python3#Prog()), args)
+ if rpcrequest(channel_id, 'poll') == 'ok'
+ return channel_id
+ endif
+ catch
+ echomsg v:throwpoint
+ echomsg v:exception
+ endtry
+ throw remote#host#LoadErrorForHost(a:host.orig_name,
+ \ '$NVIM_PYTHON_LOG_FILE')
+endfunction
+
function! provider#pythonx#Detect(major_ver) abort
let host_var = (a:major_ver == 2) ?
\ 'g:python_host_prog' : 'g:python3_host_prog'
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
new file mode 100644
index 0000000000..aad8c09d28
--- /dev/null
+++ b/runtime/autoload/provider/ruby.vim
@@ -0,0 +1,34 @@
+" The Ruby provider helper
+if exists('s:loaded_ruby_provider')
+ finish
+endif
+
+let s:loaded_ruby_provider = 1
+
+function! provider#ruby#Require(host) abort
+ " Collect registered Ruby plugins into args
+ let args = []
+ let ruby_plugins = remote#host#PluginsForHost(a:host.name)
+
+ for plugin in ruby_plugins
+ call add(args, plugin.path)
+ endfor
+
+ try
+ let channel_id = rpcstart(provider#ruby#Prog(), args)
+
+ if rpcrequest(channel_id, 'poll') == 'ok'
+ return channel_id
+ endif
+ catch
+ echomsg v:throwpoint
+ echomsg v:exception
+ endtry
+
+ throw remote#host#LoadErrorForHost(a:host.orig_name,
+ \ '$NVIM_RUBY_LOG_FILE')
+endfunction
+
+function! provider#ruby#Prog() abort
+ return 'neovim-ruby-host'
+endfunction
diff --git a/runtime/autoload/provider/script_host.py b/runtime/autoload/provider/script_host.py
deleted file mode 100644
index 416b4070bb..0000000000
--- a/runtime/autoload/provider/script_host.py
+++ /dev/null
@@ -1,247 +0,0 @@
-"""Legacy python/python3-vim emulation."""
-import imp
-import io
-import logging
-import os
-import sys
-
-import neovim
-
-__all__ = ('ScriptHost',)
-
-
-logger = logging.getLogger(__name__)
-debug, info, warn = (logger.debug, logger.info, logger.warn,)
-
-IS_PYTHON3 = sys.version_info >= (3, 0)
-
-if IS_PYTHON3:
- basestring = str
-
- if sys.version_info >= (3, 4):
- from importlib.machinery import PathFinder
-
-
-@neovim.plugin
-class ScriptHost(object):
-
- """Provides an environment for running python plugins created for Vim."""
-
- def __init__(self, nvim):
- """Initialize the legacy python-vim environment."""
- self.setup(nvim)
- # context where all code will run
- self.module = imp.new_module('__main__')
- nvim.script_context = self.module
- # 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())
- sys.modules['vim'] = self.legacy_vim
-
- def setup(self, nvim):
- """Setup import hooks and global streams.
-
- This will add import hooks for importing modules from runtime
- directories and patch the sys module so 'print' calls will be
- forwarded to Nvim.
- """
- self.nvim = nvim
- info('install import hook/path')
- self.hook = path_hook(nvim)
- sys.path_hooks.append(self.hook)
- nvim.VIM_SPECIAL_PATH = '_vim_path_'
- sys.path.append(nvim.VIM_SPECIAL_PATH)
- info('redirect sys.stdout and sys.stderr')
- self.saved_stdout = sys.stdout
- self.saved_stderr = sys.stderr
- sys.stdout = RedirectStream(lambda data: nvim.out_write(data))
- sys.stderr = RedirectStream(lambda data: nvim.err_write(data))
-
- def teardown(self):
- """Restore state modified from the `setup` call."""
- for plugin in self.installed_plugins:
- if hasattr(plugin, 'on_teardown'):
- plugin.teardown()
- nvim = self.nvim
- info('uninstall import hook/path')
- sys.path.remove(nvim.VIM_SPECIAL_PATH)
- sys.path_hooks.remove(self.hook)
- info('restore sys.stdout and sys.stderr')
- sys.stdout = self.saved_stdout
- sys.stderr = self.saved_stderr
-
- @neovim.rpc_export('python_execute', sync=True)
- def python_execute(self, script, range_start, range_stop):
- """Handle the `python` ex command."""
- self._set_current_range(range_start, range_stop)
- exec(script, self.module.__dict__)
-
- @neovim.rpc_export('python_execute_file', sync=True)
- def python_execute_file(self, file_path, range_start, range_stop):
- """Handle the `pyfile` ex command."""
- self._set_current_range(range_start, range_stop)
- with open(file_path) as f:
- script = compile(f.read(), file_path, 'exec')
- exec(script, self.module.__dict__)
-
- @neovim.rpc_export('python_do_range', sync=True)
- def python_do_range(self, start, stop, code):
- """Handle the `pydo` ex command."""
- self._set_current_range(start, stop)
- nvim = self.nvim
- start -= 1
- stop -= 1
- fname = '_vim_pydo'
-
- # define the function
- function_def = 'def %s(line, linenr):\n %s' % (fname, code,)
- exec(function_def, self.module.__dict__)
- # get the function
- function = self.module.__dict__[fname]
- while start <= stop:
- # Process batches of 5000 to avoid the overhead of making multiple
- # API calls for every line. Assuming an average line length of 100
- # bytes, approximately 488 kilobytes will be transferred per batch,
- # which can be done very quickly in a single API call.
- sstart = start
- sstop = min(start + 5000, stop)
- lines = nvim.current.buffer.get_line_slice(sstart, sstop, True,
- True)
-
- exception = None
- newlines = []
- linenr = sstart + 1
- for i, line in enumerate(lines):
- result = function(line, linenr)
- if result is None:
- # Update earlier lines, and skip to the next
- if newlines:
- end = sstart + len(newlines) - 1
- nvim.current.buffer.set_line_slice(sstart, end,
- True, True,
- newlines)
- sstart += len(newlines) + 1
- newlines = []
- pass
- elif isinstance(result, basestring):
- newlines.append(result)
- else:
- exception = TypeError('pydo should return a string ' +
- 'or None, found %s instead'
- % result.__class__.__name__)
- break
- linenr += 1
-
- start = sstop + 1
- if newlines:
- end = sstart + len(newlines) - 1
- nvim.current.buffer.set_line_slice(sstart, end, True, True,
- newlines)
- if exception:
- raise exception
- # delete the function
- del self.module.__dict__[fname]
-
- @neovim.rpc_export('python_eval', sync=True)
- def python_eval(self, expr):
- """Handle the `pyeval` vim function."""
- return eval(expr, self.module.__dict__)
-
- def _set_current_range(self, start, stop):
- current = self.legacy_vim.current
- current.range = current.buffer.range(start, stop)
-
-
-class RedirectStream(io.IOBase):
- def __init__(self, redirect_handler):
- self.redirect_handler = redirect_handler
-
- def write(self, data):
- self.redirect_handler(data)
-
- def writelines(self, seq):
- self.redirect_handler('\n'.join(seq))
-
-
-class LegacyEvalHook(neovim.SessionHook):
-
- """Injects legacy `vim.eval` behavior to a Nvim instance."""
-
- def __init__(self):
- super(LegacyEvalHook, self).__init__(from_nvim=self._string_eval)
-
- def _string_eval(self, obj, session, method, kind):
- if method == 'vim_eval':
- if IS_PYTHON3:
- if isinstance(obj, (int, float)):
- return str(obj)
- elif isinstance(obj, (int, long, float)):
- return str(obj)
- return obj
-
-
-# This was copied/adapted from nvim-python help
-def path_hook(nvim):
- def _get_paths():
- return discover_runtime_directories(nvim)
-
- def _find_module(fullname, oldtail, path):
- idx = oldtail.find('.')
- if idx > 0:
- name = oldtail[:idx]
- tail = oldtail[idx+1:]
- fmr = imp.find_module(name, path)
- module = imp.find_module(fullname[:-len(oldtail)] + name, *fmr)
- return _find_module(fullname, tail, module.__path__)
- else:
- return imp.find_module(fullname, path)
-
- class VimModuleLoader(object):
- def __init__(self, module):
- self.module = module
-
- def load_module(self, fullname, path=None):
- # Check sys.modules, required for reload (see PEP302).
- if fullname in sys.modules:
- return sys.modules[fullname]
- return imp.load_module(fullname, *self.module)
-
- class VimPathFinder(object):
- @staticmethod
- def find_module(fullname, path=None):
- "Method for Python 2.7 and 3.3."
- try:
- return VimModuleLoader(
- _find_module(fullname, fullname, path or _get_paths()))
- except ImportError:
- return None
-
- @staticmethod
- def find_spec(fullname, path=None, target=None):
- "Method for Python 3.4+."
- return PathFinder.find_spec(fullname, path or _get_paths(), target)
-
- def hook(path):
- if path == nvim.VIM_SPECIAL_PATH:
- return VimPathFinder
- else:
- raise ImportError
-
- return hook
-
-
-def discover_runtime_directories(nvim):
- rv = []
- for path in nvim.list_runtime_paths():
- if not os.path.exists(path):
- continue
- path1 = os.path.join(path, 'pythonx')
- if IS_PYTHON3:
- path2 = os.path.join(path, 'python3')
- else:
- path2 = os.path.join(path, 'python2')
- if os.path.exists(path1):
- rv.append(path1)
- if os.path.exists(path2):
- rv.append(path2)
- return rv
diff --git a/runtime/autoload/python3complete.vim b/runtime/autoload/python3complete.vim
index b02200be7f..f0f3aaddb3 100644
--- a/runtime/autoload/python3complete.vim
+++ b/runtime/autoload/python3complete.vim
@@ -1,7 +1,7 @@
"python3complete.vim - Omni Completion for python
" Maintainer: Aaron Griffin <aaronmgriffin@gmail.com>
" Version: 0.9
-" Last Updated: 18 Jun 2009
+" Last Updated: 18 Jun 2009 (small fix 2015 Sep 14 from Debian)
"
" Roland Puntaier: this file contains adaptations for python3 and is parallel to pythoncomplete.vim
"
@@ -359,6 +359,7 @@ class PyParser:
def __init__(self):
self.top = Scope('global',0)
self.scope = self.top
+ self.parserline = 0
def _parsedotname(self,pre=None):
#returns (dottedname, nexttoken)
diff --git a/runtime/autoload/remote/define.vim b/runtime/autoload/remote/define.vim
index dd2482998d..b04a5d2280 100644
--- a/runtime/autoload/remote/define.vim
+++ b/runtime/autoload/remote/define.vim
@@ -1,7 +1,7 @@
function! remote#define#CommandOnHost(host, method, sync, name, opts)
let prefix = ''
- if has_key(a:opts, 'range')
+ if has_key(a:opts, 'range')
if a:opts.range == '' || a:opts.range == '%'
" -range or -range=%, pass the line range in a list
let prefix = '<line1>,<line2>'
@@ -30,7 +30,7 @@ function! remote#define#CommandOnHost(host, method, sync, name, opts)
exe s:GetCommandPrefix(a:name, a:opts)
\ .' call remote#define#CommandBootstrap("'.a:host.'"'
\ . ', "'.a:method.'"'
- \ . ', "'.a:sync.'"'
+ \ . ', '.string(a:sync)
\ . ', "'.a:name.'"'
\ . ', '.string(a:opts).''
\ . ', "'.join(forward_args, '').'"'
@@ -94,7 +94,7 @@ function! remote#define#AutocmdOnHost(host, method, sync, name, opts)
let bootstrap_def = s:GetAutocmdPrefix(a:name, a:opts)
\ .' call remote#define#AutocmdBootstrap("'.a:host.'"'
\ . ', "'.a:method.'"'
- \ . ', "'.a:sync.'"'
+ \ . ', '.string(a:sync)
\ . ', "'.a:name.'"'
\ . ', '.string(a:opts).''
\ . ', "'.escape(forward, '"').'"'
@@ -133,7 +133,7 @@ function! remote#define#FunctionOnHost(host, method, sync, name, opts)
exe 'autocmd! '.group.' FuncUndefined '.a:name
\ .' call remote#define#FunctionBootstrap("'.a:host.'"'
\ . ', "'.a:method.'"'
- \ . ', "'.a:sync.'"'
+ \ . ', '.string(a:sync)
\ . ', "'.a:name.'"'
\ . ', '.string(a:opts)
\ . ', "'.group.'"'
@@ -157,6 +157,9 @@ endfunction
function! remote#define#FunctionOnChannel(channel, method, sync, name, opts)
let rpcargs = [a:channel, '"'.a:method.'"', 'a:000']
+ if has_key(a:opts, 'range')
+ call add(rpcargs, '[a:firstline, a:lastline]')
+ endif
call s:AddEval(rpcargs, a:opts)
let function_def = s:GetFunctionPrefix(a:name, a:opts)
@@ -187,7 +190,7 @@ let s:next_gid = 1
function! s:GetNextAutocmdGroup()
let gid = s:next_gid
let s:next_gid += 1
-
+
let group_name = 'RPC_DEFINE_AUTOCMD_GROUP_'.gid
" Ensure the group is defined
exe 'augroup '.group_name.' | augroup END'
@@ -218,7 +221,11 @@ endfunction
function! s:GetFunctionPrefix(name, opts)
- return "function! ".a:name."(...)\n"
+ let res = "function! ".a:name."(...)"
+ if has_key(a:opts, 'range')
+ let res = res." range"
+ endif
+ return res."\n"
endfunction
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index 24497b10c2..8faeaed2ea 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -2,6 +2,7 @@ let s:hosts = {}
let s:plugin_patterns = {}
let s:remote_plugins_manifest = fnamemodify(expand($MYVIMRC, 1), ':h')
\.'/.'.fnamemodify($MYVIMRC, ':t').'-rplugin~'
+let s:plugins_for_host = {}
" Register a host by associating it with a factory(funcref)
@@ -35,6 +36,9 @@ endfunction
" Get a host channel, bootstrapping it if necessary
function! remote#host#Require(name) abort
+ if empty(s:plugins_for_host)
+ call remote#host#LoadRemotePlugins()
+ endif
if !has_key(s:hosts, a:name)
throw 'No host named "'.a:name.'" is registered'
endif
@@ -123,6 +127,13 @@ function! remote#host#LoadRemotePlugins() abort
endfunction
+function! remote#host#LoadRemotePluginsEvent(event, pattern) abort
+ autocmd! nvim-rplugin
+ call remote#host#LoadRemotePlugins()
+ execute 'silent doautocmd <nomodeline>' a:event a:pattern
+endfunction
+
+
function! s:RegistrationCommands(host) abort
" Register a temporary host clone for discovering specs
let host_id = a:host.'-registration-clone'
@@ -138,7 +149,9 @@ function! s:RegistrationCommands(host) abort
endfor
let channel = remote#host#Require(host_id)
let lines = []
+ let registered = []
for path in paths
+ unlet! specs
let specs = rpcrequest(channel, 'specs', path)
if type(specs) != type([])
" host didn't return a spec list, indicates a failure while loading a
@@ -151,9 +164,10 @@ function! s:RegistrationCommands(host) abort
call add(lines, " \\ ".string(spec).",")
endfor
call add(lines, " \\ ])")
+ call add(registered, path)
endfor
echomsg printf("remote/host: %s host registered plugins %s",
- \ a:host, string(map(copy(paths), "fnamemodify(v:val, ':t')")))
+ \ a:host, string(map(registered, "fnamemodify(v:val, ':t')")))
" Delete the temporary host clone
call rpcstop(s:hosts[host_id].channel)
@@ -163,7 +177,7 @@ function! s:RegistrationCommands(host) abort
endfunction
-function! s:UpdateRemotePlugins() abort
+function! remote#host#UpdateRemotePlugins() abort
let commands = []
let hosts = keys(s:hosts)
for host in hosts
@@ -185,10 +199,6 @@ function! s:UpdateRemotePlugins() abort
endfunction
-command! UpdateRemotePlugins call s:UpdateRemotePlugins()
-
-
-let s:plugins_for_host = {}
function! remote#host#PluginsForHost(host) abort
if !has_key(s:plugins_for_host, a:host)
let s:plugins_for_host[a:host] = []
@@ -197,40 +207,25 @@ function! remote#host#PluginsForHost(host) abort
endfunction
-" Registration of standard hosts
-
-" Python/Python3 {{{
-function! s:RequirePythonHost(host) abort
- let ver = (a:host.orig_name ==# 'python') ? 2 : 3
-
- " Python host arguments
- let args = ['-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
-
- " Collect registered Python plugins into args
- let python_plugins = remote#host#PluginsForHost(a:host.name)
- for plugin in python_plugins
- call add(args, plugin.path)
- endfor
-
- try
- let channel_id = rpcstart((ver == '2' ?
- \ provider#python#Prog() : provider#python3#Prog()), args)
- if rpcrequest(channel_id, 'poll') == 'ok'
- return channel_id
- endif
- catch
- echomsg v:throwpoint
- echomsg v:exception
- endtry
- throw 'Failed to load '. a:host.orig_name . ' host. '.
+function! remote#host#LoadErrorForHost(host, log) abort
+ return 'Failed to load '. a:host . ' host. '.
\ 'You can try to see what happened '.
\ 'by starting Neovim with the environment variable '.
- \ '$NVIM_PYTHON_LOG_FILE set to a file and opening '.
- \ 'the generated log file. Also, the host stderr will be available '.
+ \ a:log . ' set to a file and opening the generated '.
+ \ 'log file. Also, the host stderr will be available '.
\ 'in Neovim log, so it may contain useful information. '.
\ 'See also ~/.nvimlog.'
endfunction
-call remote#host#Register('python', '*.py', function('s:RequirePythonHost'))
-call remote#host#Register('python3', '*.py', function('s:RequirePythonHost'))
-" }}}
+
+" Registration of standard hosts
+
+" Python/Python3
+call remote#host#Register('python', '*',
+ \ function('provider#pythonx#Require'))
+call remote#host#Register('python3', '*',
+ \ function('provider#pythonx#Require'))
+
+" Ruby
+call remote#host#Register('ruby', '*.rb',
+ \ function('provider#ruby#Require'))
diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim
index c32dd5df9b..a5ffa514ea 100644
--- a/runtime/autoload/spellfile.vim
+++ b/runtime/autoload/spellfile.vim
@@ -1,6 +1,4 @@
" Vim script to download a missing spell file
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2012 Jan 08
if !exists('g:spellfile_URL')
" Prefer using http:// when netrw should be able to use it, since
@@ -43,22 +41,23 @@ function! spellfile#LoadFile(lang)
if len(dirlist) == 0
let dir_to_create = spellfile#WritableSpellDir()
if &verbose || dir_to_create != ''
- echomsg 'spellfile#LoadFile(): There is no writable spell directory.'
+ echomsg 'spellfile#LoadFile(): No (writable) spell directory found.'
endif
if dir_to_create != ''
- if confirm("Shall I create " . dir_to_create, "&Yes\n&No", 2) == 1
- " After creating the directory it should show up in the list.
- call mkdir(dir_to_create, "p")
- let [dirlist, dirchoices] = spellfile#GetDirChoices()
- endif
+ call mkdir(dir_to_create, "p")
+ " Now it should show up in the list.
+ let [dirlist, dirchoices] = spellfile#GetDirChoices()
endif
if len(dirlist) == 0
+ echomsg 'Failed to create: '.dir_to_create
return
+ else
+ echomsg 'Created '.dir_to_create
endif
endif
- let msg = 'Cannot find spell file for "' . a:lang . '" in ' . &enc
- let msg .= "\nDo you want me to try downloading it?"
+ let msg = 'No spell file for "' . a:lang . '" in ' . &enc
+ let msg .= "\nDownload it?"
if confirm(msg, "&Yes\n&No", 2) == 1
let enc = &encoding
if enc == 'iso-8859-15'
@@ -78,78 +77,77 @@ function! spellfile#LoadFile(lang)
" Careful: Nread() may have opened a new window for the error message,
" we need to go back to our own buffer and window.
if newbufnr != winbufnr(0)
- let winnr = bufwinnr(newbufnr)
- if winnr == -1
- " Our buffer has vanished!? Open a new window.
- echomsg "download buffer disappeared, opening a new one"
- new
- setlocal bin fenc=
- else
- exe winnr . "wincmd w"
- endif
+ let winnr = bufwinnr(newbufnr)
+ if winnr == -1
+ " Our buffer has vanished!? Open a new window.
+ echomsg "download buffer disappeared, opening a new one"
+ new
+ setlocal bin fenc=
+ else
+ exe winnr . "wincmd w"
+ endif
endif
if newbufnr == winbufnr(0)
- " We are back the old buffer, remove any (half-finished) download.
- g/^/d
+ " We are back the old buffer, remove any (half-finished) download.
+ g/^/d_
else
- let newbufnr = winbufnr(0)
+ let newbufnr = winbufnr(0)
endif
let fname = a:lang . '.ascii.spl'
echo 'Could not find it, trying ' . fname . '...'
call spellfile#Nread(fname)
if getline(2) !~ 'VIMspell'
- echo 'Sorry, downloading failed'
- exe newbufnr . "bwipe!"
- return
+ echo 'Download failed'
+ exe newbufnr . "bwipe!"
+ return
endif
endif
" Delete the empty first line and mark the file unmodified.
- 1d
+ 1d_
set nomod
- let msg = "In which directory do you want to write the file:"
- for i in range(len(dirlist))
- let msg .= "\n" . (i + 1) . '. ' . dirlist[i]
- endfor
- let dirchoice = confirm(msg, dirchoices) - 2
+ if len(dirlist) == 1
+ let dirchoice = 0
+ else
+ let msg = "In which directory do you want to write the file:"
+ for i in range(len(dirlist))
+ let msg .= "\n" . (i + 1) . '. ' . dirlist[i]
+ endfor
+ let dirchoice = confirm(msg, dirchoices) - 2
+ endif
if dirchoice >= 0
if exists('*fnameescape')
- let dirname = fnameescape(dirlist[dirchoice])
+ let dirname = fnameescape(dirlist[dirchoice])
else
- let dirname = escape(dirlist[dirchoice], ' ')
+ let dirname = escape(dirlist[dirchoice], ' ')
endif
setlocal fenc=
exe "write " . dirname . '/' . fname
- " Also download the .sug file, if the user wants to.
- let msg = "Do you want me to try getting the .sug file?\n"
- let msg .= "This will improve making suggestions for spelling mistakes,\n"
- let msg .= "but it uses quite a bit of memory."
- if confirm(msg, "&No\n&Yes") == 2
- g/^/d
- let fname = substitute(fname, '\.spl$', '.sug', '')
- echo 'Downloading ' . fname . '...'
- call spellfile#Nread(fname)
- if getline(2) =~ 'VIMsug'
- 1d
- exe "write " . dirname . '/' . fname
- set nomod
- else
- echo 'Sorry, downloading failed'
- " Go back to our own buffer/window, Nread() may have taken us to
- " another window.
- if newbufnr != winbufnr(0)
- let winnr = bufwinnr(newbufnr)
- if winnr != -1
- exe winnr . "wincmd w"
- endif
- endif
- if newbufnr == winbufnr(0)
- set nomod
- endif
- endif
+ " Also download the .sug file.
+ g/^/d_
+ let fname = substitute(fname, '\.spl$', '.sug', '')
+ echo 'Downloading ' . fname . '...'
+ call spellfile#Nread(fname)
+ if getline(2) =~ 'VIMsug'
+ 1d_
+ exe "write " . dirname . '/' . fname
+ set nomod
+ else
+ echo 'Download failed'
+ " Go back to our own buffer/window, Nread() may have taken us to
+ " another window.
+ if newbufnr != winbufnr(0)
+ let winnr = bufwinnr(newbufnr)
+ if winnr != -1
+ exe winnr . "wincmd w"
+ endif
+ endif
+ if newbufnr == winbufnr(0)
+ set nomod
+ endif
endif
endif
diff --git a/runtime/autoload/tohtml.vim b/runtime/autoload/tohtml.vim
index 5cb23a6146..d972ad63fe 100644
--- a/runtime/autoload/tohtml.vim
+++ b/runtime/autoload/tohtml.vim
@@ -1,6 +1,6 @@
" Vim autoload file for the tohtml plugin.
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2013 Jun 19
+" Last Change: 2013 Sep 03
"
" Additional contributors:
"
@@ -302,7 +302,7 @@ func! tohtml#Convert2HTML(line1, line2) "{{{
else "{{{
let win_list = []
let buf_list = []
- windo | if &diff | call add(win_list, winbufnr(0)) | endif
+ windo if &diff | call add(win_list, winbufnr(0)) | endif
let s:settings.whole_filler = 1
let g:html_diff_win_num = 0
for window in win_list