diff options
50 files changed, 981 insertions, 690 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 336adc65e5..cbfd7c76a1 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -26,6 +26,7 @@ function! health#check(plugin_names) abort \ : s:to_fn_names(a:plugin_names) tabnew + setlocal wrap breakindent setlocal filetype=markdown bufhidden=wipe call s:enhance_syntax() @@ -35,7 +36,7 @@ function! health#check(plugin_names) abort redraw|echo 'Running healthchecks...' for c in healthchecks let output = '' - call append('$', split(printf("\n%s\n%s", c, repeat('=',80)), "\n")) + call append('$', split(printf("\n%s\n%s", c, repeat('=',72)), "\n")) try let output = "\n\n".execute('call '.c.'()') catch diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index 60e56034e1..8c4034eab6 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -1,5 +1,7 @@ +let s:suggest_faq = 'See https://github.com/neovim/neovim/wiki/FAQ' + " Load the remote plugin manifest file and check for unregistered plugins -function! s:check_manifest() abort +function! s:check_rplugin_manifest() abort call health#report_start('Remote Plugins') let existing_rplugins = {} @@ -57,17 +59,36 @@ function! s:check_manifest() abort endif endfunction +function! s:check_performance() abort + call health#report_start('Performance') + + " check buildtype + let buildtype = matchstr(execute('version'), '\v\cbuild type:?\s*[^\n\r\t ]+') + if empty(buildtype) + call health#report_error('failed to get build type from :version') + elseif buildtype =~# '\v(MinSizeRel|Release|RelWithDebInfo)' + call health#report_ok(buildtype) + else + call health#report_info(buildtype) + call health#report_warn( + \ "Non-optimized build-type. Nvim will be slower.", + \ ["Install a different Nvim package, or rebuild with `CMAKE_BUILD_TYPE=RelWithDebInfo`.", + \ s:suggest_faq]) + endif +endfunction + function! s:check_tmux() abort if empty($TMUX) || !executable('tmux') return endif - call health#report_start('tmux configuration') - let suggestions = ["Set escape-time in ~/.tmux.conf: set-option -sg escape-time 10", - \ 'See https://github.com/neovim/neovim/wiki/FAQ'] + call health#report_start('tmux') + + " check escape-time + let suggestions = ["Set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10", + \ s:suggest_faq] let cmd = 'tmux show-option -qvgs escape-time' let out = system(cmd) let tmux_esc_time = substitute(out, '\v(\s|\r|\n)', '', 'g') - if v:shell_error call health#report_error('command failed: '.cmd."\n".out) elseif empty(tmux_esc_time) @@ -76,7 +97,16 @@ function! s:check_tmux() abort call health#report_error( \ 'escape-time ('.tmux_esc_time.') is higher than 300ms', suggestions) else - call health#report_ok('escape-time = '.tmux_esc_time.'ms') + call health#report_ok('escape-time: '.tmux_esc_time.'ms') + endif + + " check $TERM + call health#report_info('$TERM: '.$TERM) + if $TERM !~# '\v(tmux-256color|screen-256color)' + call health#report_error( + \ '$TERM should be "screen-256color" or "tmux-256color" when running tmux.', + \ ["Set default-terminal in ~/.tmux.conf:\nset-option -g default-terminal \"screen-256color\"", + \ s:suggest_faq]) endif endfunction @@ -90,7 +120,7 @@ function! s:check_terminfo() abort \ .'infocmp $TERM | sed ''s/kbs=^[hH]/kbs=\\177/'' > $TERM.ti' \ ."\n" \ .'tic $TERM.ti', - \ 'See https://github.com/neovim/neovim/wiki/FAQ'] + \ s:suggest_faq] let cmd = 'infocmp -L' let out = system(cmd) let kbs_entry = matchstr(out, 'key_backspace=\S*') @@ -107,7 +137,8 @@ function! s:check_terminfo() abort endfunction function! health#nvim#check() abort - call s:check_manifest() + call s:check_rplugin_manifest() + call s:check_performance() call s:check_tmux() call s:check_terminfo() endfunction diff --git a/runtime/compiler/tidy.vim b/runtime/compiler/tidy.vim index 56baee2224..75be8b83d9 100644 --- a/runtime/compiler/tidy.vim +++ b/runtime/compiler/tidy.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: HTML Tidy " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2013 Jul 7 +" Last Change: 2016 Apr 21 if exists("current_compiler") finish @@ -12,8 +12,8 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal <args> endif -CompilerSet makeprg=tidy\ -quiet\ -errors\ --gnu-emacs\ yes\ % +CompilerSet makeprg=tidy\ -quiet\ -errors\ --gnu-emacs\ yes\ %:S -" sample warning: foo.html:8:1: Warning: inserting missing 'foobar' element -" sample error: foo.html:9:2: Error: <foobar> is not recognized! -CompilerSet errorformat=%f:%l:%c:\ Error:%m,%f:%l:%c:\ Warning:%m,%-G%.%# +" foo.html:8:1: Warning: inserting missing 'foobar' element +" foo.html:9:2: Error: <foobar> is not recognized! +CompilerSet errorformat=%f:%l:%c:\ %trror:%m,%f:%l:%c:\ %tarning:%m,%-G%.%# diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3c9b4dafcd..3ce0d1cd87 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 27 +*eval.txt* For Vim version 7.4. Last change: 2016 May 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -43,6 +43,7 @@ Number A 32 or 64 bit signed number. |expr-number| *Number* Float A floating point number. |floating-point-format| *Float* Examples: 123.456 1.15e-6 -1.1e3 + *E928* String A NUL terminated string of 8-bit unsigned characters (bytes). |expr-string| Examples: "ab\txx\"--" 'x-z''a,c' @@ -6171,6 +6172,7 @@ setqflist({list} [, {action}[, {title}]]) *setqflist()* Note that the list is not exactly the same as what |getqflist()| returns. + *E927* If {action} is set to 'a', then the items from {list} are added to the existing quickfix list. If there is no existing list, then a new list is created. If {action} is set to 'r', @@ -7048,8 +7050,9 @@ timer_start({time}, {callback} [, {options}]) {only available when compiled with the |+timers| feature} timer_stop({timer}) *timer_stop()* - Stop a timer. {timer} is an ID returned by timer_start(). - The timer callback will no longer be invoked. + Stop a timer. The timer callback will no longer be invoked. + {timer} is an ID returned by timer_start(), thus it must be a + Number. tolower({expr}) *tolower()* The result is a copy of the String given, with all uppercase @@ -7450,7 +7453,11 @@ There are four types of features: Example: > :if has("gui_running") < *has-patch* -3. Included patches. The "patch123" feature means that patch 123 has been +3. {Nvim} version. The "nvim-1.2.3" feature means that the Nvim version is + 1.2.3 or later. Example: > + :if has("nvim-1.2.3") +< +4. Included patches. The "patch123" feature means that patch 123 has been included. Note that this form does not check the version of Vim, you need to inspect |v:version| for that. Example (checking version 6.2.148 or later): > @@ -7458,7 +7465,7 @@ There are four types of features: < Note that it's possible for patch 147 to be omitted even though 148 is included. -4. Beyond a certain version or at a certain version and including a specific +5. Beyond a certain version or at a certain version and including a specific patch. The "patch-7.4.237" feature means that the Vim version is 7.5 or later, or it is version 7.4 and patch 237 was included. Note that this only works for patch 7.4.237 and later, before that you @@ -7530,6 +7537,7 @@ multi_byte Compiled with support for 'encoding' multi_byte_encoding 'encoding' is set to a multi-byte encoding. multi_byte_ime Compiled with support for IME input method. multi_lang Compiled with support for multiple languages. +nvim This is Nvim. |has-patch| ole Compiled with OLE automation support for Win32. path_extra Compiled with up/downwards search in 'path' and 'tags' persistent_undo Compiled with support for persistent undo history. diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 7ceddeb674..d3eeecaf7c 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -1,4 +1,4 @@ -*message.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*message.txt* For Vim version 7.4. Last change: 2016 Jul 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -656,6 +656,12 @@ You must be using an awful lot of buffers. It's now possible that two buffers have the same number, which causes various problems. You might want to exit Vim and restart it. + *E931* > + Buffer cannot be registered + +Out of memory or a duplicate buffer number. May habben after W14. Looking up +a buffer will not always work, better restart Vim. + *E296* *E297* > Seek error in swap file write Write error in swap file diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index 7f84f2d2a3..4d6f0719e3 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -1,4 +1,4 @@ -*motion.txt* For Vim version 7.4. Last change: 2015 Jun 06 +*motion.txt* For Vim version 7.4. Last change: 2016 Jul 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -569,7 +569,7 @@ i[ "inner [] block", select [count] '[' ']' blocks. This When used in Visual mode it is made characterwise. a) *v_a)* *a)* *a(* -a( *v_ab* *v_a(* *ab* +a( *vab* *v_ab* *v_a(* *ab* ab "a block", select [count] blocks, from "[count] [(" to the matching ')', including the '(' and ')' (see |[(|). Does not include white space outside of the @@ -577,7 +577,7 @@ ab "a block", select [count] blocks, from "[count] [(" to When used in Visual mode it is made characterwise. i) *v_i)* *i)* *i(* -i( *v_ib* *v_i(* *ib* +i( *vib* *v_ib* *v_i(* *ib* ib "inner block", select [count] blocks, from "[count] [(" to the matching ')', excluding the '(' and ')' (see |[(|). diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index e8ddc56f7a..5a5999e64c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Mar 19 +*options.txt* For Vim version 7.4. Last change: 2016 Jul 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -497,6 +497,7 @@ For example, to use a modeline only for Vim 7.0: To use a modeline for Vim after version 7.2: /* vim>702: set cole=2: */ ~ There can be no blanks between "vim" and the ":". +The modeline is ignored if {vers} does not fit in an integer. {Nvim} The number of lines that are checked can be set with the 'modelines' option. @@ -2110,11 +2111,17 @@ A jump table for the options with a short description can be found at |Q_op|. Change the way text is displayed. This is comma separated list of flags: lastline When included, as much as possible of the last line - in a window will be displayed. When not included, a - last line that doesn't fit is replaced with "@" lines. + in a window will be displayed. "@@@" is put in the + last columns of the last screen line to indicate the + rest of the line is not displayed. + truncate Like "lastline", but "@@@" is displayed in the first + column of the last screen line. Overrules "lastline". uhex Show unprintable characters hexadecimal as <xx> instead of using ^C and ~C. + When neither "lastline" or "truncate" is included, a last line that + doesn't fit is replaced with "@" lines. + *'eadirection'* *'ead'* 'eadirection' 'ead' string (default "both") global @@ -4943,6 +4950,7 @@ A jump table for the options with a short description can be found at |Q_op|. keymap/ key mapping files |mbyte-keymap| lang/ menu translations |:menutrans| menu.vim GUI menus |menu.vim| + pack/ packages |:packadd| plugin/ plugin scripts |write-plugin| print/ files for printing |postscript-print-encoding| spell/ spell checking files |spell| @@ -4969,6 +4977,8 @@ A jump table for the options with a short description can be found at |Q_op|. ordering. This is for preferences to overrule or add to the distributed defaults or system-wide settings (rarely needed). + More entries are added when using |packages|. + Note that, unlike 'path', no wildcards like "**" are allowed. Normal wildcards are allowed, but can significantly slow down searching for runtime files. For speed, use as few items as possible and avoid @@ -5445,6 +5455,8 @@ A jump table for the options with a short description can be found at |Q_op|. The |FilterReadPre|, |FilterReadPost| and |FilterWritePre|, |FilterWritePost| autocommands event are not triggered when 'shelltemp' is off. + The `system()` function does not respect this option and always uses + temp files. *'shellxescape'* *'sxe'* 'shellxescape' 'sxe' string (default: ""; diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 0fe6106ec5..8e50a67847 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1,4 +1,4 @@ -*pattern.txt* For Vim version 7.4. Last change: 2016 Apr 03 +*pattern.txt* For Vim version 7.4. Last change: 2016 Apr 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1071,8 +1071,8 @@ x A single character, with no special meaning, matches itself belonging to that character class. The following character classes are supported: Name Contents ~ -*[:alnum:]* [:alnum:] letters and digits -*[:alpha:]* [:alpha:] letters +*[:alnum:]* [:alnum:] ASCII letters and digits +*[:alpha:]* [:alpha:] ASCII letters *[:blank:]* [:blank:] space and tab characters *[:cntrl:]* [:cntrl:] control characters *[:digit:]* [:digit:] decimal digits @@ -1080,7 +1080,7 @@ x A single character, with no special meaning, matches itself *[:lower:]* [:lower:] lowercase letters (all letters when 'ignorecase' is used) *[:print:]* [:print:] printable characters including space -*[:punct:]* [:punct:] punctuation characters +*[:punct:]* [:punct:] ASCII punctuation characters *[:space:]* [:space:] whitespace characters *[:upper:]* [:upper:] uppercase letters (all letters when 'ignorecase' is used) @@ -1097,7 +1097,8 @@ x A single character, with no special meaning, matches itself These items only work for 8-bit characters, except [:lower:] and [:upper:] also work for multi-byte characters when using the new regexp engine. See |two-engines|. In the future these items may - work for multi-byte characters. + work for multi-byte characters. For now, to get all "alpha" + characters you can use: [[:lower:][:upper:]]. */[[=* *[==]* - An equivalence class. This means that characters are matched that have almost the same meaning, e.g., when ignoring accents. This diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index e84bbe5439..b44761cdb5 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -223,6 +223,8 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. pack/*/opt/{name} ~ The directory is added to 'runtimepath' if it wasn't there yet. + If the directory pack/*/opt/{name}/after exists it is + added at the end of 'runtimepath'. Note that {name} is the directory name, not the name of the .vim file. All the files matching the pattern @@ -492,6 +494,9 @@ To load packages earlier, so that 'runtimepath' gets updated: > This also works when loading plugins is disabled. The automatic loading will only happen once. +If the package has an "after" directory, that directory is added to the end of +'runtimepath', so that anything there will be loaded later. + Using a single plugin and loading it automatically ~ diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index dccbe2562e..bbc0260ffa 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -198,7 +198,8 @@ argument. -Z Restricted mode. All commands that make use of an external shell are disabled. This includes suspending with CTRL-Z, ":sh", filtering, the system() function, backtick expansion, - delete(), rename(), mkdir(), writefile(), libcall(), etc. + delete(), rename(), mkdir(), writefile(), libcall(), + jobstart(), etc. *-e* -e Start Vim in Ex mode |Q|. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index bb1f993ab6..b4df069f21 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -105,6 +105,10 @@ Some `CTRL-SHIFT-...` key chords are distinguished from `CTRL-...` variants Options: 'statusline' supports unlimited alignment sections + 'tabline' %@Func@foo%X can call any function on mouse-click + +Variables: + |v:windowid| is always available (for use by external UIs) Commands: |:CheckHealth| @@ -112,7 +116,10 @@ Commands: |:Man| is available by default, with many improvements such as completion Functions: + |dictwatcheradd()| notifies a callback whenever a |Dict| is modified + |dictwatcherdel()| |execute()| works with |:redir| + |msgpackdump()|, |msgpackparse()| provide msgpack de/serialization Events: |TabNew| diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c5a3577a62..bfb45a3720 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2015 Oct 13 +" Last Change: 2016 Jul 12 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -1617,11 +1617,9 @@ au BufNewFile,BufRead */etc/protocols setf protocols " Pyrex au BufNewFile,BufRead *.pyx,*.pxd setf pyrex -" Python -au BufNewFile,BufRead *.py,*.pyw setf python - +" Python, Python Shell Startup Files " Quixote (Python-based web framework) -au BufNewFile,BufRead *.ptl setf python +au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc,*.ptl setf python " Radiance au BufNewFile,BufRead *.rad,*.mat setf radiance diff --git a/runtime/ftplugin/groovy.vim b/runtime/ftplugin/groovy.vim new file mode 100644 index 0000000000..cc7d6e35eb --- /dev/null +++ b/runtime/ftplugin/groovy.vim @@ -0,0 +1,19 @@ +" Vim filetype plugin file +" Language: groovy +" Maintainer: Justin M. Keyes <justinkz@gmail.com> +" Last Change: 2016 May 22 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo-=C + +let b:undo_ftplugin = 'setlocal commentstring<' + +setlocal commentstring=//%s + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/plugin/matchit.vim b/runtime/plugin/matchit.vim index 8053b080e1..c0f1f08027 100644 --- a/runtime/plugin/matchit.vim +++ b/runtime/plugin/matchit.vim @@ -123,7 +123,6 @@ function! s:Match_wrapper(word, forward, mode) range " Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! if (match_words != s:last_words) || (&mps != s:last_mps) || \ exists("b:match_debug") - let s:last_words = match_words let s:last_mps = &mps " The next several lines were here before " BF started messing with this script. @@ -135,6 +134,7 @@ function! s:Match_wrapper(word, forward, mode) range \ '\/\*:\*\/,#\s*if\%(def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>' " s:all = pattern with all the keywords let match_words = match_words . (strlen(match_words) ? "," : "") . default + let s:last_words = match_words if match_words !~ s:notslash . '\\\d' let s:do_BR = 0 let s:pat = match_words diff --git a/runtime/scripts.vim b/runtime/scripts.vim index b62b0a5db8..c2f6d5cff1 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last change: 2014 Aug 24 +" Last change: 2016 May 21 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by @@ -240,7 +240,8 @@ else set ft=xhtml " HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN") - elseif s:line1 =~? '\<DOCTYPE\s\+html\>' + " Avoid "doctype html", used by slim. + elseif s:line1 =~? '<!DOCTYPE\s\+html\>' set ft=html " PDF diff --git a/runtime/syntax/awk.vim b/runtime/syntax/awk.vim index 40491eea1a..ae0f217580 100644 --- a/runtime/syntax/awk.vim +++ b/runtime/syntax/awk.vim @@ -1,15 +1,15 @@ " Vim syntax file " Language: awk, nawk, gawk, mawk " Maintainer: Antonio Colombo <azc100@gmail.com> -" Last Change: 2014 Oct 21 +" Last Change: 2016 Jul 15 -" AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger +" AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger " The AWK Programming Language, Addison-Wesley, 1988 " GAWK ref. is: Arnold D. Robbins " Effective AWK Programming, Third Edition, O'Reilly, 2001 " Effective AWK Programming, Fourth Edition, O'Reilly, 2015 -" (also available with the gawk source distribution) +" (also available and updated with the gawk source distribution) " MAWK is a "new awk" meaning it implements AWK ref. " mawk conforms to the Posix 1003.2 (draft 11.3) @@ -19,11 +19,8 @@ " TODO: " Dig into the commented out syntax expressions below. -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syn clear -elseif exists("b:current_syntax") +" Quit when a syntax file was already loaded +if exists("b:current_syntax") finish endif @@ -35,13 +32,13 @@ set cpo&vim syn keyword awkStatement break continue delete exit syn keyword awkStatement function getline next syn keyword awkStatement print printf return -" GAWK ref. Chapter 7 -syn keyword awkStatement nextfile +" GAWK ref. Chapter 7-9 +syn keyword awkStatement switch nextfile +syn keyword awkStatement func " " GAWK ref. Chapter 9, Functions -" " Numeric Functions -syn keyword awkFunction atan2 cos div exp int log rand sin sqrt srand +syn keyword awkFunction atan2 cos exp int intdiv log rand sin sqrt srand " String Manipulation Functions syn keyword awkFunction asort asort1 gensub gsub index length match syn keyword awkFunction patsplit split sprintf strtonum sub substr @@ -52,17 +49,17 @@ syn keyword awkFunction close fflush system syn keyword awkFunction mktime strftime systime " Bit Manipulation Functions syn keyword awkFunction and compl lshift or rshift xor -" Getting Type Function -syn keyword awkFunction isarray +" Getting Type Functions +syn keyword awkFunction isarray typeof " String-Translation Functions syn keyword awkFunction bindtextdomain dcgettext dcngetext syn keyword awkConditional if else -syn keyword awkRepeat while for +syn keyword awkRepeat while for do -syn keyword awkTodo contained TODO +syn keyword awkTodo contained TODO -syn keyword awkPatterns BEGIN END +syn keyword awkPatterns BEGIN END BEGINFILE ENDFILE " GAWK ref. Chapter 7 " Built-in Variables That Control awk @@ -74,20 +71,18 @@ syn keyword awkVariables ARGC ARGV ARGIND ENVIRON ERRNO FILENAME syn keyword awkVariables FNR NF FUNCTAB NR PROCINFO RLENGTH RSTART syn keyword awkVariables RT SYMTAB -syn keyword awkRepeat do " Octal format character. syn match awkSpecialCharacter display contained "\\[0-7]\{1,3\}" -syn keyword awkStatement func nextfile " Hex format character. syn match awkSpecialCharacter display contained "\\x[0-9A-Fa-f]\+" syn match awkFieldVars "\$\d\+" -"catch errors caused by wrong parenthesis -syn region awkParen transparent start="(" end=")" contains=ALLBUT,awkParenError,awkSpecialCharacter,awkArrayElement,awkArrayArray,awkTodo,awkRegExp,awkBrktRegExp,awkBrackets,awkCharClass +" catch errors caused by wrong parenthesis +syn region awkParen transparent start="(" end=")" contains=ALLBUT,awkParenError,awkSpecialCharacter,awkArrayElement,awkArrayArray,awkTodo,awkRegExp,awkBrktRegExp,awkBrackets,awkCharClass,awkComment syn match awkParenError display ")" -syn match awkInParen display contained "[{}]" +"syn match awkInParen display contained "[{}]" " 64 lines for complex &&'s, and ||'s in a big "if" syn sync ccomment awkParen maxlines=64 @@ -141,7 +136,7 @@ syn match awkExpression "?\|:" syn keyword awkExpression in " Boolean Logic (OR, AND, NOT) -"syn match awkBoolLogic "||\|&&\|\!" +syn match awkBoolLogic "||\|&&\|\!" " This is overridden by less-than & greater-than. " Put this above those to override them. @@ -171,63 +166,42 @@ syn region awkArray transparent start="\[" end="\]" contains=awkArray,awkArrayE " (for the few instances where it would be more than "oneline") syn sync ccomment awkArray maxlines=10 -" define the default highlighting -" For version 5.7 and earlier: only when not done already -" For version 5.8 and later: only when an item doesn't have highlighting yet -if version >= 508 || !exists("did_awk_syn_inits") - if version < 508 - let did_awk_syn_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - - HiLink awkConditional Conditional - HiLink awkFunction Function - HiLink awkRepeat Repeat - HiLink awkStatement Statement - - HiLink awkString String - HiLink awkSpecialPrintf Special - HiLink awkSpecialCharacter Special - - HiLink awkSearch String - HiLink awkBrackets awkRegExp - HiLink awkBrktRegExp awkNestRegExp - HiLink awkCharClass awkNestRegExp - HiLink awkNestRegExp Keyword - HiLink awkRegExp Special - - HiLink awkNumber Number - HiLink awkFloat Float - - HiLink awkFileIO Special - HiLink awkOperator Special - HiLink awkExpression Special - HiLink awkBoolLogic Special - - HiLink awkPatterns Special - HiLink awkVariables Special - HiLink awkFieldVars Special - - HiLink awkLineSkip Special - HiLink awkSemicolon Special - HiLink awkComma Special - "HiLink awkIdentifier Identifier - - HiLink awkComment Comment - HiLink awkTodo Todo - - " Change this if you want nested array names to be highlighted. - HiLink awkArrayArray awkArray - HiLink awkArrayElement Special - - HiLink awkParenError awkError - HiLink awkInParen awkError - HiLink awkError Error - - delcommand HiLink -endif +" Define the default highlighting. +" Only used when an item doesn't have highlighting yet +hi def link awkConditional Conditional +hi def link awkFunction Function +hi def link awkRepeat Repeat +hi def link awkStatement Statement +hi def link awkString String +hi def link awkSpecialPrintf Special +hi def link awkSpecialCharacter Special +hi def link awkSearch String +hi def link awkBrackets awkRegExp +hi def link awkBrktRegExp awkNestRegExp +hi def link awkCharClass awkNestRegExp +hi def link awkNestRegExp Keyword +hi def link awkRegExp Special +hi def link awkNumber Number +hi def link awkFloat Float +hi def link awkFileIO Special +hi def link awkOperator Special +hi def link awkExpression Special +hi def link awkBoolLogic Special +hi def link awkPatterns Special +hi def link awkVariables Special +hi def link awkFieldVars Special +hi def link awkLineSkip Special +hi def link awkSemicolon Special +hi def link awkComma Special +hi def link awkIdentifier Identifier +hi def link awkComment Comment +hi def link awkTodo Todo +" Change this if you want nested array names to be highlighted. +hi def link awkArrayArray awkArray +hi def link awkArrayElement Special +hi def link awkParenError awkError +hi def link awkInParen awkError +hi def link awkError Error let b:current_syntax = "awk" diff --git a/runtime/syntax/dcl.vim b/runtime/syntax/dcl.vim index b08adec31d..73bf577e3e 100644 --- a/runtime/syntax/dcl.vim +++ b/runtime/syntax/dcl.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: DCL (Digital Command Language - vms) " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Jan 20, 2016 -" Version: 8 +" Last Change: May 02, 2016 +" Version: 9 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_DCL " For version 5.x: Clear all syntax items @@ -13,7 +13,7 @@ elseif exists("b:current_syntax") finish endif -if !has("patch-7.4.1141") +if !has("patch-7.4.1142") setlocal iskeyword=$,@,48-57,_ else syn iskeyword $,@,48-57,_ diff --git a/runtime/syntax/debchangelog.vim b/runtime/syntax/debchangelog.vim index 4f1d6d4b11..d0c658c75e 100644 --- a/runtime/syntax/debchangelog.vim +++ b/runtime/syntax/debchangelog.vim @@ -3,7 +3,7 @@ " Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org> " Former Maintainers: Gerfried Fuchs <alfie@ist.org> " Wichert Akkerman <wakkerma@debian.org> -" Last Change: 2015 Oct 24 +" Last Change: 2016 Apr 24 " URL: https://anonscm.debian.org/cgit/pkg-vim/vim.git/plain/runtime/syntax/debchangelog.vim " Standard syntax initialization @@ -23,7 +23,7 @@ let binNMU='binary-only=yes' syn match debchangelogName contained "^[[:alnum:]][[:alnum:].+-]\+ " exe 'syn match debchangelogFirstKV contained "; \('.urgency.'\|'.binNMU.'\)"' exe 'syn match debchangelogOtherKV contained ", \('.urgency.'\|'.binNMU.'\)"' -syn match debchangelogTarget contained "\v %(frozen|unstable|sid|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile|lts|security)|wheezy-%(backports%(-sloppy)=|security)|jessie%(-backports|-security)=|stretch|%(devel|precise|trusty|vivid|wily|xenial)%(-%(security|proposed|updates|backports|commercial|partner))=)+" +syn match debchangelogTarget contained "\v %(frozen|unstable|sid|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile|lts|security)|wheezy-%(backports%(-sloppy)=|security)|jessie%(-backports|-security)=|stretch|%(devel|precise|trusty|vivid|wily|xenial|yakkety)%(-%(security|proposed|updates|backports|commercial|partner))=)+" syn match debchangelogVersion contained "(.\{-})" syn match debchangelogCloses contained "closes:\_s*\(bug\)\=#\=\_s\=\d\+\(,\_s*\(bug\)\=#\=\_s\=\d\+\)*" syn match debchangelogLP contained "\clp:\s\+#\d\+\(,\s*#\d\+\)*" diff --git a/runtime/syntax/debsources.vim b/runtime/syntax/debsources.vim index e0c5f4075f..d35e24729d 100644 --- a/runtime/syntax/debsources.vim +++ b/runtime/syntax/debsources.vim @@ -2,7 +2,7 @@ " Language: Debian sources.list " Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org> " Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl> -" Last Change: 2015 Oct 24 +" Last Change: 2016 Apr 24 " URL: https://anonscm.debian.org/cgit/pkg-vim/vim.git/plain/runtime/syntax/debsources.vim " Standard syntax initialization @@ -27,7 +27,7 @@ let s:supported = [ \ 'oldstable', 'stable', 'testing', 'unstable', 'experimental', \ 'squeeze', 'wheezy', 'jessie', 'stretch', 'sid', 'rc-buggy', \ - \ 'precise', 'trusty', 'vivid', 'wily', 'xenial', 'devel' + \ 'precise', 'trusty', 'wily', 'xenial', 'yakkety', 'devel' \ ] let s:unsupported = [ \ 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato', @@ -36,7 +36,7 @@ let s:unsupported = [ \ 'warty', 'hoary', 'breezy', 'dapper', 'edgy', 'feisty', \ 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid', \ 'maverick', 'natty', 'oneiric', 'quantal', 'raring', 'saucy', - \ 'utopic' + \ 'utopic', 'vivid' \ ] let &cpo=s:cpo diff --git a/runtime/syntax/groovy.vim b/runtime/syntax/groovy.vim index 42fcf4abac..dc39677724 100644 --- a/runtime/syntax/groovy.vim +++ b/runtime/syntax/groovy.vim @@ -2,9 +2,9 @@ " Language: Groovy " Original Author: Alessio Pace <billy.corgan@tiscali.it> " Maintainer: Tobias Rapp <yahuxo@gmx.de> -" Version: 0.1.14 +" Version: 0.1.16 " URL: http://www.vim.org/scripts/script.php?script_id=945 -" Last Change: 2015 Apr 21 +" Last Change: 2016 May 23 " THE ORIGINAL AUTHOR'S NOTES: " @@ -255,8 +255,11 @@ syn region groovyString start=+"+ end=+"+ end=+$+ contains=groovySpeci syn region groovyString start=+'+ end=+'+ end=+$+ contains=groovySpecialChar,groovySpecialError,@Spell syn region groovyString start=+"""+ end=+"""+ contains=groovySpecialChar,groovySpecialError,@Spell,groovyELExpr syn region groovyString start=+'''+ end=+'''+ contains=groovySpecialChar,groovySpecialError,@Spell -" regex string -syn region groovyString start='/[^/]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr +if exists("groovy_regex_strings") + " regex strings interfere with the division operator and thus are disabled + " by default + syn region groovyString start='/[^/*]' end='/' contains=groovySpecialChar,groovyRegexChar,groovyELExpr +endif " syn region groovyELExpr start=+${+ end=+}+ keepend contained syn match groovyELExpr /\${.\{-}}/ contained syn match groovyELExpr /\$[a-zA-Z_][a-zA-Z0-9_.]*/ contained diff --git a/runtime/syntax/lisp.vim b/runtime/syntax/lisp.vim index f496398d50..a402452389 100644 --- a/runtime/syntax/lisp.vim +++ b/runtime/syntax/lisp.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Lisp " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Jan 20, 2016 -" Version: 24 +" Last Change: May 02, 2016 +" Version: 25 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_LISP " " Thanks to F Xavier Noria for a list of 978 Common Lisp symbols taken from HyperSpec @@ -16,7 +16,7 @@ endif if exists("g:lisp_isk") exe "setl isk=".g:lisp_isk -elseif !has("patch-7.4.1141") +elseif !has("patch-7.4.1142") setl isk=38,42,43,45,47-58,60-62,64-90,97-122,_ else syn iskeyword 38,42,43,45,47-58,60-62,64-90,97-122,_ diff --git a/runtime/syntax/maple.vim b/runtime/syntax/maple.vim index 9a4db26dd8..77b1507b36 100644 --- a/runtime/syntax/maple.vim +++ b/runtime/syntax/maple.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Maple V (based on release 4) " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Jan 20, 2016 -" Version: 12 +" Last Change: May 02, 2016 +" Version: 13 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_MAPLE " " Package Function Selection: {{{1 @@ -30,7 +30,7 @@ elseif exists("b:current_syntax") endif " Iskeyword Effects: {{{1 -if !has("patch-7.4.1141") +if !has("patch-7.4.1142") setl isk=$,48-57,_,a-z,@-Z else syn iskeyword $,48-57,_,a-z,@-Z diff --git a/runtime/syntax/scheme.vim b/runtime/syntax/scheme.vim index a210b0c720..c59e09cd17 100644 --- a/runtime/syntax/scheme.vim +++ b/runtime/syntax/scheme.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language: Scheme (R5RS + some R6RS extras) -" Last Change: 2012 May 13 +" Last Change: 2016 May 23 " Maintainer: Sergey Khorev <sergey.khorev@gmail.com> " Original author: Dirk van Deun <dirk@igwe.vub.ac.be> @@ -245,6 +245,18 @@ if exists("b:is_mzscheme") || exists("is_mzscheme") syn region schemeUnquote matchgroup=Delimiter start="#,@\[" end="\]" contains=ALL syn region schemeQuoted matchgroup=Delimiter start="#['`]" end=![ \t()\[\]";]!me=e-1 contains=ALL syn region schemeQuoted matchgroup=Delimiter start="#['`](" matchgroup=Delimiter end=")" contains=ALL + + " Identifiers are very liberal in MzScheme/Racket + syn match schemeOther ![^()[\]{}",'`;#|\\ ]\+! + + " Language setting + syn match schemeLang "#lang [-+_/A-Za-z0-9]\+\>" + + " Various number forms + syn match schemeNumber "[-+]\=[0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\>" + syn match schemeNumber "[-+]\=\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\>" + syn match schemeNumber "[-+]\=[0-9]\+/[0-9]\+\>" + syn match schemeNumber "\([-+]\=\([0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\|\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\|[0-9]\+/[0-9]\+\)\)\=[-+]\([0-9]\+\(\.[0-9]*\)\=\(e[-+]\=[0-9]\+\)\=\|\.[0-9]\+\(e[-+]\=[0-9]\+\)\=\|[0-9]\+/[0-9]\+\)\=i\>" endif @@ -321,6 +333,9 @@ if version >= 508 || !exists("did_scheme_syntax_inits") HiLink schemeExtSyntax Type HiLink schemeExtFunc PreProc + + HiLink schemeLang PreProc + delcommand HiLink endif diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 6ef5bf0d16..c51bd9aa45 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> " Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int> -" Last Change: Apr 11, 2016 -" Version: 147 +" Last Change: May 02, 2016 +" Version: 151 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) @@ -18,19 +18,25 @@ endif " trying to answer the question: which shell is /bin/sh, really? " If the user has not specified any of g:is_kornshell, g:is_bash, g:is_posix, g:is_sh, then guess. -if !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh") +if getline(1) =~ '\<ksh$' + let b:is_kornshell = 1 +elseif getline(1) =~ '\<bash$' + let b:is_bash = 1 +elseif getline(1) =~ '\<dash$' + let b:is_posix = 1 +elseif !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh") let s:shell = "" if executable("/bin/sh") let s:shell = resolve("/bin/sh") elseif executable("/usr/bin/sh") let s:shell = resolve("/usr/bin/sh") endif - if s:shell =~ 'bash$' - let g:is_bash= 1 - elseif s:shell =~ 'ksh$' - let g:is_kornshell = 1 + if s:shell =~ 'ksh$' + let b:is_kornshell= 1 + elseif s:shell =~ 'bash$' + let b:is_bash = 1 elseif s:shell =~ 'dash$' - let g:is_posix = 1 + let b:is_posix = 1 endif unlet s:shell endif @@ -86,8 +92,12 @@ if g:sh_fold_enabled && &fdm == "manual" endif " set up the syntax-highlighting iskeyword -if has("patch-7.4.1141") - exe "syn iskeyword ".&iskeyword.",-" +if has("patch-7.4.1142") + if exists("b:is_bash") + exe "syn iskeyword ".&iskeyword.",-,:" + else + exe "syn iskeyword ".&iskeyword.",-" + endif endif " Set up folding commands for shell {{{1 @@ -140,6 +150,7 @@ syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo syn cluster shLoopList contains=@shCaseList,@shErrorList,shCaseEsac,shConditional,shDblBrace,shExpr,shFor,shForPP,shIf,shOption,shSet,shTest,shTestOpr,shTouch +syn cluster shPPSRightList contains=shComment,shDeref,shDerefSimple,shEscape,shPosnParm syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator syn cluster shTestList contains=shCharClass,shCommandSub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr @@ -213,14 +224,15 @@ syn region shSubSh transparent matchgroup=shSubShRegion start="[^(]\zs(" end=")" syn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$\|\[+ end="\]" contains=@shTestList,shSpecial syn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1 syn region shNoQuote start='\S' skip='\%(\\\\\)*\\.' end='\ze\s' contained +syn match shAstQuote contained '\*\ze"' nextgroup=shString syn match shTestOpr contained '[^-+/%]\zs=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern syn match shTestOpr contained "<=\|>=\|!=\|==\|=\~\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]" syn match shTestPattern contained '\w\+' -syn region shTestDoubleQuote contained start='\%(\%(\\\\\)*\\\)\@<!"' skip=+\\\\\|\\"+ end='"' +syn region shTestDoubleQuote contained start='\%(\%(\\\\\)*\\\)\@<!"' skip=+\\\\\|\\"+ end='"' contains=shDeref,shDerefSimple,shDerefSpecial syn match shTestSingleQuote contained '\\.' syn match shTestSingleQuote contained "'[^']*'" if exists("b:is_kornshell") || exists("b:is_bash") - syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\%(\\\\\)*\\$+ end="\]\]" contains=@shTestList,shNoQuote,shComment + syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\%(\\\\\)*\\$+ end="\]\]" contains=@shTestList,shAstQuote,shNoQuote,shComment syn region shDblParen matchgroup=Delimiter start="((" skip=+\%(\\\\\)*\\$+ end="))" contains=@shTestList,shComment endif @@ -313,7 +325,9 @@ syn match shSource "^\.\s" syn match shSource "\s\.\s" "syn region shColon start="^\s*:" end="$" end="\s#"me=e-2 contains=@shColonList "syn region shColon start="^\s*\zs:" end="$" end="\s#"me=e-2 -syn match shColon '^\s*\zs:' +if exists("b:is_kornshell") + syn match shColon '^\s*\zs:' +endif " String And Character Constants: {{{1 "================================ @@ -404,21 +418,21 @@ if !exists("g:is_posix") endif if exists("b:is_bash") - ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*)" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\%(do\)\@!\&\<[A-Za-z_0-9:][-a-zA-Z_0-9:]*\>\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\%(do\)\@!\&\<[A-Za-z_0-9:][-a-zA-Z_0-9:]*\>\s*\%(()\)\=\_s*)" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment else - ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment - ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment + ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment endif " Parameter Dereferencing: {{{1 " ======================== if !exists("g:sh_no_error") - syn match shDerefWordError "[^}$[]" contained + syn match shDerefWordError "[^}$[~]" contained endif syn match shDerefSimple "\$\%(\k\+\|\d\)" syn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray @@ -498,7 +512,7 @@ if exists("b:is_bash") " bash : ${parameter//pattern} syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList - syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shCommandSubList + syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shPPSRightList " bash : ${parameter/#substring/replacement} syn match shDerefPSR contained '/#' nextgroup=shDerefPSRleft @@ -567,6 +581,7 @@ syn sync match shWhileSync grouphere shRepeat "\<while\>" " Default Highlighting: {{{1 " ===================== hi def link shArithRegion shShellVariables +hi def link shAstQuote shDoubleQuote hi def link shAtExpr shSetList hi def link shBeginHere shRedir hi def link shCaseBar shConditional @@ -597,7 +612,6 @@ hi def link shEmbeddedEcho shString hi def link shEscape shCommandSub hi def link shExDoubleQuote shDoubleQuote hi def link shExSingleQuote shSingleQuote -hi def link shFunction Function hi def link shHereDoc shString hi def link shHerePayload shHereDoc hi def link shLoop shStatement @@ -628,21 +642,17 @@ if exists("b:is_bash") hi def link bashAdminStatement shStatement hi def link bashSpecialVariables shShellVariables hi def link bashStatement shStatement - hi def link shFunctionParen Delimiter - hi def link shFunctionDelim Delimiter hi def link shCharClass shSpecial endif if exists("b:is_kornshell") hi def link kshSpecialVariables shShellVariables hi def link kshStatement shStatement - hi def link shFunctionParen Delimiter endif if !exists("g:sh_no_error") hi def link shCaseError Error hi def link shCondError Error hi def link shCurlyError Error - hi def link shDerefError Error hi def link shDerefOpError Error hi def link shDerefWordError Error hi def link shDoError Error diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index d6d5dd81ee..9d91402bc8 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX " Maintainer: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM> -" Last Change: Apr 11, 2016 -" Version: 94 +" Last Change: May 02, 2016 +" Version: 95 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -133,7 +133,7 @@ endif " g:tex_isk if exists("g:tex_isk") exe "setlocal isk=".g:tex_isk -elseif !has("patch-7.4.1141") +elseif !has("patch-7.4.1142") setl isk=48-57,a-z,A-Z,192-255 else syn iskeyword 48-57,a-z,A-Z,192-255 diff --git a/runtime/syntax/tidy.vim b/runtime/syntax/tidy.vim index c24796edd1..6371cb5a86 100644 --- a/runtime/syntax/tidy.vim +++ b/runtime/syntax/tidy.vim @@ -1,145 +1,135 @@ " Vim syntax file " Language: HMTL Tidy configuration file (/etc/tidyrc ~/.tidyrc) " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2013 June 01 +" Last Change: 2016 Apr 24 if exists("b:current_syntax") finish endif -setlocal iskeyword=@,48-57,- +let s:cpo_save = &cpo +set cpo&vim + +syn iskeyword @,48-57,-,_ + +syn case ignore +syn keyword tidyBoolean contained t[rue] f[alse] y[es] n[o] 1 0 +syn keyword tidyAutoBoolean contained t[rue] f[alse] y[es] n[o] 1 0 auto +syn case match +syn keyword tidyDoctype contained html5 omit auto strict loose transitional user +syn keyword tidyEncoding contained raw ascii latin0 latin1 utf8 iso2022 mac win1252 ibm858 utf16le utf16be utf16 big5 shiftjis +syn keyword tidyNewline contained LF CRLF CR +syn match tidyNumber contained "\<\d\+\>" +syn keyword tidyRepeat contained keep-first keep-last +syn keyword tidySorter contained alpha none +syn region tidyString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ oneline +syn region tidyString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ oneline +syn match tidyTags contained "\<\w\+\(\s*,\s*\w\+\)*\>" + +syn keyword tidyBooleanOption add-xml-decl add-xml-pi add-xml-space + \ anchor-as-name ascii-chars assume-xml-procins bare break-before-br + \ clean coerce-endtags decorate-inferred-ul drop-empty-paras + \ drop-empty-elements drop-font-tags drop-proprietary-attributes + \ enclose-block-text enclose-text escape-cdata escape-scripts + \ fix-backslash fix-bad-comments fix-uri force-output gdoc gnu-emacs + \ hide-comments hide-endtags indent-attributes indent-cdata + \ indent-with-tabs input-xml join-classes join-styles keep-time + \ language literal-attributes logical-emphasis lower-literals markup + \ merge-emphasis ncr numeric-entities omit-optional-tags output-html + \ output-xhtml output-xml preserve-entities punctuation-wrap quiet + \ quote-ampersand quote-marks quote-nbsp raw replace-color show-info + \ show-warnings skip-nested split strict-tags-attributes tidy-mark + \ uppercase-attributes uppercase-tags word-2000 wrap-asp + \ wrap-attributes wrap-jste wrap-php wrap-script-literals + \ wrap-sections write-back + \ contained nextgroup=tidyBooleanDelimiter + +syn match tidyBooleanDelimiter ":" nextgroup=tidyBoolean contained skipwhite + +syn keyword tidyAutoBooleanOption indent merge-divs merge-spans output-bom show-body-only vertical-space contained nextgroup=tidyAutoBooleanDelimiter +syn match tidyAutoBooleanDelimiter ":" nextgroup=tidyAutoBoolean contained skipwhite + +syn keyword tidyCSSSelectorOption css-prefix contained nextgroup=tidyCSSSelectorDelimiter +syn match tidyCSSSelectorDelimiter ":" nextgroup=tidyCSSSelector contained skipwhite + +syn keyword tidyDoctypeOption doctype contained nextgroup=tidyDoctypeDelimiter +syn match tidyDoctypeDelimiter ":" nextgroup=tidyDoctype contained skipwhite + +syn keyword tidyEncodingOption char-encoding input-encoding output-encoding contained nextgroup=tidyEncodingDelimiter +syn match tidyEncodingDelimiter ":" nextgroup=tidyEncoding contained skipwhite + +syn keyword tidyIntegerOption accessibility-check doctype-mode indent-spaces show-errors tab-size wrap contained nextgroup=tidyIntegerDelimiter +syn match tidyIntegerDelimiter ":" nextgroup=tidyNumber contained skipwhite + +syn keyword tidyNameOption slide-style contained nextgroup=tidyNameDelimiter +syn match tidyNameDelimiter ":" nextgroup=tidyName contained skipwhite + +syn keyword tidyNewlineOption newline contained nextgroup=tidyNewlineDelimiter +syn match tidyNewlineDelimiter ":" nextgroup=tidyNewline contained skipwhite + +syn keyword tidyTagsOption new-blocklevel-tags new-empty-tags new-inline-tags new-pre-tags contained nextgroup=tidyTagsDelimiter +syn match tidyTagsDelimiter ":" nextgroup=tidyTags contained skipwhite + +syn keyword tidyRepeatOption repeated-attributes contained nextgroup=tidyRepeatDelimiter +syn match tidyRepeatDelimiter ":" nextgroup=tidyRepeat contained skipwhite + +syn keyword tidySorterOption sort-attributes contained nextgroup=tidySorterDelimiter +syn match tidySorterDelimiter ":" nextgroup=tidySorter contained skipwhite + +syn keyword tidyStringOption alt-text error-file gnu-emacs-file output-file contained nextgroup=tidyStringDelimiter +syn match tidyStringDelimiter ":" nextgroup=tidyString contained skipwhite + +syn cluster tidyOptions contains=tidy.*Option + +syn match tidyStart "^" nextgroup=@tidyOptions syn match tidyComment "^\s*//.*$" contains=tidyTodo syn match tidyComment "^\s*#.*$" contains=tidyTodo syn keyword tidyTodo TODO NOTE FIXME XXX contained -syn match tidyAssignment "^[a-z0-9-]\+:\s*.*$" contains=tidyOption,@tidyValue,tidyDelimiter -syn match tidyDelimiter ":" contained +hi def link tidyAutoBooleanOption Identifier +hi def link tidyBooleanOption Identifier +hi def link tidyCSSSelectorOption Identifier +hi def link tidyDoctypeOption Identifier +hi def link tidyEncodingOption Identifier +hi def link tidyIntegerOption Identifier +hi def link tidyNameOption Identifier +hi def link tidyNewlineOption Identifier +hi def link tidyTagsOption Identifier +hi def link tidyRepeatOption Identifier +hi def link tidySorterOption Identifier +hi def link tidyStringOption Identifier -syn match tidyNewTagAssignment "^new-\l\+-tags:\s*.*$" contains=tidyNewTagOption,tidyNewTagDelimiter,tidyNewTagValue,tidyDelimiter -syn match tidyNewTagDelimiter "," contained -syn match tidyNewTagValue "\<\w\+\>" contained +hi def link tidyAutoBooleanDelimiter Special +hi def link tidyBooleanDelimiter Special +hi def link tidyCSSSelectorDelimiter Special +hi def link tidyDoctypeDelimiter Special +hi def link tidyEncodingDelimiter Special +hi def link tidyIntegerDelimiter Special +hi def link tidyNameDelimiter Special +hi def link tidyNewlineDelimiter Special +hi def link tidyTagsDelimiter Special +hi def link tidyRepeatDelimiter Special +hi def link tidySorterDelimiter Special +hi def link tidyStringDelimiter Special -syn case ignore -syn keyword tidyBoolean t[rue] f[alse] y[es] n[o] contained -syn case match -syn match tidyDoctype "\<\%(omit\|auto\|strict\|loose\|transitional\|user\)\>" contained -" NOTE: use match rather than keyword here so that tidyEncoding 'raw' does not -" always have precedence over tidyOption 'raw' -syn match tidyEncoding "\<\%(ascii\|latin0\|latin1\|raw\|utf8\|iso2022\|mac\|utf16le\|utf16be\|utf16\|win1252\|ibm858\|big5\|shiftjis\)\>" contained -syn match tidyNewline "\<\%(LF\|CRLF\|CR\)\>" -syn match tidyNumber "\<\d\+\>" contained -syn match tidyRepeat "\<\%(keep-first\|keep-last\)\>" contained -syn region tidyString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained oneline -syn region tidyString start=+'+ skip=+\\\\\|\\'+ end=+'+ contained oneline -syn cluster tidyValue contains=tidyBoolean,tidyDoctype,tidyEncoding,tidyNewline,tidyNumber,tidyRepeat,tidyString - -syn match tidyOption "^accessibility-check" contained -syn match tidyOption "^add-xml-decl" contained -syn match tidyOption "^add-xml-pi" contained -syn match tidyOption "^add-xml-space" contained -syn match tidyOption "^alt-text" contained -syn match tidyOption "^anchor-as-name" contained -syn match tidyOption "^ascii-chars" contained -syn match tidyOption "^assume-xml-procins" contained -syn match tidyOption "^bare" contained -syn match tidyOption "^break-before-br" contained -syn match tidyOption "^char-encoding" contained -syn match tidyOption "^clean" contained -syn match tidyOption "^css-prefix" contained -syn match tidyOption "^decorate-inferred-ul" contained -syn match tidyOption "^doctype" contained -syn match tidyOption "^doctype-mode" contained -syn match tidyOption "^drop-empty-paras" contained -syn match tidyOption "^drop-font-tags" contained -syn match tidyOption "^drop-proprietary-attributes" contained -syn match tidyOption "^enclose-block-text" contained -syn match tidyOption "^enclose-text" contained -syn match tidyOption "^error-file" contained -syn match tidyOption "^escape-cdata" contained -syn match tidyOption "^fix-backslash" contained -syn match tidyOption "^fix-bad-comments" contained -syn match tidyOption "^fix-uri" contained -syn match tidyOption "^force-output" contained -syn match tidyOption "^gnu-emacs" contained -syn match tidyOption "^gnu-emacs-file" contained -syn match tidyOption "^hide-comments" contained -syn match tidyOption "^hide-endtags" contained -syn match tidyOption "^indent" contained -syn match tidyOption "^indent-attributes" contained -syn match tidyOption "^indent-cdata" contained -syn match tidyOption "^indent-spaces" contained -syn match tidyOption "^input-encoding" contained -syn match tidyOption "^input-xml" contained -syn match tidyOption "^join-classes" contained -syn match tidyOption "^join-styles" contained -syn match tidyOption "^keep-time" contained -syn match tidyOption "^language" contained -syn match tidyOption "^literal-attributes" contained -syn match tidyOption "^logical-emphasis" contained -syn match tidyOption "^lower-literals" contained -syn match tidyOption "^markup" contained -syn match tidyOption "^merge-divs" contained -syn match tidyOption "^merge-spans" contained -syn match tidyOption "^ncr" contained -syn match tidyOption "^newline" contained -syn match tidyOption "^numeric-entities" contained -syn match tidyOption "^output-bom" contained -syn match tidyOption "^output-encoding" contained -syn match tidyOption "^output-file" contained -syn match tidyOption "^output-html" contained -syn match tidyOption "^output-xhtml" contained -syn match tidyOption "^output-xml" contained -syn match tidyOption "^preserve-entities" contained -syn match tidyOption "^punctuation-wrap" contained -syn match tidyOption "^quiet" contained -syn match tidyOption "^quote-ampersand" contained -syn match tidyOption "^quote-marks" contained -syn match tidyOption "^quote-nbsp" contained -syn match tidyOption "^raw" contained -syn match tidyOption "^repeated-attributes" contained -syn match tidyOption "^replace-color" contained -syn match tidyOption "^show-body-only" contained -syn match tidyOption "^show-errors" contained -syn match tidyOption "^show-warnings" contained -syn match tidyOption "^slide-style" contained -syn match tidyOption "^sort-attributes" contained -syn match tidyOption "^split" contained -syn match tidyOption "^tab-size" contained -syn match tidyOption "^tidy-mark" contained -syn match tidyOption "^uppercase-attributes" contained -syn match tidyOption "^uppercase-tags" contained -syn match tidyOption "^word-2000" contained -syn match tidyOption "^wrap" contained -syn match tidyOption "^wrap-asp" contained -syn match tidyOption "^wrap-attributes" contained -syn match tidyOption "^wrap-jste" contained -syn match tidyOption "^wrap-php" contained -syn match tidyOption "^wrap-script-literals" contained -syn match tidyOption "^wrap-sections" contained -syn match tidyOption "^write-back" contained -syn match tidyOption "^vertical-space" contained - -syn match tidyNewTagOption "^new-blocklevel-tags" contained -syn match tidyNewTagOption "^new-empty-tags" contained -syn match tidyNewTagOption "^new-inline-tags" contained -syn match tidyNewTagOption "^new-pre-tags" contained - -hi def link tidyBoolean Boolean -hi def link tidyComment Comment -hi def link tidyDelimiter Special -hi def link tidyDoctype Constant -hi def link tidyEncoding Constant -hi def link tidyNewline Constant -hi def link tidyNewTagDelimiter Special -hi def link tidyNewTagOption Identifier -hi def link tidyNewTagValue Constant -hi def link tidyNumber Number -hi def link tidyOption Identifier -hi def link tidyRepeat Constant -hi def link tidyString String -hi def link tidyTodo Todo +hi def link tidyAutoBoolean Boolean +hi def link tidyBoolean Boolean +hi def link tidyDoctype Constant +hi def link tidyEncoding Constant +hi def link tidyNewline Constant +hi def link tidyTags Constant +hi def link tidyNumber Number +hi def link tidyRepeat Constant +hi def link tidySorter Constant +hi def link tidyString String + +hi def link tidyComment Comment +hi def link tidyTodo Todo let b:current_syntax = "tidy" +let &cpo = s:cpo_save +unlet s:cpo_save + " vim: ts=8 diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 34fdae0ffc..32e871ea79 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -39,8 +39,8 @@ syn keyword vimOnlyOption contained nobiosk nobioskey noconsk noconskey nocp noc " Invertible setting variants syn keyword vimOnlyOption contained invbiosk invbioskey invconsk invconskey invcp invcompatible invguipty invmacatsui invsn invshortname invta invtextauto invtx invtextmode invtf invttyfast invtbi invttybuiltin invwiv invweirdinvert " termcap codes (which can also be set) {{{2 -syn keyword vimTermOption contained t_AB t_al t_bc t_ce t_cl t_Co t_Cs t_CS t_CV t_da t_db t_dl t_DL t_EI t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_fs t_IE t_IS t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_ke t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ks t_ku t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RI t_RV t_Sb t_se t_Sf t_SI t_so t_sr t_te t_ti t_ts t_u7 t_ue t_us t_ut t_vb t_ve t_vi t_vs t_WP t_WS t_xs t_ZH t_ZR -syn keyword vimTermOption contained t_AF t_AL t_cd t_Ce t_cm t_cs +syn keyword vimTermOption contained t_8b t_AB t_al t_bc t_ce t_cl t_Co t_Cs t_CV t_db t_DL t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_fs t_IE t_IS t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_ke t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ks t_ku t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RB t_RI t_RV t_Sb t_se t_Sf t_SI t_so t_sr t_SR t_te t_ti t_ts t_u7 t_ue t_us t_ut t_vb t_ve t_vi t_vs t_WP t_WS t_xn t_xs t_ZH t_ZR +syn keyword vimTermOption contained t_8f t_AF t_AL t_cd t_Ce t_cm t_cs t_CS t_da t_dl t_EI syn match vimTermOption contained "t_%1" syn match vimTermOption contained "t_#2" syn match vimTermOption contained "t_#4" @@ -177,7 +177,7 @@ syn cluster vimAugroupList contains=vimAugroup,vimIsCommand,vimCommand,vimUserCm if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'a' syn region vimAugroup fold matchgroup=vimAugroupKey start="\<aug\%[roup]\>\ze\s\+\K\k*" end="\<aug\%[roup]\>\ze\s\+[eE][nN][dD]\>" contains=vimAutoCmd,@vimAugroupList else - syn region vimAugroup matchgroup=vimAugroupKey start="\<aug\%[roup]\>\ze\s\+\K\k*" end="\<aug\%[roup]\>\ze\s\+[eE][nN][dD]\>" contains=vimAutoCmd,@vimAugroupList + syn region vimAugroup matchgroup=vimAugroupKey start="\<aug\%[roup]\>\ze\s\+\K\k*" end="\<aug\%[roup]\>\ze\s\+[eE][nN][dD]\>" contains=vimAutoCmd,@vimAugroupList endif syn match vimAugroup "aug\%[roup]!" contains=vimAugroupKey if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_noaugrouperror") @@ -285,10 +285,11 @@ syn match vimStringCont contained +\(\\\\\|.\)\{-}[^\\]"+ syn cluster vimSubstList contains=vimPatSep,vimPatRegion,vimPatSepErr,vimSubstTwoBS,vimSubstRange,vimNotation syn cluster vimSubstRepList contains=vimSubstSubstr,vimSubstTwoBS,vimNotation syn cluster vimSubstList add=vimCollection -syn match vimSubst "\(:\+\s*\|^\s*\||\s*\)\<\%(s\%[ubstitute]\|sm\%[agic]\|sno\%[magic]\)[:[:alpha:]]\@!" nextgroup=vimSubstPat -syn match vimSubst "\%(^\|[^\\]\)s\%[ubstitute][:#[:alpha:]]\@!" nextgroup=vimSubstPat contained -syn match vimSubst "/\zss\%[ubstitute]\ze/" nextgroup=vimSubstPat -syn match vimSubst1 contained "s\%[ubstitute]\>" nextgroup=vimSubstPat +syn match vimSubst "\(:\+\s*\|^\s*\||\s*\)\<\%(\<s\%[ubstitute]\>\|\<sm\%[agic]\>\|\<sno\%[magic]\>\)[:#[:alpha:]]\@!" nextgroup=vimSubstPat +syn match vimSubst "\%(^\|[^\\]\)\<s\%[ubstitute]\>[:#[:alpha:]]\@!" nextgroup=vimSubstPat contained +syn match vimSubst "/\zs\<s\%[ubstitute]\>\ze/" nextgroup=vimSubstPat +syn match vimSubst "\(:\+\s*\|^\s*\)s\ze#.\{-}#.\{-}#" nextgroup=vimSubstPat +syn match vimSubst1 contained "\<s\%[ubstitute]\>" nextgroup=vimSubstPat syn region vimSubstPat contained matchgroup=vimSubstDelim start="\z([^a-zA-Z( \t[\]&]\)"rs=s+1 skip="\\\\\|\\\z1" end="\z1"re=e-1,me=e-1 contains=@vimSubstList nextgroup=vimSubstRep4 oneline syn region vimSubstRep4 contained matchgroup=vimSubstDelim start="\z(.\)" skip="\\\\\|\\\z1" end="\z1" matchgroup=vimNotation end="<[cC][rR]>" contains=@vimSubstRepList nextgroup=vimSubstFlagErr oneline syn region vimCollection contained transparent start="\\\@<!\[" skip="\\\[" end="\]" contains=vimCollClass diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index c3efb27e3a..de101357db 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -124,7 +124,7 @@ assign_commit_details() { patch_file="vim-${vim_version}.patch" } -# Patch surgery: +# Patch surgery preprocess_patch() { local file="$1" local nvim="nvim -u NORC -i NONE --headless" @@ -134,8 +134,8 @@ preprocess_patch() { na_src="$na_src"'\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%('${na_src}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" - # Remove todo.txt, version*.txt, tags - local na_doc='todo\.txt\|version\d\.txt\|tags' + # Remove channel.txt, netbeans.txt, os_*.txt, todo.txt, version*.txt, tags + local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|todo\.txt\|version\d\.txt\|tags' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\%('${na_doc}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove some testdir/Make_*.mak files @@ -143,7 +143,12 @@ preprocess_patch() { 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\%('${na_src_testdir}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" # Rename src/ paths to src/nvim/ - LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' "$file" > "$file".tmp && mv "$file".tmp "$file" + LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + + # Rename path to matchit plugin. + LC_ALL=C sed -e 's@\( [ab]/runtime\)/pack/dist/opt/matchit/\(plugin/matchit.vim\)@\1/\2@g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" } get_vim_patch() { diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 09d717bff6..eaaae943d2 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -28,9 +28,9 @@ /// Gets the buffer line count /// -/// @param buffer The buffer handle -/// @param[out] err Details of an error that may have occurred -/// @return The line count +/// @param buffer Buffer handle +/// @param[out] err Error details, if any +/// @return Line count Integer nvim_buf_line_count(Buffer buffer, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -50,10 +50,10 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err) /// for negative indices use /// "nvim_buf_get_lines(buffer, index-1, index, true)" /// -/// @param buffer The buffer handle -/// @param index The line index -/// @param[out] err Details of an error that may have occurred -/// @return The line string +/// @param buffer Buffer handle +/// @param index Line index +/// @param[out] err Error details, if any +/// @return Line string String buffer_get_line(Buffer buffer, Integer index, Error *err) { String rv = { .size = 0 }; @@ -78,10 +78,10 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err) /// for negative indices use /// "nvim_buf_set_lines(buffer, index-1, index, true, [line])" /// -/// @param buffer The buffer handle -/// @param index The line index -/// @param line The new line. -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param index Line index +/// @param line Contents of the new line +/// @param[out] err Error details, if any void buffer_set_line(Buffer buffer, Integer index, String line, Error *err) { Object l = STRING_OBJ(line); @@ -97,9 +97,9 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err) /// "nvim_buf_set_lines(buffer, index, index+1, true, [])" /// for negative indices use /// "nvim_buf_set_lines(buffer, index-1, index, true, [])" -/// @param buffer The buffer handle -/// @param index The line index -/// @param[out] err Details of an error that may have occurred +/// @param buffer buffer handle +/// @param index line index +/// @param[out] err Error details, if any void buffer_del_line(Buffer buffer, Integer index, Error *err) { Array array = ARRAY_DICT_INIT; @@ -113,13 +113,13 @@ void buffer_del_line(Buffer buffer, Integer index, Error *err) /// where newstart = start + int(not include_start) - int(start < 0) /// newend = end + int(include_end) - int(end < 0) /// int(bool) = 1 if bool is true else 0 -/// @param buffer The buffer handle -/// @param start The first line index -/// @param end The last line index -/// @param include_start True if the slice includes the `start` parameter -/// @param include_end True if the slice includes the `end` parameter -/// @param[out] err Details of an error that may have occurred -/// @return An array of lines +/// @param buffer Buffer handle +/// @param start First line index +/// @param end Last line index +/// @param include_start True if the slice includes the `start` parameter +/// @param include_end True if the slice includes the `end` parameter +/// @param[out] err Error details, if any +/// @return Array of lines ArrayOf(String) buffer_get_line_slice(Buffer buffer, Integer start, Integer end, @@ -142,12 +142,12 @@ ArrayOf(String) buffer_get_line_slice(Buffer buffer, /// Out-of-bounds indices are clamped to the nearest valid value, unless /// `strict_indexing` is set. /// -/// @param buffer The buffer handle -/// @param start The first line index -/// @param end The last line index (exclusive) -/// @param strict_indexing whether out-of-bounds should be an error. -/// @param[out] err Details of an error that may have occurred -/// @return An array of lines +/// @param buffer Buffer handle +/// @param start First line index +/// @param end Last line index (exclusive) +/// @param strict_indexing Whether out-of-bounds should be an error. +/// @param[out] err Error details, if any +/// @return Array of lines ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id, Buffer buffer, Integer start, @@ -219,14 +219,14 @@ end: /// newend = end + int(include_end) + int(end < 0) /// int(bool) = 1 if bool is true else 0 /// -/// @param buffer The buffer handle -/// @param start The first line index -/// @param end The last line index -/// @param include_start True if the slice includes the `start` parameter -/// @param include_end True if the slice includes the `end` parameter -/// @param replacement An array of lines to use as replacement(A 0-length -// array will simply delete the line range) -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param start First line index +/// @param end Last line index +/// @param include_start True if the slice includes the `start` parameter +/// @param include_end True if the slice includes the `end` parameter +/// @param replacement Array of lines to use as replacement (0-length +// array will delete the line range) +/// @param[out] err Error details, if any void buffer_set_line_slice(Buffer buffer, Integer start, Integer end, @@ -253,12 +253,12 @@ void buffer_set_line_slice(Buffer buffer, /// Out-of-bounds indices are clamped to the nearest valid value, unless /// `strict_indexing` is set. /// -/// @param buffer The buffer handle -/// @param start The first line index -/// @param end The last line index (exclusive) -/// @param strict_indexing whether out-of-bounds should be an error. -/// @param replacement An array of lines to use as replacement -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param start First line index +/// @param end Last line index (exclusive) +/// @param strict_indexing Whether out-of-bounds should be an error. +/// @param replacement Array of lines to use as replacement +/// @param[out] err Error details, if any void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, @@ -411,10 +411,10 @@ end: /// Gets a buffer-scoped (b:) variable. /// -/// @param buffer The buffer handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The variable value +/// @param buffer Buffer handle +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Variable value Object nvim_buf_get_var(Buffer buffer, String name, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -428,10 +428,10 @@ Object nvim_buf_get_var(Buffer buffer, String name, Error *err) /// Sets a buffer-scoped (b:) variable /// -/// @param buffer The buffer handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any void nvim_buf_set_var(Buffer buffer, String name, Object value, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -445,9 +445,9 @@ void nvim_buf_set_var(Buffer buffer, String name, Object value, Error *err) /// Removes a buffer-scoped (b:) variable /// -/// @param buffer The buffer handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param name Variable name +/// @param[out] err Error details, if any void nvim_buf_del_var(Buffer buffer, String name, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -463,11 +463,11 @@ void nvim_buf_del_var(Buffer buffer, String name, Error *err) /// /// @deprecated /// -/// @param buffer The buffer handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred -/// @return The old value or nil if there was no previous value. +/// @param buffer Buffer handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any +/// @return Old value or nil if there was no previous value. /// /// @warning It may return nil if there was no previous value /// or if previous value was `v:null`. @@ -486,10 +486,10 @@ Object buffer_set_var(Buffer buffer, String name, Object value, Error *err) /// /// @deprecated /// -/// @param buffer The buffer handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The old value +/// @param buffer Buffer handle +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Old value Object buffer_del_var(Buffer buffer, String name, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -504,10 +504,10 @@ Object buffer_del_var(Buffer buffer, String name, Error *err) /// Gets a buffer option value /// -/// @param buffer The buffer handle -/// @param name The option name -/// @param[out] err Details of an error that may have occurred -/// @return The option value +/// @param buffer Buffer handle +/// @param name Option name +/// @param[out] err Error details, if any +/// @return Option value Object nvim_buf_get_option(Buffer buffer, String name, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -519,13 +519,13 @@ Object nvim_buf_get_option(Buffer buffer, String name, Error *err) return get_option_from(buf, SREQ_BUF, name, err); } -/// Sets a buffer option value. Passing 'nil' as value deletes the option(only +/// Sets a buffer option value. Passing 'nil' as value deletes the option (only /// works if there's a global fallback) /// -/// @param buffer The buffer handle -/// @param name The option name -/// @param value The option value -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param name Option name +/// @param value Option value +/// @param[out] err Error details, if any void nvim_buf_set_option(Buffer buffer, String name, Object value, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -539,9 +539,9 @@ void nvim_buf_set_option(Buffer buffer, String name, Object value, Error *err) /// Gets the buffer number /// -/// @param buffer The buffer handle -/// @param[out] err Details of an error that may have occurred -/// @return The buffer number +/// @param buffer Buffer handle +/// @param[out] err Error details, if any +/// @return Buffer number Integer nvim_buf_get_number(Buffer buffer, Error *err) { Integer rv = 0; @@ -556,9 +556,9 @@ Integer nvim_buf_get_number(Buffer buffer, Error *err) /// Gets the full file name for the buffer /// -/// @param buffer The buffer handle -/// @param[out] err Details of an error that may have occurred -/// @return The buffer name +/// @param buffer Buffer handle +/// @param[out] err Error details, if any +/// @return Buffer name String nvim_buf_get_name(Buffer buffer, Error *err) { String rv = STRING_INIT; @@ -573,9 +573,9 @@ String nvim_buf_get_name(Buffer buffer, Error *err) /// Sets the full file name for a buffer /// -/// @param buffer The buffer handle -/// @param name The buffer name -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param name Buffer name +/// @param[out] err Error details, if any void nvim_buf_set_name(Buffer buffer, String name, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -603,7 +603,7 @@ void nvim_buf_set_name(Buffer buffer, String name, Error *err) /// Checks if a buffer is valid /// -/// @param buffer The buffer handle +/// @param buffer Buffer handle /// @return true if the buffer is valid, false otherwise Boolean nvim_buf_is_valid(Buffer buffer) { @@ -615,11 +615,11 @@ Boolean nvim_buf_is_valid(Buffer buffer) /// /// @deprecated use nvim_buf_set_lines(buffer, lnum, lnum, true, lines) /// -/// @param buffer The buffer handle -/// @param lnum Insert the lines after `lnum`. If negative, it will append -/// to the end of the buffer. -/// @param lines An array of lines -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param lnum Insert the lines after `lnum`. If negative, appends to +/// the end of the buffer. +/// @param lines Array of lines +/// @param[out] err Error details, if any void buffer_insert(Buffer buffer, Integer lnum, ArrayOf(String) lines, @@ -632,10 +632,10 @@ void buffer_insert(Buffer buffer, /// Return a tuple (row,col) representing the position of the named mark /// -/// @param buffer The buffer handle -/// @param name The mark's name -/// @param[out] err Details of an error that may have occurred -/// @return The (row, col) tuple +/// @param buffer Buffer handle +/// @param name Mark name +/// @param[out] err Error details, if any +/// @return (row, col) tuple ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err) { Array rv = ARRAY_DICT_INIT; @@ -694,15 +694,15 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err) /// request an unique src_id at initialization, and later asynchronously add and /// clear highlights in response to buffer changes. /// -/// @param buffer The buffer handle -/// @param src_id Source group to use or 0 to use a new group, -/// or -1 for ungrouped highlight -/// @param hl_group Name of the highlight group to use -/// @param line The line to highlight -/// @param col_start Start of range of columns to highlight -/// @param col_end End of range of columns to highlight, -/// or -1 to highlight to end of line -/// @param[out] err Details of an error that may have occurred +/// @param buffer Buffer handle +/// @param src_id Source group to use or 0 to use a new group, +/// or -1 for ungrouped highlight +/// @param hl_group Name of the highlight group to use +/// @param line Line to highlight +/// @param col_start Start of range of columns to highlight +/// @param col_end End of range of columns to highlight, +/// or -1 to highlight to end of line +/// @param[out] err Error details, if any /// @return The src_id that was used Integer nvim_buf_add_highlight(Buffer buffer, Integer src_id, @@ -740,12 +740,12 @@ Integer nvim_buf_add_highlight(Buffer buffer, /// To clear a source group in the entire buffer, pass in 1 and -1 to /// line_start and line_end respectively. /// -/// @param buffer The buffer handle -/// @param src_id Highlight source group to clear, or -1 to clear all groups. +/// @param buffer Buffer handle +/// @param src_id Highlight source group to clear, or -1 to clear all. /// @param line_start Start of range of lines to clear -/// @param line_end End of range of lines to clear (exclusive) -/// or -1 to clear to end of file. -/// @param[out] err Details of an error that may have occurred +/// @param line_end End of range of lines to clear (exclusive) or -1 to clear +/// to end of file. +/// @param[out] err Error details, if any void nvim_buf_clear_highlight(Buffer buffer, Integer src_id, Integer line_start, diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index fa00988ae3..9e61ec1871 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -11,9 +11,9 @@ /// Gets the windows in a tabpage /// -/// @param tabpage The tabpage -/// @param[out] err Details of an error that may have occurred -/// @return The windows in `tabpage` +/// @param tabpage Tabpage +/// @param[out] err Error details, if any +/// @return List of windows in `tabpage` ArrayOf(Window) nvim_tabpage_list_wins(Tabpage tabpage, Error *err) { Array rv = ARRAY_DICT_INIT; @@ -39,10 +39,10 @@ ArrayOf(Window) nvim_tabpage_list_wins(Tabpage tabpage, Error *err) /// Gets a tab-scoped (t:) variable /// -/// @param tabpage The tab page handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The variable value +/// @param tabpage Tabpage handle +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Variable value Object nvim_tabpage_get_var(Tabpage tabpage, String name, Error *err) { tabpage_T *tab = find_tab_by_handle(tabpage, err); @@ -56,10 +56,10 @@ Object nvim_tabpage_get_var(Tabpage tabpage, String name, Error *err) /// Sets a tab-scoped (t:) variable /// -/// @param tabpage handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred +/// @param tabpage Tabpage handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any void nvim_tabpage_set_var(Tabpage tabpage, String name, Object value, @@ -76,9 +76,9 @@ void nvim_tabpage_set_var(Tabpage tabpage, /// Removes a tab-scoped (t:) variable /// -/// @param tabpage handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred +/// @param tabpage Tabpage handle +/// @param name Variable name +/// @param[out] err Error details, if any void nvim_tabpage_del_var(Tabpage tabpage, String name, Error *err) { tabpage_T *tab = find_tab_by_handle(tabpage, err); @@ -94,11 +94,11 @@ void nvim_tabpage_del_var(Tabpage tabpage, String name, Error *err) /// /// @deprecated /// -/// @param tabpage handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred -/// @return The old value or nil if there was no previous value. +/// @param tabpage Tabpage handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any +/// @return Old value or nil if there was no previous value. /// /// @warning It may return nil if there was no previous value /// or if previous value was `v:null`. @@ -117,10 +117,10 @@ Object tabpage_set_var(Tabpage tabpage, String name, Object value, Error *err) /// /// @deprecated /// -/// @param tabpage handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The old value +/// @param tabpage Tabpage handle +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Old value Object tabpage_del_var(Tabpage tabpage, String name, Error *err) { tabpage_T *tab = find_tab_by_handle(tabpage, err); @@ -132,11 +132,11 @@ Object tabpage_del_var(Tabpage tabpage, String name, Error *err) return dict_set_value(tab->tp_vars, name, NIL, true, true, err); } -/// Gets the current window in a tab page +/// Gets the current window in a tabpage /// -/// @param tabpage The tab page handle -/// @param[out] err Details of an error that may have occurred -/// @return The Window handle +/// @param tabpage Tabpage handle +/// @param[out] err Error details, if any +/// @return Window handle Window nvim_tabpage_get_win(Tabpage tabpage, Error *err) { Window rv = 0; @@ -159,11 +159,11 @@ Window nvim_tabpage_get_win(Tabpage tabpage, Error *err) } } -/// Gets the tab page number +/// Gets the tabpage number /// -/// @param tabpage The tabpage handle -/// @param[out] err Details of an error that may have occurred -/// @return The tabpage number +/// @param tabpage Tabpage handle +/// @param[out] err Error details, if any +/// @return Tabpage number Integer nvim_tabpage_get_number(Tabpage tabpage, Error *err) { Integer rv = 0; @@ -176,10 +176,10 @@ Integer nvim_tabpage_get_number(Tabpage tabpage, Error *err) return tabpage_index(tab); } -/// Checks if a tab page is valid +/// Checks if a tabpage is valid /// -/// @param tabpage The tab page handle -/// @return true if the tab page is valid, false otherwise +/// @param tabpage Tabpage handle +/// @return true if the tabpage is valid, false otherwise Boolean nvim_tabpage_is_valid(Tabpage tabpage) { Error stub = ERROR_INIT; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9f3a84c88b..491375bd73 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -33,24 +33,26 @@ # include "api/vim.c.generated.h" #endif -/// Executes an ex-mode command str +/// Executes an ex-command. +/// On VimL error: Returns the VimL error; v:errmsg is not updated. /// -/// @param str The command str -/// @param[out] err Details of an error that may have occurred -void nvim_command(String str, Error *err) +/// @param command Ex-command string +/// @param[out] err Error details (including actual VimL error), if any +void nvim_command(String command, Error *err) { // Run the command try_start(); - do_cmdline_cmd(str.data); + do_cmdline_cmd(command.data); update_screen(VALID); try_end(err); } -/// Passes input keys to Neovim +/// Passes input keys to Nvim. +/// On VimL error: Does not fail, but updates v:errmsg. /// -/// @param keys to be typed -/// @param mode specifies the mapping options -/// @param escape_csi the string needs escaping for K_SPECIAL/CSI bytes +/// @param keys to be typed +/// @param mode mapping options +/// @param escape_csi If true, escape K_SPECIAL/CSI bytes in `keys` /// @see feedkeys() /// @see vim_strsave_escape_csi void nvim_feedkeys(String keys, String mode, Boolean escape_csi) @@ -102,13 +104,15 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi) } } -/// Passes input keys to Neovim. Unlike `nvim_feedkeys`, this will use a -/// lower-level input buffer and the call is not deferred. -/// This is the most reliable way to emulate real user input. +/// Passes keys to Nvim as raw user-input. +/// On VimL error: Does not fail, but updates v:errmsg. +/// +/// Unlike `nvim_feedkeys`, this uses a lower-level input buffer and the call +/// is not deferred. This is the most reliable way to emulate real user input. /// /// @param keys to be typed -/// @return The number of bytes actually written, which can be lower than -/// requested if the buffer becomes full. +/// @return Number of bytes actually written (can be fewer than +/// requested if the buffer becomes full). Integer nvim_input(String keys) FUNC_API_ASYNC { @@ -152,19 +156,19 @@ String nvim_command_output(String str, Error *err) return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT)); } -/// Evaluates the expression str using the Vim internal expression -/// evaluator (see |expression|). -/// Dictionaries and lists are recursively expanded. +/// Evaluates a VimL expression (:help expression). +/// Dictionaries and Lists are recursively expanded. +/// On VimL error: Returns a generic error; v:errmsg is not updated. /// -/// @param str The expression str -/// @param[out] err Details of an error that may have occurred -/// @return The expanded object -Object nvim_eval(String str, Error *err) +/// @param expr VimL expression string +/// @param[out] err Error details, if any +/// @return Evaluation result or expanded object +Object nvim_eval(String expr, Error *err) { Object rv = OBJECT_INIT; // Evaluate the expression try_start(); - typval_T *expr_result = eval_expr((char_u *) str.data, NULL); + typval_T *expr_result = eval_expr((char_u *)expr.data, NULL); if (!expr_result) { api_set_error(err, Exception, _("Failed to evaluate expression")); @@ -180,11 +184,12 @@ Object nvim_eval(String str, Error *err) return rv; } -/// Call the given function with the given arguments stored in an array. +/// Calls a VimL function with the given arguments. +/// On VimL error: Returns a generic error; v:errmsg is not updated. /// -/// @param fname Function to call -/// @param args Functions arguments packed in an Array -/// @param[out] err Details of an error that may have occurred +/// @param fname Function to call +/// @param args Function arguments packed in an Array +/// @param[out] err Error details, if any /// @return Result of the function call Object nvim_call_function(String fname, Array args, Error *err) { @@ -229,12 +234,12 @@ free_vim_args: return rv; } -/// Calculates the number of display cells `str` occupies, tab is counted as -/// one cell. +/// Calculates the number of display cells occupied by `text`. +/// <Tab> counts as one cell. /// -/// @param str Some text -/// @param[out] err Details of an error that may have occurred -/// @return The number of cells +/// @param text Some text +/// @param[out] err Error details, if any +/// @return Number of cells Integer nvim_strwidth(String str, Error *err) { if (str.size > INT_MAX) { @@ -245,9 +250,9 @@ Integer nvim_strwidth(String str, Error *err) return (Integer) mb_string2cells((char_u *) str.data); } -/// Gets a list of paths contained in 'runtimepath' +/// Gets the paths contained in 'runtimepath'. /// -/// @return The list of paths +/// @return List of paths ArrayOf(String) nvim_list_runtime_paths(void) { Array rv = ARRAY_DICT_INIT; @@ -285,10 +290,10 @@ ArrayOf(String) nvim_list_runtime_paths(void) return rv; } -/// Changes Vim working directory +/// Changes the global working directory. /// -/// @param dir The new working directory -/// @param[out] err Details of an error that may have occurred +/// @param dir Directory path +/// @param[out] err Error details, if any void nvim_set_current_dir(String dir, Error *err) { if (dir.size >= MAXPATHL) { @@ -315,8 +320,8 @@ void nvim_set_current_dir(String dir, Error *err) /// Gets the current line /// -/// @param[out] err Details of an error that may have occurred -/// @return The current line string +/// @param[out] err Error details, if any +/// @return Current line string String nvim_get_current_line(Error *err) { return buffer_get_line(curbuf->handle, curwin->w_cursor.lnum - 1, err); @@ -324,8 +329,8 @@ String nvim_get_current_line(Error *err) /// Sets the current line /// -/// @param line The line contents -/// @param[out] err Details of an error that may have occurred +/// @param line Line contents +/// @param[out] err Error details, if any void nvim_set_current_line(String line, Error *err) { buffer_set_line(curbuf->handle, curwin->w_cursor.lnum - 1, line, err); @@ -333,36 +338,36 @@ void nvim_set_current_line(String line, Error *err) /// Deletes the current line /// -/// @param[out] err Details of an error that may have occurred +/// @param[out] err Error details, if any void nvim_del_current_line(Error *err) { buffer_del_line(curbuf->handle, curwin->w_cursor.lnum - 1, err); } -/// Gets a global variable +/// Gets a global (g:) variable /// -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The variable value +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Variable value Object nvim_get_var(String name, Error *err) { return dict_get_value(&globvardict, name, err); } -/// Sets a global variable +/// Sets a global (g:) variable /// -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any void nvim_set_var(String name, Object value, Error *err) { dict_set_value(&globvardict, name, value, false, false, err); } -/// Removes a global variable +/// Removes a global (g:) variable /// -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred +/// @param name Variable name +/// @param[out] err Error details, if any void nvim_del_var(String name, Error *err) { dict_set_value(&globvardict, name, NIL, true, false, err); @@ -372,10 +377,10 @@ void nvim_del_var(String name, Error *err) /// /// @deprecated /// -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred -/// @return The old value or nil if there was no previous value. +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any +/// @return Old value or nil if there was no previous value. /// /// @warning It may return nil if there was no previous value /// or if previous value was `v:null`. @@ -388,19 +393,19 @@ Object vim_set_var(String name, Object value, Error *err) /// /// @deprecated /// -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The old value +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Old value Object vim_del_var(String name, Error *err) { return dict_set_value(&globvardict, name, NIL, true, true, err); } -/// Gets a vim variable +/// Gets a v: variable /// -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The variable value +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Variable value Object nvim_get_vvar(String name, Error *err) { return dict_get_value(&vimvardict, name, err); @@ -408,9 +413,9 @@ Object nvim_get_vvar(String name, Error *err) /// Gets an option value string /// -/// @param name The option name -/// @param[out] err Details of an error that may have occurred -/// @return The option value +/// @param name Option name +/// @param[out] err Error details, if any +/// @return Option value Object nvim_get_option(String name, Error *err) { return get_option_from(NULL, SREQ_GLOBAL, name, err); @@ -418,9 +423,9 @@ Object nvim_get_option(String name, Error *err) /// Sets an option value /// -/// @param name The option name -/// @param value The new option value -/// @param[out] err Details of an error that may have occurred +/// @param name Option name +/// @param value New option value +/// @param[out] err Error details, if any void nvim_set_option(String name, Object value, Error *err) { set_option_to(NULL, SREQ_GLOBAL, name, value, err); @@ -428,7 +433,7 @@ void nvim_set_option(String name, Object value, Error *err) /// Writes a message to vim output buffer /// -/// @param str The message +/// @param str Message void nvim_out_write(String str) { write_msg(str, false); @@ -436,16 +441,17 @@ void nvim_out_write(String str) /// Writes a message to vim error buffer /// -/// @param str The message +/// @param str Message void nvim_err_write(String str) { write_msg(str, true); } -/// Higher level error reporting function that ensures all str contents -/// are written by sending a trailing linefeed to `nvim_err_write` +/// Writes a message to vim error buffer. Appends a linefeed to ensure all +/// contents are written. /// -/// @param str The message +/// @param str Message +/// @see nvim_err_write() void nvim_err_writeln(String str) { nvim_err_write(str); @@ -454,7 +460,7 @@ void nvim_err_writeln(String str) /// Gets the current list of buffer handles /// -/// @return The number of buffers +/// @return List of buffer handles ArrayOf(Buffer) nvim_list_bufs(void) { Array rv = ARRAY_DICT_INIT; @@ -475,7 +481,7 @@ ArrayOf(Buffer) nvim_list_bufs(void) /// Gets the current buffer /// -/// @reqturn The buffer handle +/// @return Buffer handle Buffer nvim_get_current_buf(void) { return curbuf->handle; @@ -483,8 +489,8 @@ Buffer nvim_get_current_buf(void) /// Sets the current buffer /// -/// @param id The buffer handle -/// @param[out] err Details of an error that may have occurred +/// @param id Buffer handle +/// @param[out] err Error details, if any void nvim_set_current_buf(Buffer buffer, Error *err) { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -505,7 +511,7 @@ void nvim_set_current_buf(Buffer buffer, Error *err) /// Gets the current list of window handles /// -/// @return The number of windows +/// @return List of window handles ArrayOf(Window) nvim_list_wins(void) { Array rv = ARRAY_DICT_INIT; @@ -526,7 +532,7 @@ ArrayOf(Window) nvim_list_wins(void) /// Gets the current window /// -/// @return The window handle +/// @return Window handle Window nvim_get_current_win(void) { return curwin->handle; @@ -534,7 +540,7 @@ Window nvim_get_current_win(void) /// Sets the current window /// -/// @param handle The window handle +/// @param handle Window handle void nvim_set_current_win(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -555,7 +561,7 @@ void nvim_set_current_win(Window window, Error *err) /// Gets the current list of tabpage handles /// -/// @return The number of tab pages +/// @return List of tabpage handles ArrayOf(Tabpage) nvim_list_tabpages(void) { Array rv = ARRAY_DICT_INIT; @@ -574,18 +580,18 @@ ArrayOf(Tabpage) nvim_list_tabpages(void) return rv; } -/// Gets the current tab page +/// Gets the current tabpage /// -/// @return The tab page handle +/// @return Tabpage handle Tabpage nvim_get_current_tabpage(void) { return curtab->handle; } -/// Sets the current tab page +/// Sets the current tabpage /// -/// @param handle The tab page handle -/// @param[out] err Details of an error that may have occurred +/// @param handle Tabpage handle +/// @param[out] err Error details, if any void nvim_set_current_tabpage(Tabpage tabpage, Error *err) { tabpage_T *tp = find_tab_by_handle(tabpage, err); @@ -606,8 +612,8 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err) /// Subscribes to event broadcasts /// -/// @param channel_id The channel id (passed automatically by the dispatcher) -/// @param event The event type string +/// @param channel_id Channel id (passed automatically by the dispatcher) +/// @param event Event type string void nvim_subscribe(uint64_t channel_id, String event) FUNC_API_NOEVAL { @@ -620,8 +626,8 @@ void nvim_subscribe(uint64_t channel_id, String event) /// Unsubscribes to event broadcasts /// -/// @param channel_id The channel id (passed automatically by the dispatcher) -/// @param event The event type string +/// @param channel_id Channel id (passed automatically by the dispatcher) +/// @param event Event type string void nvim_unsubscribe(uint64_t channel_id, String event) FUNC_API_NOEVAL { @@ -756,9 +762,8 @@ validation_error: /// and flushed after each newline. Incomplete lines are kept for writing /// later. /// -/// @param message The message to write -/// @param to_err true if it should be treated as an error message (use -/// `emsg` instead of `msg` to print each line) +/// @param message Message to write +/// @param to_err true: message is an error (uses `emsg` instead of `msg`) static void write_msg(String message, bool to_err) { static size_t out_pos = 0, err_pos = 0; diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 382f65e7d9..ef881fa0eb 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -15,9 +15,9 @@ /// Gets the current buffer in a window /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return The buffer handle +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return Buffer handle Buffer nvim_win_get_buf(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -31,9 +31,9 @@ Buffer nvim_win_get_buf(Window window, Error *err) /// Gets the cursor position in the window /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return the (row, col) tuple +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return (row, col) tuple ArrayOf(Integer, 2) nvim_win_get_cursor(Window window, Error *err) { Array rv = ARRAY_DICT_INIT; @@ -49,9 +49,9 @@ ArrayOf(Integer, 2) nvim_win_get_cursor(Window window, Error *err) /// Sets the cursor position in the window /// -/// @param window The window handle -/// @param pos the (row, col) tuple representing the new position -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param pos (row, col) tuple representing the new position +/// @param[out] err Error details, if any void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -95,9 +95,9 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err) /// Gets the window height /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return the height in rows +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return Height as a count of rows Integer nvim_win_get_height(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -112,9 +112,9 @@ Integer nvim_win_get_height(Window window, Error *err) /// Sets the window height. This will only succeed if the screen is split /// horizontally. /// -/// @param window The window handle -/// @param height the new height in rows -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param height Height as a count of rows +/// @param[out] err Error details, if any void nvim_win_set_height(Window window, Integer height, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -138,9 +138,9 @@ void nvim_win_set_height(Window window, Integer height, Error *err) /// Gets the window width /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return the width in columns +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return Width as a count of columns Integer nvim_win_get_width(Window window, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -155,9 +155,9 @@ Integer nvim_win_get_width(Window window, Error *err) /// Sets the window width. This will only succeed if the screen is split /// vertically. /// -/// @param window The window handle -/// @param width the new width in columns -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param width Width as a count of columns +/// @param[out] err Error details, if any void nvim_win_set_width(Window window, Integer width, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -181,10 +181,10 @@ void nvim_win_set_width(Window window, Integer width, Error *err) /// Gets a window-scoped (w:) variable /// -/// @param window The window handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The variable value +/// @param window Window handle +/// @param name Variable name +/// @param[out] err Error details, if any +/// @return Variable value Object nvim_win_get_var(Window window, String name, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -198,10 +198,10 @@ Object nvim_win_get_var(Window window, String name, Error *err) /// Sets a window-scoped (w:) variable /// -/// @param window The window handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any void nvim_win_set_var(Window window, String name, Object value, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -215,9 +215,9 @@ void nvim_win_set_var(Window window, String name, Object value, Error *err) /// Removes a window-scoped (w:) variable /// -/// @param window The window handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param name Variable name +/// @param[out] err Error details, if any void nvim_win_del_var(Window window, String name, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -233,11 +233,11 @@ void nvim_win_del_var(Window window, String name, Error *err) /// /// @deprecated /// -/// @param window The window handle -/// @param name The variable name -/// @param value The variable value -/// @param[out] err Details of an error that may have occurred -/// @return The old value or nil if there was no previous value. +/// @param window Window handle +/// @param name Variable name +/// @param value Variable value +/// @param[out] err Error details, if any +/// @return Old value or nil if there was no previous value. /// /// @warning It may return nil if there was no previous value /// or if previous value was `v:null`. @@ -256,10 +256,10 @@ Object window_set_var(Window window, String name, Object value, Error *err) /// /// @deprecated /// -/// @param window The window handle -/// @param name The variable name -/// @param[out] err Details of an error that may have occurred -/// @return The old value +/// @param window Window handle +/// @param name variable name +/// @param[out] err Error details, if any +/// @return Old value Object window_del_var(Window window, String name, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -273,10 +273,10 @@ Object window_del_var(Window window, String name, Error *err) /// Gets a window option value /// -/// @param window The window handle -/// @param name The option name -/// @param[out] err Details of an error that may have occurred -/// @return The option value +/// @param window Window handle +/// @param name Option name +/// @param[out] err Error details, if any +/// @return Option value Object nvim_win_get_option(Window window, String name, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -291,10 +291,10 @@ Object nvim_win_get_option(Window window, String name, Error *err) /// Sets a window option value. Passing 'nil' as value deletes the option(only /// works if there's a global fallback) /// -/// @param window The window handle -/// @param name The option name -/// @param value The option value -/// @param[out] err Details of an error that may have occurred +/// @param window Window handle +/// @param name Option name +/// @param value Option value +/// @param[out] err Error details, if any void nvim_win_set_option(Window window, String name, Object value, Error *err) { win_T *win = find_window_by_handle(window, err); @@ -308,9 +308,9 @@ void nvim_win_set_option(Window window, String name, Object value, Error *err) /// Gets the window position in display cells. First position is zero. /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return The (row, col) tuple with the window position +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return (row, col) tuple with the window position ArrayOf(Integer, 2) nvim_win_get_position(Window window, Error *err) { Array rv = ARRAY_DICT_INIT; @@ -324,11 +324,11 @@ ArrayOf(Integer, 2) nvim_win_get_position(Window window, Error *err) return rv; } -/// Gets the window tab page +/// Gets the window tabpage /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return The tab page that contains the window +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return Tabpage that contains the window Tabpage nvim_win_get_tabpage(Window window, Error *err) { Tabpage rv = 0; @@ -343,9 +343,9 @@ Tabpage nvim_win_get_tabpage(Window window, Error *err) /// Gets the window number /// -/// @param window The window handle -/// @param[out] err Details of an error that may have occurred -/// @return The window number +/// @param window Window handle +/// @param[out] err Error details, if any +/// @return Window number Integer nvim_win_get_number(Window window, Error *err) { Integer rv = 0; @@ -363,7 +363,7 @@ Integer nvim_win_get_number(Window window, Error *err) /// Checks if a window is valid /// -/// @param window The window handle +/// @param window Window handle /// @return true if the window is valid, false otherwise Boolean nvim_win_is_valid(Window window) { diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index e6a7950d53..a66fdc1304 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -4523,7 +4523,7 @@ chk_modeline ( char_u *e; char_u *linecopy; /* local copy of any modeline found */ int prev; - int vers; + intmax_t vers; int end; int retval = OK; char_u *save_sourcing_name; @@ -4542,7 +4542,10 @@ chk_modeline ( e = s + 4; else e = s + 3; - vers = getdigits_int(&e); + if (getdigits_safe(&e, &vers) != OK) { + continue; + } + if (*e == ':' && (s[0] != 'V' || STRNCMP(skipwhite(e + 1), "set", 3) == 0) @@ -4550,8 +4553,9 @@ chk_modeline ( || (VIM_VERSION_100 >= vers && isdigit(s[3])) || (VIM_VERSION_100 < vers && s[3] == '<') || (VIM_VERSION_100 > vers && s[3] == '>') - || (VIM_VERSION_100 == vers && s[3] == '='))) + || (VIM_VERSION_100 == vers && s[3] == '='))) { break; + } } } prev = *s; diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 78f5d96fc7..61c5b10808 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1732,6 +1732,26 @@ char_u* skiptowhite_esc(char_u *p) { return p; } +/// Get a number from a string and skip over it, signalling overflows +/// +/// @param[out] pp A pointer to a pointer to char_u. +/// It will be advanced past the read number. +/// @param[out] nr Number read from the string. +/// +/// @return OK on success, FAIL on error/overflow +int getdigits_safe(char_u **pp, intmax_t *nr) +{ + errno = 0; + *nr = strtoimax((char *)(*pp), (char **)pp, 10); + + if ((*nr == INTMAX_MIN || *nr == INTMAX_MAX) + && errno == ERANGE) { + return FAIL; + } + + return OK; +} + /// Get a number from a string and skip over it. /// /// @param[out] pp A pointer to a pointer to char_u. @@ -1740,17 +1760,16 @@ char_u* skiptowhite_esc(char_u *p) { /// @return Number read from the string. intmax_t getdigits(char_u **pp) { - errno = 0; - intmax_t number = strtoimax((char *)*pp, (char **)pp, 10); - if (number == INTMAX_MAX || number == INTMAX_MIN) { - assert(errno != ERANGE); - } + intmax_t number; + int ret = getdigits_safe(pp, &number); + + (void)ret; // Avoid "unused variable" warning in Release build + assert(ret == OK); + return number; } -/// Get an int number from a string. -/// -/// A getdigits wrapper restricted to int values. +/// Get an int number from a string. Like getdigits(), but restricted to `int`. int getdigits_int(char_u **pp) { intmax_t number = getdigits(pp); @@ -1760,9 +1779,7 @@ int getdigits_int(char_u **pp) return (int)number; } -/// Get a long number from a string. -/// -/// A getdigits wrapper restricted to long values. +/// Get a long number from a string. Like getdigits(), but restricted to `long`. long getdigits_long(char_u **pp) { intmax_t number = getdigits(pp); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 76f33e7d8c..512555eac1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10524,16 +10524,10 @@ static void f_glob2regpat(typval_T *argvars, typval_T *rettv, FunPtr fptr) : file_pat_to_reg_pat(pat, NULL, NULL, false); } -/* - * "has()" function - */ +/// "has()" function static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - int i; - char_u *name; - int n = FALSE; - static char *(has_list[]) = - { + static char *(has_list[]) = { #ifdef UNIX "unix", #endif @@ -10646,36 +10640,42 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) NULL }; - name = get_tv_string(&argvars[0]); - for (i = 0; has_list[i] != NULL; ++i) + bool n = false; + char *name = (char *)get_tv_string(&argvars[0]); + + for (int i = 0; has_list[i] != NULL; i++) { if (STRICMP(name, has_list[i]) == 0) { - n = TRUE; + n = true; break; } + } - if (n == FALSE) { + if (!n) { if (STRNICMP(name, "patch", 5) == 0) { if (name[5] == '-' - && STRLEN(name) > 11 + && strlen(name) > 11 && ascii_isdigit(name[6]) && ascii_isdigit(name[8]) && ascii_isdigit(name[10])) { - int major = atoi((char *)name + 6); - int minor = atoi((char *)name + 8); + int major = atoi(name + 6); + int minor = atoi(name + 8); // Expect "patch-9.9.01234". n = (major < VIM_VERSION_MAJOR || (major == VIM_VERSION_MAJOR && (minor < VIM_VERSION_MINOR || (minor == VIM_VERSION_MINOR - && has_patch(atoi((char *)name + 10)))))); + && has_vim_patch(atoi(name + 10)))))); } else { - n = has_patch(atoi((char *)name + 5)); + n = has_vim_patch(atoi(name + 5)); } + } else if (STRNICMP(name, "nvim-", 5) == 0) { + // Expect "nvim-x.y.z" + n = has_nvim_version(name + 5); } else if (STRICMP(name, "vim_starting") == 0) { n = (starting != 0); } else if (STRICMP(name, "multi_byte_encoding") == 0) { - n = has_mbyte; + n = has_mbyte != 0; #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) } else if (STRICMP(name, "iconv") == 0) { n = iconv_enabled(false); @@ -10685,8 +10685,8 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - if (n == FALSE && eval_has_provider((char *)name)) { - n = TRUE; + if (!n && eval_has_provider(name)) { + n = true; } rettv->vval.v_number = n; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index f19a9206a4..17780c58e4 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2370,10 +2370,12 @@ do_ecmd ( if (p_ur < 0 || curbuf->b_ml.ml_line_count <= p_ur) { /* Save all the text, so that the reload can be undone. * Sync first so that this is a separate undo-able action. */ - u_sync(FALSE); - if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, TRUE) - == FAIL) + u_sync(false); + if (u_savecommon(0, curbuf->b_ml.ml_line_count + 1, 0, true) + == FAIL) { + xfree(new_name); goto theend; + } u_unchanged(curbuf); buf_freeall(curbuf, BFA_KEEP_UNDO); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index e085b973ea..fdfcd1f428 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -397,10 +397,11 @@ EXTERN char_u *p_dir; /* 'directory' */ EXTERN char_u *p_dy; /* 'display' */ EXTERN unsigned dy_flags; #ifdef IN_OPTION_C -static char *(p_dy_values[]) = {"lastline", "uhex", NULL}; +static char *(p_dy_values[]) = { "lastline", "truncate", "uhex", NULL }; #endif #define DY_LASTLINE 0x001 -#define DY_UHEX 0x002 +#define DY_TRUNCATE 0x002 +#define DY_UHEX 0x004 EXTERN int p_ed; // 'edcompatible' EXTERN bool p_emoji; // 'emoji' EXTERN char_u *p_ead; // 'eadirection' diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 47dd640e59..3e4d016fe7 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1401,7 +1401,7 @@ static void win_update(win_T *wp) && wp->w_lines[idx].wl_valid && wp->w_lines[idx].wl_lnum == lnum && lnum > wp->w_topline - && !(dy_flags & DY_LASTLINE) + && !(dy_flags & (DY_LASTLINE | DY_TRUNCATE)) && srow + wp->w_lines[idx].wl_size > wp->w_height && diff_check_fill(wp, lnum) == 0 ) { @@ -1484,10 +1484,20 @@ static void win_update(win_T *wp) /* Window ends in filler lines. */ wp->w_botline = lnum; wp->w_filler_rows = wp->w_height - srow; - } else if (dy_flags & DY_LASTLINE) { /* 'display' has "lastline" */ - /* - * Last line isn't finished: Display "@@@" at the end. - */ + } else if (dy_flags & DY_TRUNCATE) { // 'display' has "truncate" + int scr_row = wp->w_winrow + wp->w_height - 1; + + // Last line isn't finished: Display "@@@" in the last screen line. + screen_puts_len((char_u *)"@@", 2, scr_row, wp->w_wincol, + hl_attr(HLF_AT)); + + screen_fill(scr_row, scr_row + 1, + (int)wp->w_wincol + 2, (int)W_ENDCOL(wp), + '@', ' ', hl_attr(HLF_AT)); + set_empty_rows(wp, srow); + wp->w_botline = lnum; + } else if (dy_flags & DY_LASTLINE) { // 'display' has "lastline" + // Last line isn't finished: Display "@@@" at the end. screen_fill(wp->w_winrow + wp->w_height - 1, wp->w_winrow + wp->w_height, W_ENDCOL(wp) - 3, W_ENDCOL(wp), diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 6fd7603629..b49ae9da21 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5537,7 +5537,7 @@ void ex_ownsyntax(exarg_T *eap) } } -int syntax_present(win_T *win) +bool syntax_present(win_T *win) { return win->w_s->b_syn_patterns.ga_len != 0 || win->w_s->b_syn_clusters.ga_len != 0 diff --git a/src/nvim/version.c b/src/nvim/version.c index 389eefdcca..498afa9656 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -313,7 +313,7 @@ static int included_patches[] = { // 2131 NA // 2130 NA // 2129 NA - // 2128, + 2128, // 2127, // 2126, // 2125, @@ -332,7 +332,7 @@ static int included_patches[] = { 2112, // 2111, // 2110, - // 2109, + 2109, // 2108 NA // 2107, // 2106, @@ -2457,20 +2457,61 @@ static char *(extra_patches[]) = { NULL }; -/// Checks whether patch `n` has been included. +/// Compares a version string to the current Nvim version. /// -/// @param n The patch number. +/// @param version Version string like "1.3.42" /// -/// @return TRUE if patch "n" has been included. -int has_patch(int n) +/// @return true if Nvim is at or above the version. +bool has_nvim_version(char *version_str) + FUNC_ATTR_NONNULL_ALL { - int i; - for (i = 0; included_patches[i] != 0; ++i) { + char *p = version_str; + int major = 0; + int minor = 0; + int patch = 0; + + if (!ascii_isdigit(*p)) { + return false; + } + major = atoi(p); + p = strchr(p, '.'); // Find the next dot. + + if (p) { + p++; // Advance past the dot. + if (!ascii_isdigit(*p)) { + return false; + } + minor = atoi(p); + p = strchr(p, '.'); + if (p) { + p++; + if (!ascii_isdigit(*p)) { + return false; + } + patch = atoi(p); + } + } + + return (major < NVIM_VERSION_MAJOR + || (major == NVIM_VERSION_MAJOR + && (minor < NVIM_VERSION_MINOR + || (minor == NVIM_VERSION_MINOR + && patch <= NVIM_VERSION_PATCH)))); +} + +/// Checks whether a Vim patch has been included. +/// +/// @param n Patch number. +/// +/// @return true if patch `n` has been included. +bool has_vim_patch(int n) +{ + for (int i = 0; included_patches[i] != 0; i++) { if (included_patches[i] == n) { - return TRUE; + return true; } } - return FALSE; + return false; } void ex_version(exarg_T *eap) @@ -2529,7 +2570,11 @@ static void list_features(void) } } else { while (msg_col % width) { + int old_msg_col = msg_col; msg_putchar(' '); + if (old_msg_col == msg_col) { + break; // XXX: Avoid infinite loop. + } } } } else { diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 71ec213b97..3d3a2bb046 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -1,4 +1,3 @@ --- Sanity checks for buffer_* API calls via msgpack-rpc local helpers = require('test.functional.helpers')(after_each) local clear, nvim, buffer = helpers.clear, helpers.nvim, helpers.buffer local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq @@ -6,7 +5,7 @@ local curbufmeths, ok = helpers.curbufmeths, helpers.ok local funcs, request = helpers.funcs, helpers.request local NIL = helpers.NIL -describe('buffer_* functions', function() +describe('api/buf', function() before_each(clear) -- access deprecated functions diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 88e8c60560..78639d7ed7 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -1,4 +1,3 @@ --- Tests for nvim notifications local helpers = require('test.functional.helpers')(after_each) local eq, clear, eval, execute, nvim, next_message = helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.nvim, diff --git a/test/functional/api/tabpage_spec.lua b/test/functional/api/tabpage_spec.lua index 90940e9577..e10f30085f 100644 --- a/test/functional/api/tabpage_spec.lua +++ b/test/functional/api/tabpage_spec.lua @@ -1,4 +1,3 @@ --- Sanity checks for tabpage_* API calls via msgpack-rpc local helpers = require('test.functional.helpers')(after_each) local clear, nvim, tabpage, curtab, eq, ok = helpers.clear, helpers.nvim, helpers.tabpage, helpers.curtab, helpers.eq, @@ -8,7 +7,7 @@ local funcs = helpers.funcs local request = helpers.request local NIL = helpers.NIL -describe('tabpage_* functions', function() +describe('api/tabpage', function() before_each(clear) describe('list_wins and get_win', function() diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 724d9f1b57..ce6c52e334 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1,4 +1,3 @@ --- Sanity checks for vim_* API calls via msgpack-rpc local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local NIL = helpers.NIL @@ -9,10 +8,10 @@ local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request -describe('vim_* functions', function() +describe('api', function() before_each(clear) - describe('command', function() + describe('nvim_command', function() it('works', function() local fname = helpers.tmpname() nvim('command', 'new') @@ -29,9 +28,18 @@ describe('vim_* functions', function() f:close() os.remove(fname) end) + + it("VimL error: fails (VimL error), does NOT update v:errmsg", function() + -- Most API methods return generic errors (or no error) if a VimL + -- expression fails; nvim_command returns the VimL error details. + local status, rv = pcall(nvim, "command", "bogus_command") + eq(false, status) -- nvim_command() failed. + eq("E492:", string.match(rv, "E%d*:")) -- VimL error was returned. + eq("", nvim("eval", "v:errmsg")) -- v:errmsg was not updated. + end) end) - describe('eval', function() + describe('nvim_eval', function() it('works', function() nvim('command', 'let g:v1 = "a"') nvim('command', 'let g:v2 = [1, 2, {"v3": 3}]') @@ -46,18 +54,41 @@ describe('vim_* functions', function() it('works under deprecated name', function() eq(2, request("vim_eval", "1+1")) end) + + it("VimL error: fails (generic error), does NOT update v:errmsg", function() + local status, rv = pcall(nvim, "eval", "bogus expression") + eq(false, status) -- nvim_eval() failed. + ok(nil ~= string.find(rv, "Failed to evaluate expression")) + eq("", nvim("eval", "v:errmsg")) -- v:errmsg was not updated. + end) end) - describe('call_function', function() + describe('nvim_call_function', function() it('works', function() nvim('call_function', 'setqflist', {{{ filename = 'something', lnum = 17}}, 'r'}) eq(17, nvim('call_function', 'getqflist', {})[1].lnum) eq(17, nvim('call_function', 'eval', {17})) eq('foo', nvim('call_function', 'simplify', {'this/./is//redundant/../../../foo'})) end) + + it("VimL error: fails (generic error), does NOT update v:errmsg", function() + local status, rv = pcall(nvim, "call_function", "bogus function", {"arg1"}) + eq(false, status) -- nvim_call_function() failed. + ok(nil ~= string.find(rv, "Error calling function")) + eq("", nvim("eval", "v:errmsg")) -- v:errmsg was not updated. + end) + end) + + describe('nvim_input', function() + it("VimL error: does NOT fail, updates v:errmsg", function() + local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>") + local v_errnum = string.match(nvim("eval", "v:errmsg"), "E%d*:") + eq(true, status) -- nvim_input() did not fail. + eq("E117:", v_errnum) -- v:errmsg was updated. + end) end) - describe('strwidth', function() + describe('nvim_strwidth', function() it('works', function() eq(3, nvim('strwidth', 'abc')) -- 6 + (neovim) @@ -70,7 +101,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_current_line', function() + describe('nvim_get_current_line, nvim_set_current_line', function() it('works', function() eq('', nvim('get_current_line')) nvim('set_current_line', 'abc') @@ -78,7 +109,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set,del}_var', function() + describe('nvim_get_var, nvim_set_var, nvim_del_var', function() it('works', function() nvim('set_var', 'lua', {1, 2, {['3'] = 1}}) eq({1, 2, {['3'] = 1}}, nvim('get_var', 'lua')) @@ -109,7 +140,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_option', function() + describe('nvim_get_option, nvim_set_option', function() it('works', function() ok(nvim('get_option', 'equalalways')) nvim('set_option', 'equalalways', false) @@ -117,7 +148,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_current_buf and list_bufs', function() + describe('nvim_{get,set}_current_buf, nvim_list_bufs', function() it('works', function() eq(1, #nvim('list_bufs')) eq(nvim('list_bufs')[1], nvim('get_current_buf')) @@ -129,7 +160,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_current_win and list_wins', function() + describe('nvim_{get,set}_current_win, nvim_list_wins', function() it('works', function() eq(1, #nvim('list_wins')) eq(nvim('list_wins')[1], nvim('get_current_win')) @@ -142,7 +173,7 @@ describe('vim_* functions', function() end) end) - describe('{get,set}_current_tabpage and list_tabpages', function() + describe('nvim_{get,set}_current_tabpage, nvim_list_tabpages', function() it('works', function() eq(1, #nvim('list_tabpages')) eq(nvim('list_tabpages')[1], nvim('get_current_tabpage')) @@ -161,7 +192,7 @@ describe('vim_* functions', function() end) end) - describe('replace_termcodes', function() + describe('nvim_replace_termcodes', function() it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function() eq('\128\254X', helpers.nvim('replace_termcodes', '\128', true, true, true)) end) @@ -183,7 +214,7 @@ describe('vim_* functions', function() end) end) - describe('feedkeys', function() + describe('nvim_feedkeys', function() it('CSI escaping', function() local function on_setup() -- notice the special char(…) \xe2\80\xa6 @@ -210,7 +241,7 @@ describe('vim_* functions', function() end) end) - describe('err_write', function() + describe('nvim_err_write', function() local screen before_each(function() @@ -298,7 +329,7 @@ describe('vim_* functions', function() end) end) - describe('call_atomic', function() + describe('nvim_call_atomic', function() it('works', function() meths.buf_set_lines(0, 0, -1, true, {'first'}) local req = { diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index bf2bf55fb3..465bda6bc9 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -1,4 +1,3 @@ --- Sanity checks for window_* API calls via msgpack-rpc local helpers = require('test.functional.helpers')(after_each) local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq, ok, feed, insert, eval = helpers.clear, helpers.nvim, helpers.curbuf, @@ -29,7 +28,7 @@ local function is_visible(str) return false end -describe('window_* functions', function() +describe('api/win', function() before_each(clear) describe('get_buf', function() diff --git a/test/functional/eval/has_spec.lua b/test/functional/eval/has_spec.lua new file mode 100644 index 0000000000..97b3b0e620 --- /dev/null +++ b/test/functional/eval/has_spec.lua @@ -0,0 +1,52 @@ +local helpers = require('test.functional.helpers')(after_each) +local eq = helpers.eq +local clear = helpers.clear +local funcs = helpers.funcs + +describe('has()', function() + before_each(clear) + + it('"nvim-x.y.z"', function() + eq(0, funcs.has("nvim-")) + eq(0, funcs.has("nvim- ")) + eq(0, funcs.has("nvim- \t ")) + eq(0, funcs.has("nvim-0. 1. 1")) + eq(0, funcs.has("nvim-0. 1.1")) + eq(0, funcs.has("nvim-0.1. 1")) + eq(0, funcs.has("nvim-a")) + eq(0, funcs.has("nvim-a.b.c")) + eq(0, funcs.has("nvim-0.b.c")) + eq(0, funcs.has("nvim-0.0.c")) + eq(0, funcs.has("nvim-0.b.0")) + eq(0, funcs.has("nvim-a.b.0")) + eq(0, funcs.has("nvim-.0.0.0")) + eq(0, funcs.has("nvim-.0")) + eq(0, funcs.has("nvim-0.")) + eq(0, funcs.has("nvim-0..")) + eq(0, funcs.has("nvim-.")) + eq(0, funcs.has("nvim-..")) + eq(0, funcs.has("nvim-...")) + eq(0, funcs.has("nvim-42")) + eq(0, funcs.has("nvim-9999")) + eq(0, funcs.has("nvim-99.001.05")) + + eq(1, funcs.has("nvim")) + eq(1, funcs.has("nvim-0")) + eq(1, funcs.has("nvim-0.1")) + eq(1, funcs.has("nvim-0.0.0")) + eq(1, funcs.has("nvim-0.1.1.")) + eq(1, funcs.has("nvim-0.1.1.abc")) + eq(1, funcs.has("nvim-0.1.1..")) + eq(1, funcs.has("nvim-0.1.1.. ..")) + eq(1, funcs.has("nvim-0.1.1.... ")) + eq(1, funcs.has("nvim-0.0.0")) + eq(1, funcs.has("nvim-0.0.1")) + eq(1, funcs.has("nvim-0.1.0")) + eq(1, funcs.has("nvim-0.1.1")) + eq(1, funcs.has("nvim-0.1.5")) + eq(1, funcs.has("nvim-0000.001.05")) + eq(1, funcs.has("nvim-0.01.005")) + eq(1, funcs.has("nvim-00.001.05")) + end) + +end) diff --git a/test/functional/eval/modeline_spec.lua b/test/functional/eval/modeline_spec.lua new file mode 100644 index 0000000000..0be7210a76 --- /dev/null +++ b/test/functional/eval/modeline_spec.lua @@ -0,0 +1,19 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, execute, write_file = helpers.clear, helpers.execute, helpers.write_file +local eq, eval = helpers.eq, helpers.eval + +describe("modeline", function() + local tempfile = helpers.tmpname() + before_each(clear) + + after_each(function() + os.remove(tempfile) + end) + + it('does not crash with a large version number', function() + write_file(tempfile, 'vim100000000000000000000000') + execute('e! ' .. tempfile) + + eq(2, eval('1+1')) -- Still alive? + end) +end) diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index b8f1f87f30..6393477260 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, eval, feed, nvim = - helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim +local eq, clear, eval, execute, feed, nvim = + helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.feed, + helpers.nvim local Screen = require('test.functional.ui.screen') @@ -117,8 +118,12 @@ describe('system()', function() eq("echoed", eval('system("echo -n echoed")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("echo -n echoed &")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("echo -n echoed &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) @@ -128,8 +133,12 @@ describe('system()', function() eq("input", eval('system("cat -", "input")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("cat - &", "input")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("cat - &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 325f41e506..ff62b4de86 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,11 +1,13 @@ require('coxpcall') local lfs = require('lfs') -local ChildProcessStream = require('nvim.child_process_stream') -local SocketStream = require('nvim.socket_stream') -local TcpStream = require('nvim.tcp_stream') -local Session = require('nvim.session') local global_helpers = require('test.helpers') +-- nvim client: Found in .deps/usr/share/lua/<version>/nvim/ if "bundled". +local Session = require('nvim.session') +local TcpStream = require('nvim.tcp_stream') +local SocketStream = require('nvim.socket_stream') +local ChildProcessStream = require('nvim.child_process_stream') + local check_logs = global_helpers.check_logs local neq = global_helpers.neq local eq = global_helpers.eq @@ -134,10 +136,14 @@ local function stop() session:stop() end +-- Executes an ex-command. VimL errors manifest as client (lua) errors, but +-- v:errmsg will not be updated. local function nvim_command(cmd) request('nvim_command', cmd) end +-- Evaluates a VimL expression. +-- Fails on VimL error, but does not update v:errmsg. local function nvim_eval(expr) return request('nvim_eval', expr) end @@ -158,10 +164,14 @@ local os_name = (function() end) end)() +-- Executes a VimL function. +-- Fails on VimL error, but does not update v:errmsg. local function nvim_call(name, ...) return request('nvim_call_function', name, {...}) end +-- Sends user input to Nvim. +-- Does not fail on VimL error, but v:errmsg will be updated. local function nvim_feed(input) while #input > 0 do local written = request('nvim_input', input) @@ -279,6 +289,8 @@ local function insert(...) nvim_feed('<ESC>') end +-- Executes an ex-command by user input. Because nvim_input() is used, VimL +-- errors will not manifest as client (lua) errors. Use command() for that. local function execute(...) for _, v in ipairs({...}) do if v:sub(1, 1) ~= '/' then diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 4bcaab009f..5b5e5f9ace 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -47,7 +47,7 @@ describe('health.vim', function() helpers.expect([[ health#success1#check - ================================================================================ + ======================================================================== ## report 1 - SUCCESS: everything is fine @@ -55,7 +55,7 @@ describe('health.vim', function() - SUCCESS: nothing to see here health#success2#check - ================================================================================ + ======================================================================== ## another 1 - SUCCESS: ok ]]) @@ -66,7 +66,7 @@ describe('health.vim', function() helpers.expect([[ health#broken#check - ================================================================================ + ======================================================================== - ERROR: Failed to run healthcheck for "broken" plugin. Exception: caused an error ]]) @@ -77,7 +77,7 @@ describe('health.vim', function() helpers.expect([[ health#non_existent_healthcheck#check - ================================================================================ + ======================================================================== - ERROR: No healthcheck found for "non_existent_healthcheck" plugin. ]]) end) |