aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--ISSUE_TEMPLATE.md12
-rw-r--r--runtime/autoload/phpcomplete.vim181
-rw-r--r--runtime/autoload/spellfile.vim118
-rw-r--r--runtime/doc/autocmd.txt2
-rw-r--r--runtime/doc/cmdline.txt9
-rw-r--r--runtime/doc/diff.txt7
-rw-r--r--runtime/doc/editing.txt4
-rw-r--r--runtime/doc/eval.txt35
-rw-r--r--runtime/doc/quickref.txt8
-rw-r--r--runtime/doc/syntax.txt3
-rw-r--r--runtime/doc/vim_diff.txt48
-rw-r--r--runtime/doc/windows.txt2
-rw-r--r--runtime/filetype.vim3
-rw-r--r--runtime/indent/sh.vim4
-rw-r--r--runtime/indent/teraterm.vim67
-rw-r--r--runtime/optwin.vim6
-rw-r--r--runtime/plugin/spellfile.vim7
-rw-r--r--runtime/syntax/python.vim89
-rw-r--r--runtime/syntax/teraterm.vim139
-rw-r--r--runtime/syntax/vb.vim2
-rwxr-xr-xscripts/vim-patch.sh4
-rw-r--r--src/nvim/CMakeLists.txt1
-rw-r--r--src/nvim/buffer.c229
-rw-r--r--src/nvim/buffer_defs.h4
-rw-r--r--src/nvim/charset.c100
-rw-r--r--src/nvim/edit.c13
-rw-r--r--src/nvim/eval.c87
-rw-r--r--src/nvim/globals.h4
-rw-r--r--src/nvim/if_cscope.c13
-rw-r--r--src/nvim/spell.c13
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/legacy/eval_spec.lua18
-rw-r--r--test/functional/viml/completion_spec.lua12
-rw-r--r--test/unit/buffer_spec.lua10
35 files changed, 831 insertions, 427 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07557c6580..5798a74369 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,7 +59,7 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
# version string, else it is combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 1)
-set(NVIM_VERSION_PATCH 3)
+set(NVIM_VERSION_PATCH 4)
set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index 4abcc4eae1..e0185844ad 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -1,9 +1,15 @@
- Neovim version:
-- Operating system:
-- Terminal emulator:
+- [ ] Vim behaves differently?
+ - Vim version:
+- Operating system/version:
+- Terminal name/version:
+- `$TERM`:
### Actual behaviour
### Expected behaviour
-### Steps to reproduce
+### Steps to reproduce using `nvim -u NONE`
+
+1. `nvim -u NONE`
+2.
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/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/doc/autocmd.txt b/runtime/doc/autocmd.txt
index ec5818e16f..9f1b7702ed 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt* For Vim version 7.4. Last change: 2015 Mar 21
+*autocmd.txt* For Vim version 7.4. Last change: 2015 Jul 20
VIM REFERENCE MANUAL by Bram Moolenaar
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index ae808a4a9b..1236bc6e16 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -1,4 +1,4 @@
-*cmdline.txt* For Vim version 7.4. Last change: 2014 Sep 06
+*cmdline.txt* For Vim version 7.4. Last change: 2015 Jul 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -565,6 +565,7 @@ starts editing the three files "foo bar", "goes to" and "school ".
When you want to use the special characters '"' or '|' in a command, or want
to use '%' or '#' in a file name, precede them with a backslash. The
backslash is not required in a range and in the ":substitute" command.
+See also |`=|.
*:_!*
The '!' (bang) character after an Ex command makes the command behave in a
@@ -715,7 +716,7 @@ example, "%" stands for the current file name, while CTRL-R % inserts the
current file name right away. See |c_CTRL-R|.
Note: If you want to avoid the special characters in a Vim script you may want
-to use |fnameescape()|.
+to use |fnameescape()|. Also see |`=|.
In Ex commands, at places where a file name can be used, the following
@@ -755,7 +756,7 @@ it, no matter how many backslashes.
# alternate.file
\# #
\\# \#
-
+Also see |`=|.
*:<cword>* *:<cWORD>* *:<cfile>* *<cfile>*
*:<sfile>* *<sfile>* *:<afile>* *<afile>*
*:<abuf>* *<abuf>* *:<amatch>* *<amatch>*
@@ -910,6 +911,7 @@ Examples: (alternate file name is "?readme?")
:e #.* :e {files matching "?readme?.*"}
:cd <cfile> :cd {file name under cursor}
:cd <cfile>* :cd {file name under cursor plus "*" and then expanded}
+Also see |`=|.
When the expanded argument contains a "!" and it is used for a shell command
(":!cmd", ":r !cmd" or ":w !cmd"), the "!" is escaped with a backslash to
@@ -935,6 +937,7 @@ for the file "$home" in the root directory. A few examples:
\$home file "$home" in current directory
/\$home file "$home" in root directory
\\$home file "\\", followed by expanded $home
+Also see |`=|.
==============================================================================
7. Command-line window *cmdline-window* *cmdwin*
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
index 8c9cdc3800..77603b1e58 100644
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -1,4 +1,4 @@
-*diff.txt* For Vim version 7.4. Last change: 2015 Feb 03
+*diff.txt* For Vim version 7.4. Last change: 2015 Jul 03
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -124,8 +124,9 @@ file for a moment and come back to the same file and be in diff mode again.
if the current window does not have 'diff' set then no options
in it are changed.
-The ":diffoff" command resets the relevant options to the values they had when
-using |:diffsplit|, |:diffpatch| , |:diffthis|. or starting Vim in diff mode.
+The `:diffoff` command resets the relevant options to the values they had when
+using `:diffsplit`, `:diffpatch` , `:diffthis`. or starting Vim in diff mode.
+When using `:diffoff` twice the last saved values are restored.
Otherwise they are set to their default value:
'diff' off
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index bcb89f6527..507ee14baf 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1,4 +1,4 @@
-*editing.txt* For Vim version 7.4. Last change: 2015 Apr 18
+*editing.txt* For Vim version 7.4. Last change: 2015 Jul 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -397,6 +397,8 @@ does apply like to other wildcards.
If the expression returns a string then names are to be separated with line
breaks. When the result is a |List| then each item is used as a name. Line
breaks also separate names.
+Note that such expressions are only supported in places where a filename is
+expected as an argument to an Ex-command.
*++opt* *[++opt]*
The [++opt] argument can be used to force the value of 'fileformat',
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 0b2880ef03..6a1eac6814 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2015 Jun 26
+*eval.txt* For Vim version 7.4. Last change: 2015 Jul 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -916,6 +916,11 @@ just above, except that indexes out of range cause an error. Examples: >
Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
error.
+Watch out for confusion between a namespace and a variable followed by a colon
+for a sublist: >
+ mylist[n:] " uses variable n
+ mylist[s:] " uses namespace s:, error!
+
expr8.name entry in a |Dictionary| *expr-entry*
@@ -1491,7 +1496,9 @@ v:hlsearch Variable that indicates whether search highlighting is on.
this variable to zero acts like the |:nohlsearch| command,
setting it to one acts like >
let &hlsearch = &hlsearch
-<
+< Note that the value is restored when returning from a
+ function. |function-search-undo|.
+
*v:insertmode* *insertmode-variable*
v:insertmode Used for the |InsertEnter| and |InsertChange| autocommand
events. Values:
@@ -4594,7 +4601,7 @@ match({expr}, {pat}[, {start}[, {count}]]) *match()*
done like 'magic' is set and 'cpoptions' is empty.
*matchadd()* *E798* *E799* *E801*
-matchadd({group}, {pattern}[, {priority}[, {id}]])
+matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
Defines a pattern to be highlighted in the current window (a
"match"). It will be highlighted with {group}. Returns an
identification number (ID), which can be used to delete the
@@ -4602,6 +4609,8 @@ matchadd({group}, {pattern}[, {priority}[, {id}]])
Matching is case sensitive and magic, unless case sensitivity
or magicness are explicitly overridden in {pattern}. The
'magic', 'smartcase' and 'ignorecase' options are not used.
+ The "Conceal" value is special, it causes the match to be
+ concealed.
The optional {priority} argument assigns a priority to the
match. A match with a high priority will have its
@@ -5176,7 +5185,7 @@ readfile({fname} [, {binary} [, {max}]])
separated with CR will result in a single long line (unless a
NL appears somewhere).
All NUL characters are replaced with a NL character.
- When {binary/append} contains "b" binary mode is used:
+ When {binary} contains "b" binary mode is used:
- When the last line ends in a NL an extra empty list item is
added.
- No CR characters are removed.
@@ -6200,6 +6209,24 @@ strchars({expr} [, {skipcc}]) *strchars()*
When {skipcc} set to 1, Composing characters are ignored.
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
+
+ {skipcc} is only available after 7.4.755. For backward
+ compatibility, you can define a wrapper function: >
+ if has("patch-7.4.755")
+ function s:strchars(str, skipcc)
+ return strchars(a:str, a:skipcc)
+ endfunction
+ else
+ function s:strchars(str, skipcc)
+ if a:skipcc
+ return strlen(substitute(a:str, ".", "x", "g"))
+ else
+ return strchars(a:str)
+ endif
+ endfunction
+ endif
+<
+
strdisplaywidth({expr}[, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
String {expr} occupies on the screen when it starts at {col}.
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index ded5e69438..120e027242 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -1,4 +1,4 @@
-*quickref.txt* For Vim version 7.4. Last change: 2014 Nov 19
+*quickref.txt* For Vim version 7.4. Last change: 2015 Jul 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -617,6 +617,7 @@ Short explanation of each option: *option-list*
'balloondelay' 'bdlay' delay in mS before a balloon may pop up
'ballooneval' 'beval' switch on balloon evaluation
'balloonexpr' 'bexpr' expression to show in balloon
+'belloff' 'bo' do not ring the bell for these reasons
'binary' 'bin' read/write/edit file in binary mode
'bomb' prepend a Byte Order Mark to the file
'breakat' 'brk' characters that may cause a line break
@@ -688,6 +689,7 @@ Short explanation of each option: *option-list*
'fileignorecase' 'fic' ignore case when using file names
'filetype' 'ft' type of file, used for autocommands
'fillchars' 'fcs' characters to use for displaying special items
+'fixendofline' 'fixeol' make sure last line in file has <EOL>
'fkmap' 'fk' Farsi keyboard mapping
'foldclose' 'fcl' close a fold when the cursor leaves it
'foldcolumn' 'fdc' width of the column used to indicate folds
@@ -702,10 +704,10 @@ Short explanation of each option: *option-list*
'foldnestmax' 'fdn' maximum fold depth
'foldopen' 'fdo' for which commands a fold will be opened
'foldtext' 'fdt' expression used to display for a closed fold
+'formatexpr' 'fex' expression used with "gq" command
'formatlistpat' 'flp' pattern used to recognize a list header
'formatoptions' 'fo' how automatic formatting is to be done
'formatprg' 'fp' name of external program used with "gq" command
-'formatexpr' 'fex' expression used with "gq" command
'fsync' 'fs' whether to invoke fsync() after file write
'gdefault' 'gd' the ":substitute" flag 'g' is default on
'grepformat' 'gfm' format of 'grepprg' output
@@ -873,9 +875,9 @@ Short explanation of each option: *option-list*
'switchbuf' 'swb' sets behavior when switching to another buffer
'synmaxcol' 'smc' maximum column to find syntax items
'syntax' 'syn' syntax to be loaded for current buffer
-'tabstop' 'ts' number of spaces that <Tab> in file uses
'tabline' 'tal' custom format for the console tab pages line
'tabpagemax' 'tpm' maximum number of tab pages for |-p| and "tab all"
+'tabstop' 'ts' number of spaces that <Tab> in file uses
'tagbsearch' 'tbs' use binary searching in tags files
'taglength' 'tl' number of significant characters for a tag
'tagrelative' 'tr' file names in tag file are relative
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 6aed7441a0..d1c1f90c37 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt* For Vim version 7.4. Last change: 2015 Mar 29
+*syntax.txt* For Vim version 7.4. Last change: 2015 Jul 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3684,6 +3684,7 @@ Whether or not it is actually concealed depends on the value of the
'conceallevel' option. The 'concealcursor' option is used to decide whether
concealable items in the current line are displayed unconcealed to be able to
edit the line.
+Another way to conceal text with with |matchadd()|.
concealends *:syn-concealends*
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 8722fced26..17e16911bc 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -21,10 +21,10 @@ these differences.
==============================================================================
1. Configuration *nvim-configuration*
-- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for storing
+- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for storing
configuration.
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
-- Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
+- Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
session information.
==============================================================================
@@ -73,56 +73,56 @@ are always available and may be used simultaneously in separate plugins. The
|nvim-python|).
|mkdir()| behaviour changed:
-1. Assuming /tmp/foo does not exist and /tmp can be written to
+1. Assuming /tmp/foo does not exist and /tmp can be written to
mkdir('/tmp/foo/bar', 'p', 0700) will create both /tmp/foo and /tmp/foo/bar
with 0700 permissions. Vim mkdir will create /tmp/foo with 0755.
-2. If you try to create an existing directory with `'p'` (e.g. mkdir('/',
+2. If you try to create an existing directory with `'p'` (e.g. mkdir('/',
'p')) mkdir() will silently exit. In Vim this was an error.
3. mkdir() error messages now include strerror() text when mkdir fails.
'encoding' cannot be changed after startup.
|string()| and |:echo| behaviour changed:
-1. No maximum recursion depth limit is applied to nested container
+1. No maximum recursion depth limit is applied to nested container
structures.
-2. |string()| fails immediately on nested containers, not when recursion limit
+2. |string()| fails immediately on nested containers, not when recursion limit
was exceeded.
2. When |:echo| encounters duplicate containers like >
let l = []
echo [l, l]
<
- it does not use "[...]" (was: "[[], [...]]", now: "[[], []]"). "..." is
+ it does not use "[...]" (was: "[[], [...]]", now: "[[], []]"). "..." is
only used for recursive containers.
-3. |:echo| printing nested containers adds "@level" after "..." designating
- the level at which recursive container was printed: |:echo-self-refer|.
- Same thing applies to |string()| (though it uses construct like
- "{E724@level}"), but this is not reliable because |string()| continues to
+3. |:echo| printing nested containers adds "@level" after "..." designating
+ the level at which recursive container was printed: |:echo-self-refer|.
+ Same thing applies to |string()| (though it uses construct like
+ "{E724@level}"), but this is not reliable because |string()| continues to
error out.
-4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
+4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
back.
-Viminfo text files were replaced with binary (messagepack) ShaDa files.
+Viminfo text files were replaced with binary (messagepack) ShaDa files.
Additional differences:
- |shada-c| has no effect.
- |shada-s| now limits size of every item and not just registers.
-- When reading ShaDa files items are merged according to the timestamp.
+- When reading ShaDa files items are merged according to the timestamp.
|shada-merging|
-- 'viminfo' option got renamed to 'shada'. Old option is kept as an alias for
+- 'viminfo' option got renamed to 'shada'. Old option is kept as an alias for
compatibility reasons.
-- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old
+- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old
commands are still kept.
- |:oldfiles| supports !.
-- When writing (|:wshada| without bang or at exit) it merges much more data,
- and does this according to the timestamp. Vim merges only marks.
+- When writing (|:wshada| without bang or at exit) it merges much more data,
+ and does this according to the timestamp. Vim merges only marks.
|shada-merging|
-- ShaDa file format was designed with forward and backward compatibility in
+- ShaDa file format was designed with forward and backward compatibility in
mind. |shada-compatibility|
-- Some errors make ShaDa code keep temporary file in-place for user to decide
- what to do with it. Vim deletes temporary file in these cases.
+- Some errors make ShaDa code keep temporary file in-place for user to decide
+ what to do with it. Vim deletes temporary file in these cases.
|shada-error-handling|
-- Vim keeps no timestamps at all, neither in viminfo file nor in the instance
+- Vim keeps no timestamps at all, neither in viminfo file nor in the instance
itself.
- ShaDa file keeps search direction (|v:searchforward|), viminfo does not.
@@ -141,8 +141,8 @@ Meta (alt) chords are recognized (even in the terminal).
Note: Meta chords are case-sensitive (<M-a> is distinguished from <M-A>).
-Some `CTRL-SHIFT-...` key chords are distinguished from `CTRL-...` variants (even in
-the terminal). Specifically, the following are known to work:
+Some `CTRL-SHIFT-...` key chords are distinguished from `CTRL-...` variants
+(even in the terminal). Specifically, the following are known to work:
<C-Tab>, <C-S-Tab>
<C-BS>, <C-S-BS>
<C-Enter>, <C-S-Enter>
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index eee171b7da..29c8aaf808 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -706,7 +706,7 @@ can also get to them with the buffer list commands, like ":bnext".
*:bufdo*
:[range]bufdo[!] {cmd} Execute {cmd} in each buffer in the buffer list or if
- [range[ is given only for buffers for which their
+ [range] is given only for buffers for which their
buffer name is in the [range]. It works like doing
this: >
:bfirst
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index d60ab65ce7..15928d6722 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -2174,6 +2174,9 @@ au BufNewFile,BufRead *.tli setf tli
" Telix Salt
au BufNewFile,BufRead *.slt setf tsalt
+" Tera Term Language
+au BufRead,BufNewFile *.ttl setf teraterm
+
" Terminfo
au BufNewFile,BufRead *.ti setf terminfo
diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim
index 0394ee22e8..29a25a2108 100644
--- a/runtime/indent/sh.vim
+++ b/runtime/indent/sh.vim
@@ -1,6 +1,8 @@
" Vim indent file
" Language: Shell Script
-" Maintainer: Peter Aronoff <telemachus@arpinum.org>
+" Maintainer: Currently unmaintained. If you want to take it, please
+" email Bram
+" Previous Maintainer: Peter Aronoff <telemachus@arpinum.org>
" Original Author: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2014-08-22
diff --git a/runtime/indent/teraterm.vim b/runtime/indent/teraterm.vim
new file mode 100644
index 0000000000..ba24257b02
--- /dev/null
+++ b/runtime/indent/teraterm.vim
@@ -0,0 +1,67 @@
+" Vim indent file
+" Language: Tera Term Language (TTL)
+" Based on Tera Term Version 4.86
+" Maintainer: Ken Takata
+" URL: https://github.com/k-takata/vim-teraterm
+" Last Change: 2015 Jun 4
+" Filenames: *.ttl
+" License: VIM License
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nosmartindent
+setlocal noautoindent
+setlocal indentexpr=GetTeraTermIndent(v:lnum)
+setlocal indentkeys=!^F,o,O,e
+setlocal indentkeys+==elseif,=endif,=loop,=next,=enduntil,=endwhile
+
+if exists("*GetTeraTermIndent")
+ finish
+endif
+
+" The shiftwidth() function is relatively new.
+" Don't require it to exist.
+if exists('*shiftwidth')
+ function s:sw() abort
+ return shiftwidth()
+ endfunction
+else
+ function s:sw() abort
+ return &shiftwidth
+ endfunction
+endif
+
+function! GetTeraTermIndent(lnum)
+ let l:prevlnum = prevnonblank(a:lnum-1)
+ if l:prevlnum == 0
+ " top of file
+ return 0
+ endif
+
+ " grab the previous and current line, stripping comments.
+ let l:prevl = substitute(getline(l:prevlnum), ';.*$', '', '')
+ let l:thisl = substitute(getline(a:lnum), ';.*$', '', '')
+ let l:previ = indent(l:prevlnum)
+
+ let l:ind = l:previ
+
+ if l:prevl =~ '^\s*if\>.*\<then\s*$'
+ " previous line opened a block
+ let l:ind += s:sw()
+ endif
+ if l:prevl =~ '^\s*\%(elseif\|else\|do\|until\|while\|for\)\>'
+ " previous line opened a block
+ let l:ind += s:sw()
+ endif
+ if l:thisl =~ '^\s*\%(elseif\|else\|endif\|enduntil\|endwhile\|loop\|next\)\>'
+ " this line closed a block
+ let l:ind -= s:sw()
+ endif
+
+ return l:ind
+endfunction
+
+" vim: ts=8 sw=2 sts=2
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index a092f18d23..536c87ad7f 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2014 Nov 19
+" Last Change: 2015 Jul 22
" If there already is an option window, jump to that one.
if bufwinnr("option-window") > 0
@@ -673,6 +673,8 @@ call append("$", "errorbells\tring the bell for error messages")
call <SID>BinOptionG("eb", &eb)
call append("$", "visualbell\tuse a visual bell instead of beeping")
call <SID>BinOptionG("vb", &vb)
+call append("$", "belloff\tdo not ring the bell for these reasons")
+call <SID>OptionG("belloff", &belloff)
if has("multi_lang")
call append("$", "helplang\tlist of preferred languages for finding help")
call <SID>OptionG("hlg", &hlg)
@@ -922,7 +924,7 @@ call <SID>BinOptionL("bin")
call append("$", "endofline\tlast line in the file has an end-of-line")
call append("$", "\t(local to buffer)")
call <SID>BinOptionL("eol")
-call append("$", "fixeol\tfixes missing end-of-line at end of text file")
+call append("$", "fixendofline\tfixes missing end-of-line at end of text file")
call append("$", "\t(local to buffer)")
call <SID>BinOptionL("fixeol")
if has("multi_byte")
diff --git a/runtime/plugin/spellfile.vim b/runtime/plugin/spellfile.vim
index 437296090c..e03659d6d6 100644
--- a/runtime/plugin/spellfile.vim
+++ b/runtime/plugin/spellfile.vim
@@ -1,15 +1,8 @@
" Vim plugin for downloading spell files
-" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2006 Feb 01
-" Exit quickly when:
-" - this plugin was already loaded
-" - when 'compatible' is set
-" - some autocommands are already taking care of spell files
if exists("loaded_spellfile_plugin") || &cp || exists("#SpellFileMissing")
finish
endif
let loaded_spellfile_plugin = 1
-" The function is in the autoload directory.
autocmd SpellFileMissing * call spellfile#LoadFile(expand('<amatch>'))
diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index c608aeedeb..f4369df131 100644
--- a/runtime/syntax/python.vim
+++ b/runtime/syntax/python.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Python
" Maintainer: Zvezdan Petkovic <zpetkovic@acm.org>
-" Last Change: 2015 Jun 19
+" Last Change: 2015 Jul 14
" Credits: Neil Schemenauer <nas@python.ca>
" Dmitry Vasiliev
"
@@ -51,24 +51,25 @@ set cpo&vim
" Keep Python keywords in alphabetical order inside groups for easy
" comparison with the table in the 'Python Language Reference'
-" http://docs.python.org/reference/lexical_analysis.html#keywords.
+" https://docs.python.org/2/reference/lexical_analysis.html#keywords,
+" https://docs.python.org/3/reference/lexical_analysis.html#keywords.
" Groups are in the order presented in NAMING CONVENTIONS in syntax.txt.
" Exceptions come last at the end of each group (class and def below).
"
" Keywords 'with' and 'as' are new in Python 2.6
" (use 'from __future__ import with_statement' in Python 2.5).
"
-" Some compromises had to be made to support both Python 3.0 and 2.6.
-" We include Python 3.0 features, but when a definition is duplicated,
+" Some compromises had to be made to support both Python 3 and 2.
+" We include Python 3 features, but when a definition is duplicated,
" the last definition takes precedence.
"
-" - 'False', 'None', and 'True' are keywords in Python 3.0 but they are
-" built-ins in 2.6 and will be highlighted as built-ins below.
-" - 'exec' is a built-in in Python 3.0 and will be highlighted as
+" - 'False', 'None', and 'True' are keywords in Python 3 but they are
+" built-ins in 2 and will be highlighted as built-ins below.
+" - 'exec' is a built-in in Python 3 and will be highlighted as
" built-in below.
-" - 'nonlocal' is a keyword in Python 3.0 and will be highlighted.
-" - 'print' is a built-in in Python 3.0 and will be highlighted as
-" built-in below (use 'from __future__ import print_function' in 2.6)
+" - 'nonlocal' is a keyword in Python 3 and will be highlighted.
+" - 'print' is a built-in in Python 3 and will be highlighted as
+" built-in below (use 'from __future__ import print_function' in 2)
"
syn keyword pythonStatement False, None, True
syn keyword pythonStatement as assert break continue del exec global
@@ -147,7 +148,8 @@ endif
" - 08e0 or 08j are highlighted,
"
" and so on, as specified in the 'Python Language Reference'.
-" http://docs.python.org/reference/lexical_analysis.html#numeric-literals
+" https://docs.python.org/2/reference/lexical_analysis.html#numeric-literals
+" https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
if !exists("python_no_number_highlight")
" numbers (including longs and complex)
syn match pythonNumber "\<0[oO]\=\o\+[Ll]\=\>"
@@ -159,54 +161,58 @@ if !exists("python_no_number_highlight")
syn match pythonNumber
\ "\<\d\+\.\%([eE][+-]\=\d\+\)\=[jJ]\=\%(\W\|$\)\@="
syn match pythonNumber
- \ "\%(^\|\W\)\@<=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>"
+ \ "\%(^\|\W\)\zs\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>"
endif
" Group the built-ins in the order in the 'Python Library Reference' for
" easier comparison.
-" http://docs.python.org/library/constants.html
-" http://docs.python.org/library/functions.html
-" http://docs.python.org/library/functions.html#non-essential-built-in-functions
+" https://docs.python.org/2/library/constants.html
+" https://docs.python.org/3/library/constants.html
+" http://docs.python.org/2/library/functions.html
+" http://docs.python.org/3/library/functions.html
+" http://docs.python.org/2/library/functions.html#non-essential-built-in-functions
+" http://docs.python.org/3/library/functions.html#non-essential-built-in-functions
" Python built-in functions are in alphabetical order.
if !exists("python_no_builtin_highlight")
" built-in constants
- " 'False', 'True', and 'None' are also reserved words in Python 3.0
+ " 'False', 'True', and 'None' are also reserved words in Python 3
syn keyword pythonBuiltin False True None
syn keyword pythonBuiltin NotImplemented Ellipsis __debug__
" built-in functions
- syn keyword pythonBuiltin abs all any bin bool chr classmethod
- syn keyword pythonBuiltin compile complex delattr dict dir divmod
- syn keyword pythonBuiltin enumerate eval filter float format
+ syn keyword pythonBuiltin abs all any bin bool bytearray callable chr
+ syn keyword pythonBuiltin classmethod compile complex delattr dict dir
+ syn keyword pythonBuiltin divmod enumerate eval filter float format
syn keyword pythonBuiltin frozenset getattr globals hasattr hash
syn keyword pythonBuiltin help hex id input int isinstance
syn keyword pythonBuiltin issubclass iter len list locals map max
- syn keyword pythonBuiltin min next object oct open ord pow print
- syn keyword pythonBuiltin property range repr reversed round set
+ syn keyword pythonBuiltin memoryview min next object oct open ord pow
+ syn keyword pythonBuiltin print property range repr reversed round set
syn keyword pythonBuiltin setattr slice sorted staticmethod str
syn keyword pythonBuiltin sum super tuple type vars zip __import__
- " Python 2.6 only
- syn keyword pythonBuiltin basestring callable cmp execfile file
+ " Python 2 only
+ syn keyword pythonBuiltin basestring cmp execfile file
syn keyword pythonBuiltin long raw_input reduce reload unichr
syn keyword pythonBuiltin unicode xrange
- " Python 3.0 only
- syn keyword pythonBuiltin ascii bytearray bytes exec memoryview
- " non-essential built-in functions; Python 2.6 only
+ " Python 3 only
+ syn keyword pythonBuiltin ascii bytes exec
+ " non-essential built-in functions; Python 2 only
syn keyword pythonBuiltin apply buffer coerce intern
endif
" From the 'Python Library Reference' class hierarchy at the bottom.
-" http://docs.python.org/library/exceptions.html
+" http://docs.python.org/2/library/exceptions.html
+" http://docs.python.org/3/library/exceptions.html
if !exists("python_no_exception_highlight")
- " builtin base exceptions (only used as base classes for other exceptions)
+ " builtin base exceptions (used mostly as base classes for other exceptions)
syn keyword pythonExceptions BaseException Exception
- syn keyword pythonExceptions ArithmeticError EnvironmentError
+ syn keyword pythonExceptions ArithmeticError BufferError
syn keyword pythonExceptions LookupError
- " builtin base exception removed in Python 3.0
- syn keyword pythonExceptions StandardError
+ " builtin base exceptions removed in Python 3
+ syn keyword pythonExceptions EnvironmentError StandardError
" builtin exceptions (actually raised)
- syn keyword pythonExceptions AssertionError AttributeError BufferError
+ syn keyword pythonExceptions AssertionError AttributeError
syn keyword pythonExceptions EOFError FloatingPointError GeneratorExit
- syn keyword pythonExceptions IOError ImportError IndentationError
+ syn keyword pythonExceptions ImportError IndentationError
syn keyword pythonExceptions IndexError KeyError KeyboardInterrupt
syn keyword pythonExceptions MemoryError NameError NotImplementedError
syn keyword pythonExceptions OSError OverflowError ReferenceError
@@ -214,13 +220,26 @@ if !exists("python_no_exception_highlight")
syn keyword pythonExceptions SystemError SystemExit TabError TypeError
syn keyword pythonExceptions UnboundLocalError UnicodeError
syn keyword pythonExceptions UnicodeDecodeError UnicodeEncodeError
- syn keyword pythonExceptions UnicodeTranslateError ValueError VMSError
- syn keyword pythonExceptions WindowsError ZeroDivisionError
+ syn keyword pythonExceptions UnicodeTranslateError ValueError
+ syn keyword pythonExceptions ZeroDivisionError
+ " builtin OS exceptions in Python 3
+ syn keyword pythonExceptions BlockingIOError BrokenPipeError
+ syn keyword pythonExceptions ChildProcessError ConnectionAbortedError
+ syn keyword pythonExceptions ConnectionError ConnectionRefusedError
+ syn keyword pythonExceptions ConnectionResetError FileExistsError
+ syn keyword pythonExceptions FileNotFoundError InterruptedError
+ syn keyword pythonExceptions IsADirectoryError NotADirectoryError
+ syn keyword pythonExceptions PermissionError ProcessLookupError
+ syn keyword pythonExceptions TimeoutError
+ " builtin exceptions deprecated/removed in Python 3
+ syn keyword pythonExceptions IOError VMSError WindowsError
" builtin warnings
syn keyword pythonExceptions BytesWarning DeprecationWarning FutureWarning
syn keyword pythonExceptions ImportWarning PendingDeprecationWarning
syn keyword pythonExceptions RuntimeWarning SyntaxWarning UnicodeWarning
syn keyword pythonExceptions UserWarning Warning
+ " builtin warnings in Python 3
+ syn keyword pythonExceptions ResourceWarning
endif
if exists("python_space_error_highlight")
diff --git a/runtime/syntax/teraterm.vim b/runtime/syntax/teraterm.vim
new file mode 100644
index 0000000000..521331d8ce
--- /dev/null
+++ b/runtime/syntax/teraterm.vim
@@ -0,0 +1,139 @@
+" Vim syntax file
+" Language: Tera Term Language (TTL)
+" Based on Tera Term Version 4.86
+" Maintainer: Ken Takata
+" URL: https://github.com/k-takata/vim-teraterm
+" Last Change: 2015 Jun 24
+" Filenames: *.ttl
+" License: VIM License
+
+if exists("b:current_syntax")
+ finish
+endif
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+syn case ignore
+
+syn region ttlComment start=";" end="$" contains=@Spell
+syn region ttlComment start="/\*" end="\*/" contains=@Spell
+syn region ttlFirstComment start="/\*" end="\*/" contained contains=@Spell
+ \ nextgroup=ttlStatement,ttlFirstComment
+
+syn match ttlCharacter "#\%(\d\+\|\$\x\+\)\>"
+syn match ttlNumber "\%(\<\d\+\|\$\x\+\)\>"
+syn match ttlString "'[^']*'" contains=@Spell
+syn match ttlString '"[^"]*"' contains=@Spell
+syn cluster ttlConstant contains=ttlCharacter,ttlNumber,ttlString
+
+syn match ttlLabel ":\s*\w\{1,32}\>"
+
+syn keyword ttlOperator and or xor not
+
+syn match ttlVar "\<groupmatchstr\d\>"
+syn match ttlVar "\<param\d\>"
+syn keyword ttlVar inputstr matchstr paramcnt result timeout mtimeout
+
+
+syn match ttlLine nextgroup=ttlStatement "^"
+syn match ttlStatement contained "\s*"
+ \ nextgroup=ttlIf,ttlElseIf,ttlConditional,ttlRepeat,
+ \ ttlFirstComment,ttlComment,ttlLabel,@ttlCommand
+
+syn cluster ttlCommand contains=ttlControlCommand,ttlCommunicationCommand,
+ \ ttlStringCommand,ttlFileCommand,ttlPasswordCommand,
+ \ ttlMiscCommand
+
+
+syn keyword ttlIf contained nextgroup=ttlIfExpression if
+syn keyword ttlElseIf contained nextgroup=ttlElseIfExpression elseif
+
+syn match ttlIfExpression contained "\s.*"
+ \ contains=@ttlConstant,ttlVar,ttlOperator,ttlComment,ttlThen,
+ \ @ttlCommand
+syn match ttlElseIfExpression contained "\s.*"
+ \ contains=@ttlConstant,ttlVar,ttlOperator,ttlComment,ttlThen
+
+syn keyword ttlThen contained then
+syn keyword ttlConditional contained else endif
+
+syn keyword ttlRepeat contained for next until enduntil while endwhile
+syn match ttlRepeat contained
+ \ "\<\%(do\|loop\)\%(\s\+\%(while\|until\)\)\?\>"
+syn keyword ttlControlCommand contained
+ \ break call continue end execcmnd exit goto include
+ \ mpause pause return
+
+
+syn keyword ttlCommunicationCommand contained
+ \ bplusrecv bplussend callmenu changedir clearscreen
+ \ closett connect cygconnect disconnect dispstr
+ \ enablekeyb flushrecv gethostname getmodemstatus
+ \ gettitle kmtfinish kmtget kmtrecv kmtsend loadkeymap
+ \ logautoclosemode logclose loginfo logopen logpause
+ \ logrotate logstart logwrite quickvanrecv
+ \ quickvansend recvln restoresetup scprecv scpsend
+ \ send sendbreak sendbroadcast sendfile sendkcode
+ \ sendln sendlnbroadcast sendmulticast setbaud
+ \ setdebug setdtr setecho setmulticastname setrts
+ \ setsync settitle showtt testlink unlink wait
+ \ wait4all waitevent waitln waitn waitrecv waitregex
+ \ xmodemrecv xmodemsend ymodemrecv ymodemsend
+ \ zmodemrecv zmodemsend
+syn keyword ttlStringCommand contained
+ \ code2str expandenv int2str regexoption sprintf
+ \ sprintf2 str2code str2int strcompare strconcat
+ \ strcopy strinsert strjoin strlen strmatch strremove
+ \ strreplace strscan strspecial strsplit strtrim
+ \ tolower toupper
+syn keyword ttlFileCommand contained
+ \ basename dirname fileclose fileconcat filecopy
+ \ filecreate filedelete filelock filemarkptr fileopen
+ \ filereadln fileread filerename filesearch fileseek
+ \ fileseekback filestat filestrseek filestrseek2
+ \ filetruncate fileunlock filewrite filewriteln
+ \ findfirst findnext findclose foldercreate
+ \ folderdelete foldersearch getdir getfileattr makepath
+ \ setdir setfileattr
+syn keyword ttlPasswordCommand contained
+ \ delpassword getpassword ispassword passwordbox
+ \ setpassword
+syn keyword ttlMiscCommand contained
+ \ beep bringupbox checksum8 checksum8file checksum16
+ \ checksum16file checksum32 checksum32file closesbox
+ \ clipb2var crc16 crc16file crc32 crc32file exec
+ \ dirnamebox filenamebox getdate getenv getipv4addr
+ \ getipv6addr getspecialfolder gettime getttdir getver
+ \ ifdefined inputbox intdim listbox messagebox random
+ \ rotateleft rotateright setdate setdlgpos setenv
+ \ setexitcode settime show statusbox strdim uptime
+ \ var2clipb yesnobox
+
+
+hi def link ttlCharacter Character
+hi def link ttlNumber Number
+hi def link ttlComment Comment
+hi def link ttlFirstComment Comment
+hi def link ttlString String
+hi def link ttlLabel Label
+hi def link ttlIf Conditional
+hi def link ttlElseIf Conditional
+hi def link ttlThen Conditional
+hi def link ttlConditional Conditional
+hi def link ttlRepeat Repeat
+hi def link ttlControlCommand Keyword
+hi def link ttlVar Identifier
+hi def link ttlOperator Operator
+hi def link ttlCommunicationCommand Keyword
+hi def link ttlStringCommand Keyword
+hi def link ttlFileCommand Keyword
+hi def link ttlPasswordCommand Keyword
+hi def link ttlMiscCommand Keyword
+
+let b:current_syntax = "teraterm"
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: ts=8 sw=2 sts=2
diff --git a/runtime/syntax/vb.vim b/runtime/syntax/vb.vim
index 14f9e64850..0c05b35fbd 100644
--- a/runtime/syntax/vb.vim
+++ b/runtime/syntax/vb.vim
@@ -223,7 +223,7 @@ syn keyword vbStatement Explicit FileCopy For ForEach Function Get GoSub
syn keyword vbStatement GoTo Gosub Implements Kill LSet Let Lib LineInput
syn keyword vbStatement Load Lock Loop Mid MkDir Name Next On OnError Open
syn keyword vbStatement Option Preserve Private Property Public Put RSet
-syn keyword vbStatement RaiseEvent Randomize ReDim Redim Rem Reset Resume
+syn keyword vbStatement RaiseEvent Randomize ReDim Redim Reset Resume
syn keyword vbStatement Return RmDir SavePicture SaveSetting Seek SendKeys
syn keyword vbStatement Sendkeys Set SetAttr Static Step Stop Sub Time
syn keyword vbStatement Type Unload Unlock Until Wend While Width With
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 7612a2ada0..4dc24a8cdf 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -65,7 +65,7 @@ get_vim_sources() {
if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
- git clone --depth=1000 https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
+ git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}"
cd "${VIM_SOURCE_DIR}"
else
if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then
@@ -243,7 +243,7 @@ list_vim_patches() {
local patch_number="${vim_tag:5}" # Remove prefix like "v7.4."
# Tagged Vim patch, check version.c:
is_missing="$(sed -n '/static int included_patches/,/}/p' "${NEOVIM_SOURCE_DIR}/src/nvim/version.c" |
- grep -x -e "[[:space:]]*//[[:space:]]${patch_number} NA" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")"
+ grep -x -e "[[:space:]]*//[[:space:]]${patch_number} NA.*" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")"
vim_commit="${vim_tag#v}"
else
# Untagged Vim patch (e.g. runtime updates), check the Neovim git log:
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index b80352b7b8..487b554d6d 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -77,7 +77,6 @@ list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
# Handle legacy files that don't yet pass -Wconversion.
set(CONV_SOURCES
buffer.c
- charset.c
diff.c
edit.c
eval.c
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 8d3769cb54..c514c4378e 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -264,17 +264,16 @@ open_buffer (
return retval;
}
-/*
- * Return TRUE if "buf" points to a valid buffer (in the buffer list).
- */
-int buf_valid(buf_T *buf)
+/// Check that "buf" points to a valid buffer (in the buffer list).
+bool buf_valid(buf_T *buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
FOR_ALL_BUFFERS(bp) {
if (bp == buf) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
/*
@@ -2062,16 +2061,15 @@ void buflist_setfpos(buf_T *const buf, win_T *const win,
}
-/*
- * Return true when "wip" has 'diff' set and the diff is only for another tab
- * page. That's because a diff is local to a tab page.
- */
+/// Check that "wip" has 'diff' set and the diff is only for another tab page.
+/// That's because a diff is local to a tab page.
static bool wininfo_other_tab_diff(wininfo_T *wip)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
if (wip->wi_opt.wo_diff) {
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
- /* return false when it's a window in the current tab page, thus
- * the buffer was in diff mode here */
+ // return false when it's a window in the current tab page, thus
+ // the buffer was in diff mode here
if (wip->wi_win == wp) {
return false;
}
@@ -2428,52 +2426,62 @@ void buflist_altfpos(win_T *win)
buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE);
}
-/*
- * Return TRUE if 'ffname' is not the same file as current file.
- * Fname must have a full path (expanded by path_get_absolute_path()).
- */
-int otherfile(char_u *ffname)
+/// Check that "ffname" is not the same file as current file.
+/// Fname must have a full path (expanded by path_get_absolute_path()).
+///
+/// @param ffname full path name to check
+bool otherfile(char_u *ffname)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
return otherfile_buf(curbuf, ffname, NULL, false);
}
-static int otherfile_buf(buf_T *buf, char_u *ffname,
- FileID *file_id_p, bool file_id_valid)
+/// Check that "ffname" is not the same file as the file loaded in "buf".
+/// Fname must have a full path (expanded by path_get_absolute_path()).
+///
+/// @param buf buffer to check
+/// @param ffname full path name to check
+/// @param file_id_p information about the file at "ffname".
+/// @param file_id_valid whether a valid "file_id_p" was passed in.
+static bool otherfile_buf(buf_T *buf, char_u *ffname, FileID *file_id_p,
+ bool file_id_valid)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
- /* no name is different */
+ // no name is different
if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL) {
- return TRUE;
+ return true;
}
if (fnamecmp(ffname, buf->b_ffname) == 0) {
- return FALSE;
+ return false;
}
{
FileID file_id;
- /* If no struct stat given, get it now */
+ // If no struct stat given, get it now
if (file_id_p == NULL) {
file_id_p = &file_id;
file_id_valid = os_fileid((char *)ffname, file_id_p);
}
if (!file_id_valid) {
// file_id not valid, assume files are different.
- return TRUE;
+ return true;
}
- /* Use dev/ino to check if the files are the same, even when the names
- * are different (possible with links). Still need to compare the
- * name above, for when the file doesn't exist yet.
- * Problem: The dev/ino changes when a file is deleted (and created
- * again) and remains the same when renamed/moved. We don't want to
- * stat() each buffer each time, that would be too slow. Get the
- * dev/ino again when they appear to match, but not when they appear
- * to be different: Could skip a buffer when it's actually the same
- * file. */
+ // Use dev/ino to check if the files are the same, even when the names
+ // are different (possible with links). Still need to compare the
+ // name above, for when the file doesn't exist yet.
+ // Problem: The dev/ino changes when a file is deleted (and created
+ // again) and remains the same when renamed/moved. We don't want to
+ // stat() each buffer each time, that would be too slow. Get the
+ // dev/ino again when they appear to match, but not when they appear
+ // to be different: Could skip a buffer when it's actually the same
+ // file.
if (buf_same_file_id(buf, file_id_p)) {
buf_set_file_id(buf);
- if (buf_same_file_id(buf, file_id_p))
- return FALSE;
+ if (buf_same_file_id(buf, file_id_p)) {
+ return false;
+ }
}
}
- return TRUE;
+ return true;
}
// Set file_id for a buffer.
@@ -2490,11 +2498,14 @@ void buf_set_file_id(buf_T *buf)
}
}
-// return TRUE if file_id in buffer "buf" matches with "file_id".
+/// Check that file_id in buffer "buf" matches with "file_id".
+///
+/// @param buf buffer
+/// @param file_id file id
static bool buf_same_file_id(buf_T *buf, FileID *file_id)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
- return buf->file_id_valid
- && os_fileid_equal(&(buf->file_id), file_id);
+ return buf->file_id_valid && os_fileid_equal(&(buf->file_id), file_id);
}
/*
@@ -2777,23 +2788,28 @@ void maketitle(void)
resettitle();
}
-/*
- * Used for title and icon: Check if "str" differs from "*last". Set "*last"
- * from "str" if it does.
- * Return TRUE when "*last" changed.
- */
-static int ti_change(char_u *str, char_u **last)
+/// Used for title and icon: Check if "str" differs from "*last". Set "*last"
+/// from "str" if it does by freeing the old value of "*last" and duplicating
+/// "str".
+///
+/// @param str desired title string
+/// @param[in,out] last current title string
+//
+/// @return true when "*last" changed.
+static bool ti_change(char_u *str, char_u **last)
+ FUNC_ATTR_WARN_UNUSED_RESULT
{
if ((str == NULL) != (*last == NULL)
|| (str != NULL && *last != NULL && STRCMP(str, *last) != 0)) {
xfree(*last);
- if (str == NULL)
+ if (str == NULL) {
*last = NULL;
- else
+ } else {
*last = vim_strsave(str);
- return TRUE;
+ }
+ return true;
}
- return FALSE;
+ return false;
}
/*
@@ -3929,26 +3945,29 @@ void get_rel_pos(win_T *wp, char_u *buf, int buflen)
: (int)(above * 100L / (above + below)));
}
-/*
- * Append (file 2 of 8) to "buf[buflen]", if editing more than one file.
- * Return TRUE if it was appended.
- */
-static int
-append_arg_number (
- win_T *wp,
- char_u *buf,
- int buflen,
- int add_file /* Add "file" before the arg number */
-)
+/// Append (file 2 of 8) to "buf[buflen]", if editing more than one file.
+///
+/// @param wp window whose buffers to check
+/// @param[in,out] buf string buffer to add the text to
+/// @param buflen length of the string buffer
+/// @param add_file if true, add "file" before the arg number
+///
+/// @return true if it was appended.
+static bool append_arg_number(win_T *wp, char_u *buf, int buflen, bool add_file)
+ FUNC_ATTR_NONNULL_ALL
{
- char_u *p;
+ // Nothing to do
+ if (ARGCOUNT <= 1) {
+ return false;
+ }
- if (ARGCOUNT <= 1) /* nothing to do */
- return FALSE;
+ char_u *p = buf + STRLEN(buf); // go to the end of the buffer
+
+ // Early out if the string is getting too long
+ if (p - buf + 35 >= buflen) {
+ return false;
+ }
- p = buf + STRLEN(buf); /* go to the end of the buffer */
- if (p - buf + 35 >= buflen) /* getting too long */
- return FALSE;
*p++ = ' ';
*p++ = '(';
if (add_file) {
@@ -3956,9 +3975,10 @@ append_arg_number (
p += 5;
}
vim_snprintf((char *)p, (size_t)(buflen - (p - buf)),
- wp->w_arg_idx_invalid ? "(%d) of %d)"
- : "%d of %d)", wp->w_arg_idx + 1, ARGCOUNT);
- return TRUE;
+ wp->w_arg_idx_invalid
+ ? "(%d) of %d)"
+ : "%d of %d)", wp->w_arg_idx + 1, ARGCOUNT);
+ return true;
}
/*
@@ -4592,11 +4612,16 @@ char_u *buf_spname(buf_T *buf)
return NULL;
}
-/*
- * Find a window for buffer "buf".
- * If found true is returned and "wp" and "tp" are set to the window and tabpage.
- * If not found false is returned.
- */
+/// Find a window for buffer "buf".
+/// If found true is returned and "wp" and "tp" are set to
+/// the window and tabpage.
+/// If not found, false is returned.
+///
+/// @param buf buffer to find a window for
+/// @param[out] wp stores the found window
+/// @param[out] tp stores the found tabpage
+///
+/// @return true if a window was found for the buffer.
bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp)
{
*wp = NULL;
@@ -5110,50 +5135,54 @@ void set_buflisted(int on)
}
}
-/*
- * Read the file for "buf" again and check if the contents changed.
- * Return TRUE if it changed or this could not be checked.
- */
-int buf_contents_changed(buf_T *buf)
+/// Read the file for "buf" again and check if the contents changed.
+/// Return true if it changed or this could not be checked.
+///
+/// @param buf buffer to check
+///
+/// @return true if the buffer's contents have changed
+bool buf_contents_changed(buf_T *buf)
+ FUNC_ATTR_NONNULL_ALL
{
- buf_T *newbuf;
- int differ = TRUE;
- linenr_T lnum;
- aco_save_T aco;
- exarg_T ea;
+ bool differ = true;
- /* Allocate a buffer without putting it in the buffer list. */
- newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
- if (newbuf == NULL)
- return TRUE;
+ // Allocate a buffer without putting it in the buffer list.
+ buf_T *newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
+ if (newbuf == NULL) {
+ return true;
+ }
- /* Force the 'fileencoding' and 'fileformat' to be equal. */
+ // Force the 'fileencoding' and 'fileformat' to be equal.
+ exarg_T ea;
prep_exarg(&ea, buf);
- /* set curwin/curbuf to buf and save a few things */
+ // set curwin/curbuf to buf and save a few things
+ aco_save_T aco;
aucmd_prepbuf(&aco, newbuf);
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
- (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
- &ea, READ_NEW | READ_DUMMY) == OK) {
- /* compare the two files line by line */
+ (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
+ &ea, READ_NEW | READ_DUMMY) == OK) {
+ // compare the two files line by line
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) {
- differ = FALSE;
- for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
- if (STRCMP(ml_get_buf(buf, lnum, FALSE), ml_get(lnum)) != 0) {
- differ = TRUE;
+ differ = false;
+ for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
+ if (STRCMP(ml_get_buf(buf, lnum, false), ml_get(lnum)) != 0) {
+ differ = true;
break;
}
+ }
}
}
xfree(ea.cmd);
- /* restore curwin/curbuf and a few other things */
+ // restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
- if (curbuf != newbuf) /* safety check */
- wipe_buffer(newbuf, FALSE);
+ if (curbuf != newbuf) { // safety check
+ wipe_buffer(newbuf, false);
+ }
return differ;
}
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 936a14b903..86e63eb52c 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -533,9 +533,9 @@ struct file_buffer {
/*
* Character table, only used in charset.c for 'iskeyword'
- * 32 bytes of 8 bits: 1 bit per character 0-255.
+ * bitset with 4*64=256 bits: 1 bit per character 0-255.
*/
- char_u b_chartab[32];
+ uint64_t b_chartab[4];
/* Table used for mappings local to a buffer. */
mapblock_T *(b_maphash[256]);
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 4e329b5cd8..83e2aaa6e6 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -32,16 +32,16 @@
#endif
-static int chartab_initialized = FALSE;
+static bool chartab_initialized = false;
-// b_chartab[] is an array of 32 bytes, each bit representing one of the
+// b_chartab[] is an array with 256 bits, each bit representing one of the
// characters 0-255.
#define SET_CHARTAB(buf, c) \
- (buf)->b_chartab[(unsigned)(c) >> 3] |= (1 << ((c) & 0x7))
+ (buf)->b_chartab[(unsigned)(c) >> 6] |= (1ull << ((c) & 0x3f))
#define RESET_CHARTAB(buf, c) \
- (buf)->b_chartab[(unsigned)(c) >> 3] &= ~(1 << ((c) & 0x7))
+ (buf)->b_chartab[(unsigned)(c) >> 6] &= ~(1ull << ((c) & 0x3f))
#define GET_CHARTAB(buf, c) \
- ((buf)->b_chartab[(unsigned)(c) >> 3] & (1 << ((c) & 0x7)))
+ ((buf)->b_chartab[(unsigned)(c) >> 6] & (1ull << ((c) & 0x3f)))
/// Fill chartab[]. Also fills curbuf->b_chartab[] with flags for keyword
/// characters for current buffer.
@@ -69,12 +69,12 @@ static int chartab_initialized = FALSE;
/// an error, OK otherwise.
int init_chartab(void)
{
- return buf_init_chartab(curbuf, TRUE);
+ return buf_init_chartab(curbuf, true);
}
/// Helper for init_chartab
///
-/// @param global FALSE: only set buf->b_chartab[]
+/// @param global false: only set buf->b_chartab[]
///
/// @return FAIL if 'iskeyword', 'isident', 'isfname' or 'isprint' option has
/// an error, OK otherwise.
@@ -84,13 +84,13 @@ int buf_init_chartab(buf_T *buf, int global)
int c2;
char_u *p;
int i;
- int tilde;
- int do_isalpha;
+ bool tilde;
+ bool do_isalpha;
if (global) {
// Set the default size for printable characters:
// From <Space> to '~' is 1 (printable), others are 2 (not printable).
- // This also inits all 'isident' and 'isfname' flags to FALSE.
+ // This also inits all 'isident' and 'isfname' flags to false.
c = 0;
while (c < ' ') {
@@ -133,7 +133,7 @@ int buf_init_chartab(buf_T *buf, int global)
}
}
- // Init word char flags all to FALSE
+ // Init word char flags all to false
memset(buf->b_chartab, 0, (size_t)32);
if (enc_dbcs != 0) {
@@ -169,11 +169,11 @@ int buf_init_chartab(buf_T *buf, int global)
}
while (*p) {
- tilde = FALSE;
- do_isalpha = FALSE;
+ tilde = false;
+ do_isalpha = false;
if ((*p == '^') && (p[1] != NUL)) {
- tilde = TRUE;
+ tilde = true;
++p;
}
@@ -212,7 +212,7 @@ int buf_init_chartab(buf_T *buf, int global)
// standard function isalpha(). This takes care of locale for
// single-byte characters).
if (c == '@') {
- do_isalpha = TRUE;
+ do_isalpha = true;
c = 1;
c2 = 255;
} else {
@@ -231,7 +231,7 @@ int buf_init_chartab(buf_T *buf, int global)
if (i == 0) {
// (re)set ID flag
if (tilde) {
- chartab[c] &= ~CT_ID_CHAR;
+ chartab[c] &= (uint8_t)~CT_ID_CHAR;
} else {
chartab[c] |= CT_ID_CHAR;
}
@@ -244,18 +244,18 @@ int buf_init_chartab(buf_T *buf, int global)
|| (p_altkeymap && (F_isalpha(c) || F_isdigit(c))))
&& !(enc_dbcs && (MB_BYTE2LEN(c) == 2))) {
if (tilde) {
- chartab[c] = (chartab[c] & ~CT_CELL_MASK)
- + ((dy_flags & DY_UHEX) ? 4 : 2);
- chartab[c] &= ~CT_PRINT_CHAR;
+ chartab[c] = (uint8_t)((chartab[c] & ~CT_CELL_MASK)
+ + ((dy_flags & DY_UHEX) ? 4 : 2));
+ chartab[c] &= (uint8_t)~CT_PRINT_CHAR;
} else {
- chartab[c] = (chartab[c] & ~CT_CELL_MASK) + 1;
+ chartab[c] = (uint8_t)((chartab[c] & ~CT_CELL_MASK) + 1);
chartab[c] |= CT_PRINT_CHAR;
}
}
} else if (i == 2) {
// (re)set fname flag
if (tilde) {
- chartab[c] &= ~CT_FNAME_CHAR;
+ chartab[c] &= (uint8_t)~CT_FNAME_CHAR;
} else {
chartab[c] |= CT_FNAME_CHAR;
}
@@ -280,7 +280,7 @@ int buf_init_chartab(buf_T *buf, int global)
}
}
}
- chartab_initialized = TRUE;
+ chartab_initialized = true;
return OK;
}
@@ -333,7 +333,8 @@ char_u *transstr(char_u *s) FUNC_ATTR_NONNULL_RET
{
char_u *res;
char_u *p;
- int l, c;
+ int c;
+ size_t l;
char_u hexbuf[11];
if (has_mbyte) {
@@ -343,7 +344,7 @@ char_u *transstr(char_u *s) FUNC_ATTR_NONNULL_RET
p = s;
while (*p != NUL) {
- if ((l = (*mb_ptr2len)(p)) > 1) {
+ if ((l = (size_t)(*mb_ptr2len)(p)) > 1) {
c = (*mb_ptr2char)(p);
p += l;
@@ -354,7 +355,7 @@ char_u *transstr(char_u *s) FUNC_ATTR_NONNULL_RET
len += STRLEN(hexbuf);
}
} else {
- l = byte2cells(*p++);
+ l = (size_t)byte2cells(*p++);
if (l > 0) {
len += l;
@@ -366,14 +367,14 @@ char_u *transstr(char_u *s) FUNC_ATTR_NONNULL_RET
}
res = xmallocz(len);
} else {
- res = xmallocz(vim_strsize(s));
+ res = xmallocz((size_t)vim_strsize(s));
}
*res = NUL;
p = s;
while (*p != NUL) {
- if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) {
+ if (has_mbyte && ((l = (size_t)(*mb_ptr2len)(p)) > 1)) {
c = (*mb_ptr2char)(p);
if (vim_isprintc(c)) {
@@ -477,9 +478,9 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
i += (*mb_ptr2len)(STR_PTR(i));
} else {
if (buf == NULL) {
- GA_CHAR(i) = TOLOWER_LOC(GA_CHAR(i));
+ GA_CHAR(i) = (char_u)TOLOWER_LOC(GA_CHAR(i));
} else {
- buf[i] = TOLOWER_LOC(buf[i]);
+ buf[i] = (char_u)TOLOWER_LOC(buf[i]);
}
++i;
}
@@ -493,7 +494,7 @@ char_u* str_foldcase(char_u *str, int orglen, char_u *buf, int buflen)
// Catch 22: chartab[] can't be initialized before the options are
// initialized, and initializing options may cause transchar() to be called!
-// When chartab_initialized == FALSE don't use chartab[].
+// When chartab_initialized == false don't use chartab[].
// Does NOT work for multi-byte characters, c must be <= 255.
// Also doesn't work for the first byte of a multi-byte, "c" must be a
// character!
@@ -518,7 +519,7 @@ char_u* transchar(int c)
if ((!chartab_initialized && (((c >= ' ') && (c <= '~')) || F_ischar(c)))
|| ((c < 256) && vim_isprintc_strict(c))) {
// printable character
- transchar_buf[i] = c;
+ transchar_buf[i] = (char_u)c;
transchar_buf[i + 1] = NUL;
} else {
transchar_nonprint(transchar_buf + i, c);
@@ -564,7 +565,7 @@ void transchar_nonprint(char_u *buf, int c)
// 0x00 - 0x1f and 0x7f
buf[0] = '^';
// DEL displayed as ^?
- buf[1] = c ^ 0x40;
+ buf[1] = (char_u)(c ^ 0x40);
buf[2] = NUL;
} else if (enc_utf8 && (c >= 0x80)) {
@@ -572,12 +573,12 @@ void transchar_nonprint(char_u *buf, int c)
} else if ((c >= ' ' + 0x80) && (c <= '~' + 0x80)) {
// 0xa0 - 0xfe
buf[0] = '|';
- buf[1] = c - 0x80;
+ buf[1] = (char_u)(c - 0x80);
buf[2] = NUL;
} else {
// 0x80 - 0x9f and 0xff
buf[0] = '~';
- buf[1] = (c - 0x80) ^ 0x40;
+ buf[1] = (char_u)((c - 0x80) ^ 0x40);
buf[2] = NUL;
}
}
@@ -592,11 +593,11 @@ void transchar_hex(char_u *buf, int c)
buf[0] = '<';
if (c > 255) {
- buf[++i] = nr2hex((unsigned)c >> 12);
- buf[++i] = nr2hex((unsigned)c >> 8);
+ buf[++i] = (char_u)nr2hex((unsigned)c >> 12);
+ buf[++i] = (char_u)nr2hex((unsigned)c >> 8);
}
- buf[++i] = nr2hex((unsigned)c >> 4);
- buf[++i] = nr2hex((unsigned)c);
+ buf[++i] = (char_u)(nr2hex((unsigned)c >> 4));
+ buf[++i] = (char_u)(nr2hex((unsigned)c));
buf[++i] = '>';
buf[++i] = NUL;
}
@@ -734,9 +735,8 @@ int vim_strnsize(char_u *s, int len)
/// @return Number of characters.
#define RET_WIN_BUF_CHARTABSIZE(wp, buf, p, col) \
if (*(p) == TAB && (!(wp)->w_p_list || lcs_tab1)) { \
- int ts; \
- ts = (buf)->b_p_ts; \
- return (int)(ts - (col % ts)); \
+ const int ts = (int) (buf)->b_p_ts; \
+ return (ts - (int)(col % ts)); \
} else { \
return ptr2cells(p); \
}
@@ -1137,7 +1137,7 @@ static int win_nolbr_chartabsize(win_T *wp, char_u *s, colnr_T col, int *headp)
int n;
if ((*s == TAB) && (!wp->w_p_list || lcs_tab1)) {
- n = wp->w_buffer->b_p_ts;
+ n = (int)wp->w_buffer->b_p_ts;
return n - (col % n);
}
n = ptr2cells(s);
@@ -1205,11 +1205,11 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor,
char_u *line; // start of the line
int incr;
int head;
- int ts = wp->w_buffer->b_p_ts;
+ int ts = (int)wp->w_buffer->b_p_ts;
int c;
vcol = 0;
- line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
+ line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, false);
if (pos->col == MAXCOL) {
// continue until the NUL
@@ -1329,7 +1329,7 @@ colnr_T getvcol_nolist(pos_T *posp)
int list_save = curwin->w_p_list;
colnr_T vcol;
- curwin->w_p_list = FALSE;
+ curwin->w_p_list = false;
getvcol(curwin, posp, NULL, &vcol, NULL);
curwin->w_p_list = list_save;
return vcol;
@@ -1358,7 +1358,7 @@ void getvvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor,
endadd = 0;
// Cannot put the cursor on part of a wide character.
- ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
+ ptr = ml_get_buf(wp->w_buffer, pos->lnum, false);
if (pos->col < (colnr_T)STRLEN(ptr)) {
int c = (*mb_ptr2char)(ptr + pos->col);
@@ -1595,7 +1595,7 @@ bool vim_islower(int c)
if (c >= 0x100) {
if (has_mbyte) {
- return iswlower(c);
+ return iswlower((wint_t)c);
}
// islower() can't handle these chars and may crash
@@ -1626,7 +1626,7 @@ bool vim_isupper(int c)
if (c >= 0x100) {
if (has_mbyte) {
- return iswupper(c);
+ return iswupper((wint_t)c);
}
// isupper() can't handle these chars and may crash
@@ -1653,7 +1653,7 @@ int vim_toupper(int c)
if (c >= 0x100) {
if (has_mbyte) {
- return towupper(c);
+ return (int)towupper((wint_t)c);
}
// toupper() can't handle these chars and may crash
@@ -1680,7 +1680,7 @@ int vim_tolower(int c)
if (c >= 0x100) {
if (has_mbyte) {
- return towlower(c);
+ return (int)towlower((wint_t)c);
}
// tolower() can't handle these chars and may crash
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 1c33c4d549..614a5d43be 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -2358,13 +2358,13 @@ void set_completion(colnr_T startcol, list_T *list)
int save_w_wrow = curwin->w_wrow;
compl_curr_match = compl_first_match;
- if (compl_no_insert) {
+ if (compl_no_insert || compl_no_select) {
ins_complete(K_DOWN, false);
- } else {
- ins_complete(Ctrl_N, false);
if (compl_no_select) {
- ins_complete(Ctrl_P, false);
+ ins_complete(K_UP, false);
}
+ } else {
+ ins_complete(Ctrl_N, false);
}
// Lazily show the popup menu, unless we got interrupted.
@@ -4239,9 +4239,10 @@ void ins_compl_check_keys(int frequency)
static int ins_compl_key2dir(int c)
{
if (c == Ctrl_P || c == Ctrl_L
- || (pum_visible() && (c == K_PAGEUP || c == K_KPAGEUP
- || c == K_S_UP || c == K_UP)))
+ || c == K_PAGEUP || c == K_KPAGEUP
+ || c == K_S_UP || c == K_UP) {
return BACKWARD;
+ }
return FORWARD;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3c67625d1c..5477e79cad 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -174,6 +174,7 @@ static char *e_illvar = N_("E461: Illegal variable name: %s");
static char *e_float_as_string = N_("E806: using Float as a String");
static char_u * const empty_string = (char_u *)"";
+static char_u * const namespace_char = (char_u *)"abglstvw";
static dictitem_T globvars_var; /* variable used for g: */
#define globvarht globvardict.dv_hashtab
@@ -17873,21 +17874,28 @@ static int get_env_len(char_u **arg)
return len;
}
-/*
- * Get the length of the name of a function or internal variable.
- * "arg" is advanced to the first non-white character after the name.
- * Return 0 if something is wrong.
- */
-static int get_id_len(char_u **arg)
-{
- char_u *p;
+// Get the length of the name of a function or internal variable.
+// "arg" is advanced to the first non-white character after the name.
+// Return 0 if something is wrong.
+static int get_id_len(char_u **arg) {
+ char_u *p;
int len;
- /* Find the end of the name. */
- for (p = *arg; eval_isnamec(*p); ++p)
- ;
- if (p == *arg) /* no name found */
+ // Find the end of the name.
+ for (p = *arg; eval_isnamec(*p); p++) {
+ if (*p == ':') {
+ // "s:" is start of "s:var", but "n:" is not and can be used in
+ // slice "[n:]". Also "xx:" is not a namespace.
+ len = (int)(p - *arg);
+ if (len > 1
+ || (len == 1 && vim_strchr(namespace_char, **arg) == NULL)) {
+ break;
+ }
+ }
+ }
+ if (p == *arg) { // no name found
return 0;
+ }
len = (int)(p - *arg);
*arg = skipwhite(p);
@@ -17958,28 +17966,29 @@ static int get_name_len(char_u **arg, char_u **alias, int evaluate, int verbose)
return len;
}
-/*
- * Find the end of a variable or function name, taking care of magic braces.
- * If "expr_start" is not NULL then "expr_start" and "expr_end" are set to the
- * start and end of the first magic braces item.
- * "flags" can have FNE_INCL_BR and FNE_CHECK_START.
- * Return a pointer to just after the name. Equal to "arg" if there is no
- * valid name.
- */
-static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end, int flags)
+// Find the end of a variable or function name, taking care of magic braces.
+// If "expr_start" is not NULL then "expr_start" and "expr_end" are set to the
+// start and end of the first magic braces item.
+// "flags" can have FNE_INCL_BR and FNE_CHECK_START.
+// Return a pointer to just after the name. Equal to "arg" if there is no
+// valid name.
+static char_u *find_name_end(char_u *arg, char_u **expr_start,
+ char_u **expr_end, int flags)
{
int mb_nest = 0;
int br_nest = 0;
- char_u *p;
+ char_u *p;
+ int len;
if (expr_start != NULL) {
*expr_start = NULL;
*expr_end = NULL;
}
- /* Quick check for valid starting character. */
- if ((flags & FNE_CHECK_START) && !eval_isnamec1(*arg) && *arg != '{')
+ // Quick check for valid starting character.
+ if ((flags & FNE_CHECK_START) && !eval_isnamec1(*arg) && *arg != '{') {
return arg;
+ }
for (p = arg; *p != NUL
&& (eval_isnamec(*p)
@@ -17994,30 +18003,44 @@ static char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end
if (*p == NUL)
break;
} else if (*p == '"') {
- /* skip over "str\"ing" to avoid counting [ and ] inside it. */
- for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p))
- if (*p == '\\' && p[1] != NUL)
+ // skip over "str\"ing" to avoid counting [ and ] inside it.
+ for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) {
+ if (*p == '\\' && p[1] != NUL) {
++p;
- if (*p == NUL)
+ }
+ }
+ if (*p == NUL) {
+ break;
+ }
+ } else if (br_nest == 0 && mb_nest == 0 && *p == ':') {
+ // "s:" is start of "s:var", but "n:" is not and can be used in
+ // slice "[n:]". Also "xx:" is not a namespace.
+ len = (int)(p - arg);
+ if (len > 1
+ || (len == 1 && vim_strchr(namespace_char, *arg) == NULL)) {
break;
+ }
}
if (mb_nest == 0) {
- if (*p == '[')
+ if (*p == '[') {
++br_nest;
- else if (*p == ']')
+ } else if (*p == ']') {
--br_nest;
+ }
}
if (br_nest == 0) {
if (*p == '{') {
mb_nest++;
- if (expr_start != NULL && *expr_start == NULL)
+ if (expr_start != NULL && *expr_start == NULL) {
*expr_start = p;
+ }
} else if (*p == '}') {
mb_nest--;
- if (expr_start != NULL && mb_nest == 0 && *expr_end == NULL)
+ if (expr_start != NULL && mb_nest == 0 && *expr_end == NULL) {
*expr_end = p;
+ }
}
}
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 618245ea23..40b5718071 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -922,8 +922,8 @@ EXTERN int KeyTyped; // TRUE if user typed current char
EXTERN int KeyStuffed; // TRUE if current char from stuffbuf
EXTERN int maptick INIT(= 0); // tick for each non-mapped char
-EXTERN char_u chartab[256]; /* table used in charset.c; See
- init_chartab() for explanation */
+EXTERN uint8_t chartab[256]; // table used in charset.c; See
+ // init_chartab() for explanation
EXTERN int must_redraw INIT(= 0); /* type of redraw necessary */
EXTERN int skip_redraw INIT(= FALSE); /* skip redraw once */
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 7169a1d963..a143490356 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -2081,12 +2081,13 @@ static int cs_show(exarg_T *eap)
if (csinfo[i].fname == NULL)
continue;
- if (csinfo[i].ppath != NULL)
- (void)smsg("%2zu %-5" PRId64 " %-34s %-32s",
- i, (long)csinfo[i].pid, csinfo[i].fname, csinfo[i].ppath);
- else
- (void)smsg("%2zu %-5" PRId64 " %-34s <none>",
- i, (long)csinfo[i].pid, csinfo[i].fname);
+ if (csinfo[i].ppath != NULL) {
+ (void)smsg("%2zu %-5" PRId64 " %-34s %-32s", i,
+ (int64_t)csinfo[i].pid, csinfo[i].fname, csinfo[i].ppath);
+ } else {
+ (void)smsg("%2zu %-5" PRId64 " %-34s <none>", i,
+ (int64_t)csinfo[i].pid, csinfo[i].fname);
+ }
}
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index cc7dc6210c..fdae89b84c 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -2332,14 +2332,17 @@ static void spell_load_lang(char_u *lang)
if (r == FAIL) {
if (starting) {
- // Some startup file sets &spell, but the necessary files don't exist:
- // try to prompt the user at VimEnter. Also set spell again. #3027
- do_cmdline_cmd(
- "autocmd VimEnter * call spellfile#LoadFile(&spelllang)|set spell");
+ // Prompt the user at VimEnter if spell files are missing. #3027
+ // Plugins aren't loaded yet, so spellfile.vim cannot handle this case.
+ char autocmd_buf[128] = { 0 };
+ snprintf(autocmd_buf, sizeof(autocmd_buf),
+ "autocmd VimEnter * call spellfile#LoadFile('%s')|set spell",
+ lang);
+ do_cmdline_cmd(autocmd_buf);
} else {
smsg(
_("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""),
- lang, spell_enc(), lang);
+ lang, spell_enc(), lang);
}
} else if (sl.sl_slang != NULL) {
// At least one file was loaded, now load ALL the additions.
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 275cb2063a..ebf21d162f 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -193,7 +193,7 @@ static int included_patches[] = {
// 1108,
// 1107,
// 1106 NA
- // 1105,
+ 1105,
// 1104 NA
// 1103 NA
// 1102,
diff --git a/test/functional/legacy/eval_spec.lua b/test/functional/legacy/eval_spec.lua
index e0a4e10746..d1ed96cc2e 100644
--- a/test/functional/legacy/eval_spec.lua
+++ b/test/functional/legacy/eval_spec.lua
@@ -693,4 +693,22 @@ describe('eval', function()
start:
6]])
end)
+
+ it('substring and variable name', function()
+ execute("let str = 'abcdef'")
+ execute('let n = 3')
+ eq('def', eval('str[n:]'))
+ eq('abcd', eval('str[:n]'))
+ eq('d', eval('str[n:n]'))
+ execute('unlet n')
+ execute('let nn = 3')
+ eq('def', eval('str[nn:]'))
+ eq('abcd', eval('str[:nn]'))
+ eq('d', eval('str[nn:nn]'))
+ execute('unlet nn')
+ execute('let b:nn = 4')
+ eq('ef', eval('str[b:nn:]'))
+ eq('abcde', eval('str[:b:nn]'))
+ eq('e', eval('str[b:nn:b:nn]'))
+ end)
end)
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index 20eee24524..01b2bad059 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -100,6 +100,18 @@ describe('completion', function()
feed('o<C-r>=TestComplete()<CR><ESC>')
eq('', eval('getline(3)'))
end)
+ it('does not change modified state if noinsert', function()
+ execute('set completeopt+=menuone,noinsert')
+ execute('setlocal nomodified')
+ feed('i<C-r>=TestComplete()<CR><ESC>')
+ eq(0, eval('&l:modified'))
+ end)
+ it('does not change modified state if noselect', function()
+ execute('set completeopt+=menuone,noselect')
+ execute('setlocal nomodified')
+ feed('i<C-r>=TestComplete()<CR><ESC>')
+ eq(0, eval('&l:modified'))
+ end)
end)
describe("refresh:always", function()
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index a2e7bd91af..b7f82064d7 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -41,13 +41,13 @@ describe('buffer functions', function()
describe('buf_valid', function()
it('should view NULL as an invalid buffer', function()
- eq(0, buffer.buf_valid(NULL))
+ eq(false, buffer.buf_valid(NULL))
end)
it('should view an open buffer as valid', function()
local buf = buflist_new(path1, buffer.BLN_LISTED)
- eq(1, buffer.buf_valid(buf))
+ eq(true, buffer.buf_valid(buf))
end)
it('should view a closed and hidden buffer as valid', function()
@@ -55,7 +55,7 @@ describe('buffer functions', function()
close_buffer(NULL, buf, 0, 0)
- eq(1, buffer.buf_valid(buf))
+ eq(true, buffer.buf_valid(buf))
end)
it('should view a closed and unloaded buffer as valid', function()
@@ -63,7 +63,7 @@ describe('buffer functions', function()
close_buffer(NULL, buf, buffer.DOBUF_UNLOAD, 0)
- eq(1, buffer.buf_valid(buf))
+ eq(true, buffer.buf_valid(buf))
end)
it('should view a closed and wiped buffer as invalid', function()
@@ -71,7 +71,7 @@ describe('buffer functions', function()
close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0)
- eq(0, buffer.buf_valid(buf))
+ eq(false, buffer.buf_valid(buf))
end)
end)