diff options
28 files changed, 1088 insertions, 628 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index adf23c19b0..ecc8689cf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -479,3 +479,15 @@ if(LUACHECK_PRG) -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test -P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake) endif() + +set(CPACK_PACKAGE_NAME "Neovim") +set(CPACK_PACKAGE_VENDOR "neovim.io") +set(CPACK_PACKAGE_VERSION ${NVIM_VERSION_MEDIUM}) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "Neovim") +# Set toplevel directory/installer name as Neovim +set(CPACK_PACKAGE_FILE_NAME "Neovim") +set(CPACK_TOPLEVEL_TAG "Neovim") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") +set(CPACK_NSIS_MODIFY_PATH ON) +set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) +include(CPack) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 89b4825f5b..38ac74f0af 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2015 Jan 29 +*eval.txt* For Vim version 7.4. Last change: 2015 Nov 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1375,6 +1375,15 @@ v:errmsg Last given error message. It's allowed to set this variable. : ... handle error < "errmsg" also works, for backwards compatibility. + *v:errors* *errors-variable* +v:errors Errors found by assert functions, such as |assert_true()|. + This is a list of strings. + The assert functions append an item when an assert fails. + To remove old results make it empty: > + :let v:errors = [] +< If v:errors is set to anything but a list it is made an empty + list by the assert function. + *v:exception* *exception-variable* v:exception The value of the exception most recently caught and not finished. See also |v:throwpoint| and |throw-variables|. @@ -1728,10 +1737,13 @@ append( {lnum}, {string}) Number append {string} below line {lnum} append( {lnum}, {list}) Number append lines {list} below line {lnum} argc() Number number of files in the argument list argidx() Number current index in the argument list -arglistid( [{winnr}, [ {tabnr}]]) +arglistid( [{winnr} [, {tabnr}]]) Number argument list id argv( {nr}) String {nr} entry of the argument list argv( ) List the argument list +assert_equal( {exp}, {act} [, {msg}]) none assert that {exp} equals {act} +assert_false( {actual} [, {msg}]) none assert that {actual} is false +assert_true( {actual} [, {msg}]) none assert that {actual} is true asin( {expr}) Float arc sine of {expr} atan( {expr}) Float arc tangent of {expr} atan2( {expr}, {expr}) Float arc tangent of {expr1} / {expr2} @@ -2161,6 +2173,37 @@ argv([{nr}]) The result is the {nr}th file in the argument list of the < Without the {nr} argument a |List| with the whole |arglist| is returned. + *assert_equal()* +assert_equal({expected}, {actual}, [, {msg}]) + When {expected} and {actual} are not equal an error message is + added to |v:errors|. + There is no automatic conversion, the String "4" is different + from the Number 4. And the number 4 is different from the + Float 4.0. The value of 'ignorecase' is not used here, case + always matters. + When {msg} is omitted an error in the form "Expected + {expected} but got {actual}" is produced. + Example: > + assert_equal('foo', 'bar') +< Will result in a string to be added to |v:errors|: + test.vim line 12: Expected 'foo' but got 'bar' ~ + +assert_false({actual}, [, {msg}]) *assert_false()* + When {actual} is not false an error message is added to + |v:errors|, like with |assert_equal()|.. + A value is false when it is zero. When "{actual}" is not a + number the assert fails. + When {msg} is omitted an error in the form "Expected False but + got {actual}" is produced. + +assert_true({actual}, [, {msg}]) *assert_true()* + When {actual} is not true an error message is added to + |v:errors|, like with |assert_equal()|.. + A value is true when it is a non-zeron number. When {actual} + is not a number the assert fails. + When {msg} is omitted an error in the form "Expected True but + got {actual}" is produced. + asin({expr}) *asin()* Return the arc sine of {expr} measured in radians, as a |Float| in the range of [-pi/2, pi/2]. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index fe9d9b4d62..c6b143ca0e 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 7.4. Last change: 2014 Aug 16 +*usr_41.txt* For Vim version 7.4. Last change: 2015 Nov 30 VIM USER MANUAL - by Bram Moolenaar @@ -888,6 +888,11 @@ Mappings: *mapping-functions* maparg() get rhs of a mapping wildmenumode() check if the wildmode is active +Testing: *test-functions* + assert_equal() assert that two expressions values are equal + assert_false() assert that an expression is false + assert_true() assert that an expression is true + Various: *various-functions* mode() get current editing mode visualmode() last visual mode used diff --git a/runtime/syntax/amiga.vim b/runtime/syntax/amiga.vim index e70f995f68..4ccab1950f 100644 --- a/runtime/syntax/amiga.vim +++ b/runtime/syntax/amiga.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: AmigaDos -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 11, 2006 -" Version: 6 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 7 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_AMIGA " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/csh.vim b/runtime/syntax/csh.vim index 39603fa158..a67cb09189 100644 --- a/runtime/syntax/csh.vim +++ b/runtime/syntax/csh.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: C-shell (csh) -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Version: 10 -" Last Change: Sep 11, 2006 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Version: 11 +" Last Change: Oct 23, 2014 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/dcl.vim b/runtime/syntax/dcl.vim index cf62cdf202..37bf38fe11 100644 --- a/runtime/syntax/dcl.vim +++ b/runtime/syntax/dcl.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: DCL (Digital Command Language - vms) -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 11, 2006 -" Version: 6 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 7 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_DCL " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/elmfilt.vim b/runtime/syntax/elmfilt.vim index 0afa1694cf..e7d5df22aa 100644 --- a/runtime/syntax/elmfilt.vim +++ b/runtime/syntax/elmfilt.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: Elm Filter rules -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 11, 2006 -" Version: 5 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 6 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_ELMFILT " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/exports.vim b/runtime/syntax/exports.vim index 40b4b8806d..f695dc8d21 100644 --- a/runtime/syntax/exports.vim +++ b/runtime/syntax/exports.vim @@ -1,10 +1,10 @@ " Vim syntax file " Language: exports -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 06, 2005 -" Version: 4 +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 5 " Notes: This file includes both SysV and BSD 'isms -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_EXPORTS " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/lisp.vim b/runtime/syntax/lisp.vim index 74ec20bb4e..2528f4f9b1 100644 --- a/runtime/syntax/lisp.vim +++ b/runtime/syntax/lisp.vim @@ -1,28 +1,23 @@ " Vim syntax file " Language: Lisp -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Nov 16, 2010 -" Version: 22 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 06, 2014 +" Version: 23 +" 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 the HyperSpec +" Thanks to F Xavier Noria for a list of 978 Common Lisp symbols taken from HyperSpec " Clisp additions courtesy of http://clisp.cvs.sourceforge.net/*checkout*/clisp/clisp/emacs/lisp.vim " --------------------------------------------------------------------- " Load Once: {{{1 -" For vim-version 5.x: Clear all syntax items -" For vim-version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish +if exists("b:current_syntax") + finish endif -if version >= 600 - setlocal iskeyword=38,42,43,45,47-58,60-62,64-90,97-122,_ +if exists("g:lisp_isk") + exe "setl isk=".g:lisp_isk else - set iskeyword=38,42,43,45,47-58,60-62,64-90,97-122,_ + setl isk=38,42,43,45,47-58,60-62,64-90,97-122,_ endif if exists("g:lispsyntax_ignorecase") || exists("g:lispsyntax_clisp") diff --git a/runtime/syntax/maple.vim b/runtime/syntax/maple.vim index b6e4ae9243..9c94643836 100644 --- a/runtime/syntax/maple.vim +++ b/runtime/syntax/maple.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: Maple V (based on release 4) -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Jan 05, 2010 -" Version: 10 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 11 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_MAPLE " " Package Function Selection: {{{1 " Because there are a lot of packages, and because of the potential for namespace diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 5ca5bc641a..f3218ffcb2 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,10 +2,10 @@ " 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: Mar 20, 2014 -" Version: 132 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax -" For options and settings, please use: :help ft-sh-syntax +" Last Change: Jan 08, 2015 +" Version: 134 +" 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 ?ric Brunet (eric.brunet@ens.fr) " For version 5.x: Clear all syntax items {{{1 @@ -17,7 +17,7 @@ elseif exists("b:current_syntax") endif " AFAICT "." should be considered part of the iskeyword. Using iskeywords in -" syntax is dicey, so the following code permits the user to +" syntax is dicey, so the following code permits the user to prevent/override " g:sh_isk set to a string : specify iskeyword. " g:sh_noisk exists : don't change iskeyword " g:sh_noisk does not exist : (default) append "." to iskeyword @@ -104,7 +104,7 @@ syn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsa if exists("b:is_kornshell") syn cluster ErrorList add=shDTestError endif -syn cluster shArithParenList contains=shArithmetic,shCaseEsac,shDeref,shDerefSimple,shEcho,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement +syn cluster shArithParenList contains=shArithmetic,shCaseEsac,shComment,shDeref,shDerefSimple,shDo,shEcho,shEscape,shIf,shFor,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement syn cluster shArithList contains=@shArithParenList,shParenError syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq @@ -127,7 +127,7 @@ syn cluster shHereList contains=shBeginHere,shHerePayload 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,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest,@shErrorList,shSet,shOption +syn cluster shLoopList contains=@shCaseList,shIf,shFor,shForPP,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest,@shErrorList,shSet,shOption 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,shComment,shCommandSub,shDeref,shDerefSimple,shExDoubleQuote,shDoubleQuote,shExpr,shNumber,shOperator,shExSingleQuote,shSingleQuote,shTestOpr,shTest,shCtrlSeq " Echo: {{{1 @@ -151,18 +151,18 @@ endif " Error Codes: {{{1 " ============ if !exists("g:sh_no_error") - syn match shDoError "\<done\>" - syn match shIfError "\<fi\>" - syn match shInError "\<in\>" - syn match shCaseError ";;" - syn match shEsacError "\<esac\>" - syn match shCurlyError "}" - syn match shParenError ")" - syn match shOK '\.\(done\|fi\|in\|esac\)' + syn match shDoError "\<done\>" + syn match shIfError "\<fi\>" + syn match shInError "\<in\>" + syn match shCaseError ";;" + syn match shEsacError "\<esac\>" + syn match shCurlyError "}" + syn match shParenError ")" + syn match shOK '\.\(done\|fi\|in\|esac\)' if exists("b:is_kornshell") - syn match shDTestError "]]" + syn match shDTestError "]]" endif - syn match shTestError "]" + syn match shTestError "]" endif " Options: {{{1 @@ -197,9 +197,10 @@ syn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\ syn match shTestOpr contained "<=\|>=\|!=\|==\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]" syn match shTestOpr contained '=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern syn match shTestPattern contained '\w\+' -syn match shTestDoubleQuote contained '\%(\%(\\\\\)*\\\)\@<!"[^"]*"' +syn region shTestDoubleQuote contained start='"' skip='\\"' end='"' contains=shBQpairs syn match shTestSingleQuote contained '\\.' syn match shTestSingleQuote contained "'[^']*'" +syn match shBQpairs contained '\\\\' if exists("b:is_kornshell") || exists("b:is_bash") syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\\\\\|\\$+ end="\]\]" contains=@shTestList syn region shDblParen matchgroup=Delimiter start="((" skip=+\\\\\|\\$+ end="))" contains=@shTestList @@ -216,11 +217,11 @@ if s:sh_fold_ifdofor syn region shIf fold transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList syn region shFor fold matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn else - syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList + syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList syn region shFor matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn - syn match shForPP '\<for\>\ze\_s*((' endif +syn region shForPP matchgroup=shLoop start='\<for\>\_s*((' end='))' contains=shTestOpr if exists("b:is_kornshell") || exists("b:is_bash") syn cluster shCaseList add=shRepeat syn cluster shFunctionList add=shRepeat @@ -280,7 +281,7 @@ if exists("b:is_kornshell") || exists("b:is_bash") elseif !exists("g:sh_no_error") syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList endif -syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList +syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(\ze[^(]" skip='\\\\\|\\.' end=")" contains=@shCommandSubList if exists("b:is_bash") syn cluster shCommandSubList add=bashSpecialVariables,bashStatement @@ -321,12 +322,12 @@ elseif !exists("g:sh_no_error") endif syn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell +"syn region shDoubleQuote matchgroup=shQuote start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell syn match shStringSpecial "[^[:print:] \t]" contained syn match shStringSpecial "\%(\\\\\)*\\[\\"'`$()#]" -"syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial,shComment -syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial -syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shComment -syn match shMoreSpecial "\%(\\\\\)*\\[\\"'`$()#]" contained nextgroup=shMoreSpecial +syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial,shComment +syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shComment +syn match shMoreSpecial "\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial contained " Comments: {{{1 "========== @@ -363,9 +364,9 @@ elseif s:sh_fold_heredoc syn region shHereDoc matchgroup=shRedir19 fold start="<<\\\z([^ \t|]*\)" matchgroup=shRedir19 end="^\z1\s*$" else - syn region shHereDoc matchgroup=shRedir20 start="<<\s*\\\=\z([^ \t|]*\)" matchgroup=shRedir20 end="^\z1\s*$" contains=@shDblQuoteList + syn region shHereDoc matchgroup=shRedir20 start="<<\s*\\\=\z([^ \t|]*\)" matchgroup=shRedir20 end="^\z1\s*$" contains=@shDblQuoteList syn region shHereDoc matchgroup=shRedir21 start="<<\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir21 end="^\z1\s*$" - syn region shHereDoc matchgroup=shRedir22 start="<<-\s*\z([^ \t|]*\)" matchgroup=shRedir22 end="^\s*\z1\s*$" contains=@shDblQuoteList + syn region shHereDoc matchgroup=shRedir22 start="<<-\s*\z([^ \t|]*\)" matchgroup=shRedir22 end="^\s*\z1\s*$" contains=@shDblQuoteList syn region shHereDoc matchgroup=shRedir23 start="<<-\s*'\z([^ \t|]*\)'" matchgroup=shRedir23 end="^\s*\z1\s*$" syn region shHereDoc matchgroup=shRedir24 start="<<\s*'\z([^ \t|]*\)'" matchgroup=shRedir24 end="^\z1\s*$" syn region shHereDoc matchgroup=shRedir25 start="<<-\s*\"\z([^ \t|]*\)\"" matchgroup=shRedir25 end="^\s*\z1\s*$" @@ -450,21 +451,21 @@ syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@s syn match shDerefVar contained "{\@<=\k\+" nextgroup=@shDerefVarList " sh ksh bash : ${var[... ]...} array reference: {{{1 -syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError +syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError " Special ${parameter OPERATOR word} handling: {{{1 -" sh ksh bash : ${parameter:-word} word is default value -" sh ksh bash : ${parameter:=word} assign word as default value -" sh ksh bash : ${parameter:?word} display word if parameter is null -" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing -" ksh bash : ${parameter#pattern} remove small left pattern -" ksh bash : ${parameter##pattern} remove large left pattern -" ksh bash : ${parameter%pattern} remove small right pattern -" ksh bash : ${parameter%%pattern} remove large right pattern -" bash : ${parameter^pattern} Case modification -" bash : ${parameter^^pattern} Case modification -" bash : ${parameter,pattern} Case modification -" bash : ${parameter,,pattern} Case modification +" sh ksh bash : ${parameter:-word} word is default value +" sh ksh bash : ${parameter:=word} assign word as default value +" sh ksh bash : ${parameter:?word} display word if parameter is null +" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing +" ksh bash : ${parameter#pattern} remove small left pattern +" ksh bash : ${parameter##pattern} remove large left pattern +" ksh bash : ${parameter%pattern} remove small right pattern +" ksh bash : ${parameter%%pattern} remove large right pattern +" bash : ${parameter^pattern} Case modification +" bash : ${parameter^^pattern} Case modification +" bash : ${parameter,pattern} Case modification +" bash : ${parameter,,pattern} Case modification syn cluster shDerefPatternList contains=shDerefPattern,shDerefString if !exists("g:sh_no_error") syn match shDerefOpError contained ":[[:punct:]]" @@ -576,7 +577,7 @@ hi def link shDoubleQuote shString hi def link shEcho shString hi def link shEchoDelim shOperator hi def link shEchoQuote shString -hi def link shForPP shLoop +"hi def link shForPP shLoop hi def link shEmbeddedEcho shString hi def link shEscape shCommandSub hi def link shExDoubleQuote shDoubleQuote @@ -598,12 +599,12 @@ hi def link shSetOption shOption hi def link shSingleQuote shString hi def link shSource shOperator hi def link shStringSpecial shSpecial -hi def link shStringSpecial Unique hi def link shSubShRegion shOperator hi def link shTestOpr shConditional hi def link shTestPattern shString hi def link shTestDoubleQuote shString hi def link shTestSingleQuote shString +hi def link shBQpairs shString hi def link shVariable shSetList hi def link shWrapLineOperator shOperator diff --git a/runtime/syntax/tags.vim b/runtime/syntax/tags.vim index 051d65aa6e..c86f17a618 100644 --- a/runtime/syntax/tags.vim +++ b/runtime/syntax/tags.vim @@ -1,8 +1,8 @@ " Language: tags -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchip@PcampbellAfamily.Mbiz> -" Last Change: Sep 06, 2005 -" Version: 3 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Maintainer: Charles E. Campbell <NdrOchip@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 4 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TAGS " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 3f719e8244..dcdeca2e6c 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: Sep 09, 2014 -" Version: 82 +" Last Change: Nov 18, 2014 +" Version: 83 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -64,6 +64,8 @@ if version >= 508 || !exists("did_tex_syntax_inits") endif if exists("g:tex_no_error") && g:tex_no_error let s:tex_no_error= 1 +else + let s:tex_no_error= 0 endif " by default, enable all region-based highlighting @@ -76,7 +78,6 @@ if exists("g:tex_fast") else let s:tex_fast= g:tex_fast endif - let s:tex_no_error= 1 else let s:tex_fast= "bcmMprsSvV" endif @@ -141,7 +142,7 @@ endif " Clusters: {{{1 " -------- syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texBeginEnd,texBeginEndName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle -if !exists("s:tex_no_error") +if !exists("s:tex_no_error") || !s:tex_no_error syn cluster texCmdGroup add=texMathError endif syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement @@ -157,13 +158,13 @@ else endif syn cluster texPreambleMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter -if !exists("tex_no_math") +if !exists("g:tex_no_math") syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ syn cluster texMatchGroup add=@texMathZones syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2 syn cluster texMathMatchGroup contains=@texMathZones,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathMatcher,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle - if !exists("s:tex_no_error") + if !exists("s:tex_no_error") || !s:tex_no_error syn cluster texMathMatchGroup add=texMathError syn cluster texMathZoneGroup add=texMathError endif @@ -185,7 +186,7 @@ endif " Try to flag {} and () mismatches: {{{1 if s:tex_fast =~ 'm' - if !exists("s:tex_no_error") + if !exists("s:tex_no_error") || !s:tex_no_error syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError,@NoSpell else @@ -198,12 +199,12 @@ if s:tex_fast =~ 'm' syn region texParen start="(" end=")" contains=@texMatchGroup endif endif -if !exists("s:tex_no_error") +if !exists("s:tex_no_error") || !s:tex_no_error syn match texError "[}\])]" endif if s:tex_fast =~ 'M' - if !exists("tex_no_math") - if !exists("s:tex_no_error") + if !exists("g:tex_no_math") + if !exists("s:tex_no_error") || !s:tex_no_error syn match texMathError "}" contained endif syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup @@ -217,7 +218,7 @@ if exists("g:tex_tex") || b:tex_stylish syn match texStatement "\\[a-zA-Z@]\+" else syn match texStatement "\\\a\+" - if !exists("s:tex_no_error") + if !exists("s:tex_no_error") || !s:tex_no_error syn match texError "\\\a*@[a-zA-Z@]*" endif endif @@ -358,6 +359,7 @@ if s:tex_fast =~ 'p' syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell + syn region texSpellZone matchgroup=texSpellZone start="%spellzone_start" end="%spellzone_end" contains=@Spell endif else if g:tex_fold_enabled && has("folding") @@ -397,14 +399,14 @@ if s:tex_fast =~ 'b' endif " Bad Math (mismatched): {{{1 -if !exists("g:tex_no_math") && !exists("s:tex_no_error") +if !exists("g:tex_no_math") && (!exists("s:tex_no_error") || !s:tex_no_error) syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}" syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}" syn match texBadMath "\\[\])]" endif " Math Zones: {{{1 -if !exists("tex_no_math") +if !exists("g:tex_no_math") " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2 " Starred forms are created if starform is true. Starred " forms have syntax group and synchronization groups with a @@ -541,7 +543,7 @@ else syn match texSpecialChar "\\[SP@]\A"me=e-1 endif syn match texSpecialChar "\\\\" -if !exists("tex_no_math") +if !exists("g:tex_no_math") syn match texOnlyMath "[_^]" endif syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S" @@ -574,12 +576,14 @@ else syn match texComment "%.*$" contains=@texCommentGroup if s:tex_fast =~ 'c' syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold - syn region texNoSpell contained fold matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell + syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" fold contains=@texFoldGroup,@NoSpell + syn region texSpellZone matchgroup=texComment start="%\s*spellzone_start" end="%\s*spellzone_end" fold contains=@Spell,@texFoldGroup endif else - syn match texComment "%.*$" contains=@texCommentGroup + syn match texComment "%.*$" contains=@texCommentGroup if s:tex_fast =~ 'c' - syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell + syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell + syn region texSpellZone matchgroup=texComment start="%\s*spellzone_start" end="%\s*spellzone_end" contains=@Spell,@texFoldGroup endif endif endif @@ -663,7 +667,7 @@ syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\ syn match texString "\(``\|''\|,,\)" " makeatletter -- makeatother sections -if !exists("s:tex_no_error") +if !exists("s:tex_no_error") || !s:tex_no_error if s:tex_fast =~ 'S' syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained endif @@ -794,8 +798,8 @@ if has("conceal") && &enc == 'utf-8' \ ['left(' , '('], \ ['left\[' , '['], \ ['left\\{' , '{'], - \ ['leftarrow' , '⟵'], - \ ['Leftarrow' , '⟸'], + \ ['leftarrow' , '←'], + \ ['Leftarrow' , '⇐'], \ ['leftarrowtail' , '↢'], \ ['leftharpoondown', '↽'], \ ['leftharpoonup' , '↼'], @@ -881,8 +885,8 @@ if has("conceal") && &enc == 'utf-8' \ ['right)' , ')'], \ ['right]' , ']'], \ ['right\\}' , '}'], - \ ['rightarrow' , '⟶'], - \ ['Rightarrow' , '⟹'], + \ ['rightarrow' , '→'], + \ ['Rightarrow' , '⇒'], \ ['rightarrowtail' , '↣'], \ ['rightleftharpoons', '⇌'], \ ['rightsquigarrow', '↝'], @@ -995,6 +999,7 @@ if has("conceal") && &enc == 'utf-8' syn match texMathSymbol '\\hat{W}' contained conceal cchar=Ŵ syn match texMathSymbol '\\hat{y}' contained conceal cchar=ŷ syn match texMathSymbol '\\hat{Y}' contained conceal cchar=Ŷ +" syn match texMathSymbol '\\bar{a}' contained conceal cchar=a̅ endif " Greek {{{2 @@ -1011,7 +1016,7 @@ if has("conceal") && &enc == 'utf-8' call s:Greek('texGreek','\\zeta\>' ,'ζ') call s:Greek('texGreek','\\eta\>' ,'η') call s:Greek('texGreek','\\theta\>' ,'θ') - call s:Greek('texGreek','\\vartheta\>' ,'ϑ') + call s:Greek('texGreek','\\vartheta\>' ,'ϑ') call s:Greek('texGreek','\\kappa\>' ,'κ') call s:Greek('texGreek','\\lambda\>' ,'λ') call s:Greek('texGreek','\\mu\>' ,'μ') @@ -1022,11 +1027,11 @@ if has("conceal") && &enc == 'utf-8' call s:Greek('texGreek','\\rho\>' ,'ρ') call s:Greek('texGreek','\\varrho\>' ,'ϱ') call s:Greek('texGreek','\\sigma\>' ,'σ') - call s:Greek('texGreek','\\varsigma\>' ,'ς') + call s:Greek('texGreek','\\varsigma\>' ,'ς') call s:Greek('texGreek','\\tau\>' ,'τ') call s:Greek('texGreek','\\upsilon\>' ,'υ') - call s:Greek('texGreek','\\phi\>' ,'φ') - call s:Greek('texGreek','\\varphi\>' ,'ϕ') + call s:Greek('texGreek','\\phi\>' ,'ϕ') + call s:Greek('texGreek','\\varphi\>' ,'φ') call s:Greek('texGreek','\\chi\>' ,'χ') call s:Greek('texGreek','\\psi\>' ,'ψ') call s:Greek('texGreek','\\omega\>' ,'ω') @@ -1245,7 +1250,7 @@ syn sync match texSyncStop groupthere NONE "%stopzone\>" " (one can't tell if a "$$" starts or stops a math zone by itself) " The following grouptheres coupled with minlines above " help improve the odds of good syncing. -if !exists("tex_no_math") +if !exists("g:tex_no_math") syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}" syn sync match texSyncMathZoneA groupthere NONE "\\end{center}" syn sync match texSyncMathZoneA groupthere NONE "\\end{description}" @@ -1285,7 +1290,7 @@ if did_tex_syntax_inits == 1 HiLink texInputFileOpt texCmdArgs HiLink texInputCurlies texDelimiter HiLink texLigature texSpecialChar - if !exists("tex_no_math") + if !exists("g:tex_no_math") HiLink texMathDelimSet1 texMathDelim HiLink texMathDelimSet2 texMathDelim HiLink texMathDelimKey texMathDelim diff --git a/runtime/syntax/xmath.vim b/runtime/syntax/xmath.vim index 83efb08db2..5434f928c7 100644 --- a/runtime/syntax/xmath.vim +++ b/runtime/syntax/xmath.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: xmath (a simulation tool) -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> " Last Change: Sep 11, 2006 -" Version: 6 -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" Version: 7 +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_XMATH " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/xxd.vim b/runtime/syntax/xxd.vim index 50594e1fcf..b2b1e44603 100644 --- a/runtime/syntax/xxd.vim +++ b/runtime/syntax/xxd.vim @@ -1,10 +1,10 @@ " Vim syntax file " Language: bin using xxd -" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> -" Last Change: Sep 06, 2005 -" Version: 7 +" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> +" Last Change: Oct 23, 2014 +" Version: 8 " Notes: use :help xxd to see how to invoke it -" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax +" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_XXD " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded diff --git a/runtime/syntax/yacc.vim b/runtime/syntax/yacc.vim index 714432be9d..9dc6cccb2d 100644 --- a/runtime/syntax/yacc.vim +++ b/runtime/syntax/yacc.vim @@ -42,7 +42,7 @@ exe "syn include @yaccCode ".s:Cpath " --------------------------------------------------------------------- " Yacc Clusters: {{{1 syn cluster yaccInitCluster contains=yaccKey,yaccKeyActn,yaccBrkt,yaccType,yaccString,yaccUnionStart,yaccHeader2,yaccComment,yaccDefines,yaccParseParam,yaccParseOption -syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString,yaccComment +syn cluster yaccRulesCluster contains=yaccNonterminal,yaccString " --------------------------------------------------------------------- " Yacc Sections: {{{1 diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 57d7002739..d053bea6b5 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -313,70 +313,71 @@ static struct vimvar { * The order here must match the VV_ defines in eval.h! * Initializing a union does not work, leave tv.vval empty to get zero's. */ - {VV_NAME("count", VAR_NUMBER), VV_COMPAT+VV_RO}, - {VV_NAME("count1", VAR_NUMBER), VV_RO}, - {VV_NAME("prevcount", VAR_NUMBER), VV_RO}, - {VV_NAME("errmsg", VAR_STRING), VV_COMPAT}, - {VV_NAME("warningmsg", VAR_STRING), 0}, - {VV_NAME("statusmsg", VAR_STRING), 0}, - {VV_NAME("shell_error", VAR_NUMBER), VV_COMPAT+VV_RO}, - {VV_NAME("this_session", VAR_STRING), VV_COMPAT}, - {VV_NAME("version", VAR_NUMBER), VV_COMPAT+VV_RO}, - {VV_NAME("lnum", VAR_NUMBER), VV_RO_SBX}, - {VV_NAME("termresponse", VAR_STRING), VV_RO}, - {VV_NAME("fname", VAR_STRING), VV_RO}, - {VV_NAME("lang", VAR_STRING), VV_RO}, - {VV_NAME("lc_time", VAR_STRING), VV_RO}, - {VV_NAME("ctype", VAR_STRING), VV_RO}, - {VV_NAME("charconvert_from", VAR_STRING), VV_RO}, - {VV_NAME("charconvert_to", VAR_STRING), VV_RO}, - {VV_NAME("fname_in", VAR_STRING), VV_RO}, - {VV_NAME("fname_out", VAR_STRING), VV_RO}, - {VV_NAME("fname_new", VAR_STRING), VV_RO}, - {VV_NAME("fname_diff", VAR_STRING), VV_RO}, - {VV_NAME("cmdarg", VAR_STRING), VV_RO}, - {VV_NAME("foldstart", VAR_NUMBER), VV_RO_SBX}, - {VV_NAME("foldend", VAR_NUMBER), VV_RO_SBX}, - {VV_NAME("folddashes", VAR_STRING), VV_RO_SBX}, - {VV_NAME("foldlevel", VAR_NUMBER), VV_RO_SBX}, - {VV_NAME("progname", VAR_STRING), VV_RO}, - {VV_NAME("servername", VAR_STRING), VV_RO}, - {VV_NAME("dying", VAR_NUMBER), VV_RO}, - {VV_NAME("exception", VAR_STRING), VV_RO}, - {VV_NAME("throwpoint", VAR_STRING), VV_RO}, - {VV_NAME("register", VAR_STRING), VV_RO}, - {VV_NAME("cmdbang", VAR_NUMBER), VV_RO}, - {VV_NAME("insertmode", VAR_STRING), VV_RO}, - {VV_NAME("val", VAR_UNKNOWN), VV_RO}, - {VV_NAME("key", VAR_UNKNOWN), VV_RO}, - {VV_NAME("profiling", VAR_NUMBER), VV_RO}, - {VV_NAME("fcs_reason", VAR_STRING), VV_RO}, - {VV_NAME("fcs_choice", VAR_STRING), 0}, - {VV_NAME("beval_bufnr", VAR_NUMBER), VV_RO}, - {VV_NAME("beval_winnr", VAR_NUMBER), VV_RO}, - {VV_NAME("beval_lnum", VAR_NUMBER), VV_RO}, - {VV_NAME("beval_col", VAR_NUMBER), VV_RO}, - {VV_NAME("beval_text", VAR_STRING), VV_RO}, - {VV_NAME("scrollstart", VAR_STRING), 0}, - {VV_NAME("swapname", VAR_STRING), VV_RO}, - {VV_NAME("swapchoice", VAR_STRING), 0}, - {VV_NAME("swapcommand", VAR_STRING), VV_RO}, - {VV_NAME("char", VAR_STRING), 0}, - {VV_NAME("mouse_win", VAR_NUMBER), 0}, - {VV_NAME("mouse_lnum", VAR_NUMBER), 0}, - {VV_NAME("mouse_col", VAR_NUMBER), 0}, - {VV_NAME("operator", VAR_STRING), VV_RO}, - {VV_NAME("searchforward", VAR_NUMBER), 0}, - {VV_NAME("hlsearch", VAR_NUMBER), 0}, - {VV_NAME("oldfiles", VAR_LIST), 0}, - {VV_NAME("windowid", VAR_NUMBER), VV_RO}, - {VV_NAME("progpath", VAR_STRING), VV_RO}, - {VV_NAME("command_output", VAR_STRING), 0}, - {VV_NAME("completed_item", VAR_DICT), VV_RO}, - {VV_NAME("option_new", VAR_STRING), VV_RO}, - {VV_NAME("option_old", VAR_STRING), VV_RO}, - {VV_NAME("option_type", VAR_STRING), VV_RO}, - {VV_NAME("msgpack_types", VAR_DICT), VV_RO}, + { VV_NAME("count", VAR_NUMBER), VV_COMPAT+VV_RO }, + { VV_NAME("count1", VAR_NUMBER), VV_RO }, + { VV_NAME("prevcount", VAR_NUMBER), VV_RO }, + { VV_NAME("errmsg", VAR_STRING), VV_COMPAT }, + { VV_NAME("warningmsg", VAR_STRING), 0 }, + { VV_NAME("statusmsg", VAR_STRING), 0 }, + { VV_NAME("shell_error", VAR_NUMBER), VV_COMPAT+VV_RO }, + { VV_NAME("this_session", VAR_STRING), VV_COMPAT }, + { VV_NAME("version", VAR_NUMBER), VV_COMPAT+VV_RO }, + { VV_NAME("lnum", VAR_NUMBER), VV_RO_SBX }, + { VV_NAME("termresponse", VAR_STRING), VV_RO }, + { VV_NAME("fname", VAR_STRING), VV_RO }, + { VV_NAME("lang", VAR_STRING), VV_RO }, + { VV_NAME("lc_time", VAR_STRING), VV_RO }, + { VV_NAME("ctype", VAR_STRING), VV_RO }, + { VV_NAME("charconvert_from", VAR_STRING), VV_RO }, + { VV_NAME("charconvert_to", VAR_STRING), VV_RO }, + { VV_NAME("fname_in", VAR_STRING), VV_RO }, + { VV_NAME("fname_out", VAR_STRING), VV_RO }, + { VV_NAME("fname_new", VAR_STRING), VV_RO }, + { VV_NAME("fname_diff", VAR_STRING), VV_RO }, + { VV_NAME("cmdarg", VAR_STRING), VV_RO }, + { VV_NAME("foldstart", VAR_NUMBER), VV_RO_SBX }, + { VV_NAME("foldend", VAR_NUMBER), VV_RO_SBX }, + { VV_NAME("folddashes", VAR_STRING), VV_RO_SBX }, + { VV_NAME("foldlevel", VAR_NUMBER), VV_RO_SBX }, + { VV_NAME("progname", VAR_STRING), VV_RO }, + { VV_NAME("servername", VAR_STRING), VV_RO }, + { VV_NAME("dying", VAR_NUMBER), VV_RO }, + { VV_NAME("exception", VAR_STRING), VV_RO }, + { VV_NAME("throwpoint", VAR_STRING), VV_RO }, + { VV_NAME("register", VAR_STRING), VV_RO }, + { VV_NAME("cmdbang", VAR_NUMBER), VV_RO }, + { VV_NAME("insertmode", VAR_STRING), VV_RO }, + { VV_NAME("val", VAR_UNKNOWN), VV_RO }, + { VV_NAME("key", VAR_UNKNOWN), VV_RO }, + { VV_NAME("profiling", VAR_NUMBER), VV_RO }, + { VV_NAME("fcs_reason", VAR_STRING), VV_RO }, + { VV_NAME("fcs_choice", VAR_STRING), 0 }, + { VV_NAME("beval_bufnr", VAR_NUMBER), VV_RO }, + { VV_NAME("beval_winnr", VAR_NUMBER), VV_RO }, + { VV_NAME("beval_lnum", VAR_NUMBER), VV_RO }, + { VV_NAME("beval_col", VAR_NUMBER), VV_RO }, + { VV_NAME("beval_text", VAR_STRING), VV_RO }, + { VV_NAME("scrollstart", VAR_STRING), 0 }, + { VV_NAME("swapname", VAR_STRING), VV_RO }, + { VV_NAME("swapchoice", VAR_STRING), 0 }, + { VV_NAME("swapcommand", VAR_STRING), VV_RO }, + { VV_NAME("char", VAR_STRING), 0 }, + { VV_NAME("mouse_win", VAR_NUMBER), 0 }, + { VV_NAME("mouse_lnum", VAR_NUMBER), 0 }, + { VV_NAME("mouse_col", VAR_NUMBER), 0 }, + { VV_NAME("operator", VAR_STRING), VV_RO }, + { VV_NAME("searchforward", VAR_NUMBER), 0 }, + { VV_NAME("hlsearch", VAR_NUMBER), 0 }, + { VV_NAME("oldfiles", VAR_LIST), 0 }, + { VV_NAME("windowid", VAR_NUMBER), VV_RO }, + { VV_NAME("progpath", VAR_STRING), VV_RO }, + { VV_NAME("command_output", VAR_STRING), 0 }, + { VV_NAME("completed_item", VAR_DICT), VV_RO }, + { VV_NAME("option_new", VAR_STRING), VV_RO }, + { VV_NAME("option_old", VAR_STRING), VV_RO }, + { VV_NAME("option_type", VAR_STRING), VV_RO }, + { VV_NAME("errors", VAR_LIST), 0 }, + { VV_NAME("msgpack_types", VAR_DICT), VV_RO }, }; /* shorthand */ @@ -544,6 +545,7 @@ void eval_init(void) set_vim_var_dict(VV_MSGPACK_TYPES, msgpack_types_dict); set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc()); + set_vim_var_list(VV_ERRORS, list_alloc()); set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); set_reg_var(0); /* default for v:register is not 0 but '"' */ @@ -7090,295 +7092,298 @@ static struct fst { /* implementation of function */ } functions[] = { - {"abs", 1, 1, f_abs}, - {"acos", 1, 1, f_acos}, /* WJMc */ - {"add", 2, 2, f_add}, - {"and", 2, 2, f_and}, - {"append", 2, 2, f_append}, - {"argc", 0, 0, f_argc}, - {"argidx", 0, 0, f_argidx}, - {"arglistid", 0, 2, f_arglistid}, - {"argv", 0, 1, f_argv}, - {"asin", 1, 1, f_asin}, /* WJMc */ - {"atan", 1, 1, f_atan}, - {"atan2", 2, 2, f_atan2}, - {"browse", 4, 4, f_browse}, - {"browsedir", 2, 2, f_browsedir}, - {"bufexists", 1, 1, f_bufexists}, - {"buffer_exists", 1, 1, f_bufexists}, /* obsolete */ - {"buffer_name", 1, 1, f_bufname}, /* obsolete */ - {"buffer_number", 1, 1, f_bufnr}, /* obsolete */ - {"buflisted", 1, 1, f_buflisted}, - {"bufloaded", 1, 1, f_bufloaded}, - {"bufname", 1, 1, f_bufname}, - {"bufnr", 1, 2, f_bufnr}, - {"bufwinnr", 1, 1, f_bufwinnr}, - {"byte2line", 1, 1, f_byte2line}, - {"byteidx", 2, 2, f_byteidx}, - {"byteidxcomp", 2, 2, f_byteidxcomp}, - {"call", 2, 3, f_call}, - {"ceil", 1, 1, f_ceil}, - {"changenr", 0, 0, f_changenr}, - {"char2nr", 1, 2, f_char2nr}, - {"cindent", 1, 1, f_cindent}, - {"clearmatches", 0, 0, f_clearmatches}, - {"col", 1, 1, f_col}, - {"complete", 2, 2, f_complete}, - {"complete_add", 1, 1, f_complete_add}, - {"complete_check", 0, 0, f_complete_check}, - {"confirm", 1, 4, f_confirm}, - {"copy", 1, 1, f_copy}, - {"cos", 1, 1, f_cos}, - {"cosh", 1, 1, f_cosh}, - {"count", 2, 4, f_count}, - {"cscope_connection",0,3, f_cscope_connection}, - {"cursor", 1, 3, f_cursor}, - {"deepcopy", 1, 2, f_deepcopy}, - {"delete", 1, 1, f_delete}, - {"dictwatcheradd", 3, 3, f_dictwatcheradd}, - {"dictwatcherdel", 3, 3, f_dictwatcherdel}, - {"did_filetype", 0, 0, f_did_filetype}, - {"diff_filler", 1, 1, f_diff_filler}, - {"diff_hlID", 2, 2, f_diff_hlID}, - {"empty", 1, 1, f_empty}, - {"escape", 2, 2, f_escape}, - {"eval", 1, 1, f_eval}, - {"eventhandler", 0, 0, f_eventhandler}, - {"executable", 1, 1, f_executable}, - {"exepath", 1, 1, f_exepath}, - {"exists", 1, 1, f_exists}, - {"exp", 1, 1, f_exp}, - {"expand", 1, 3, f_expand}, - {"extend", 2, 3, f_extend}, - {"feedkeys", 1, 2, f_feedkeys}, - {"file_readable", 1, 1, f_filereadable}, /* obsolete */ - {"filereadable", 1, 1, f_filereadable}, - {"filewritable", 1, 1, f_filewritable}, - {"filter", 2, 2, f_filter}, - {"finddir", 1, 3, f_finddir}, - {"findfile", 1, 3, f_findfile}, - {"float2nr", 1, 1, f_float2nr}, - {"floor", 1, 1, f_floor}, - {"fmod", 2, 2, f_fmod}, - {"fnameescape", 1, 1, f_fnameescape}, - {"fnamemodify", 2, 2, f_fnamemodify}, - {"foldclosed", 1, 1, f_foldclosed}, - {"foldclosedend", 1, 1, f_foldclosedend}, - {"foldlevel", 1, 1, f_foldlevel}, - {"foldtext", 0, 0, f_foldtext}, - {"foldtextresult", 1, 1, f_foldtextresult}, - {"foreground", 0, 0, f_foreground}, - {"function", 1, 1, f_function}, - {"garbagecollect", 0, 1, f_garbagecollect}, - {"get", 2, 3, f_get}, - {"getbufline", 2, 3, f_getbufline}, - {"getbufvar", 2, 3, f_getbufvar}, - {"getchar", 0, 1, f_getchar}, - {"getcharmod", 0, 0, f_getcharmod}, - {"getcharsearch", 0, 0, f_getcharsearch}, - {"getcmdline", 0, 0, f_getcmdline}, - {"getcmdpos", 0, 0, f_getcmdpos}, - {"getcmdtype", 0, 0, f_getcmdtype}, - {"getcmdwintype", 0, 0, f_getcmdwintype}, - {"getcurpos", 0, 0, f_getcurpos}, - {"getcwd", 0, 0, f_getcwd}, - {"getfontname", 0, 1, f_getfontname}, - {"getfperm", 1, 1, f_getfperm}, - {"getfsize", 1, 1, f_getfsize}, - {"getftime", 1, 1, f_getftime}, - {"getftype", 1, 1, f_getftype}, - {"getline", 1, 2, f_getline}, - {"getloclist", 1, 1, f_getqflist}, - {"getmatches", 0, 0, f_getmatches}, - {"getpid", 0, 0, f_getpid}, - {"getpos", 1, 1, f_getpos}, - {"getqflist", 0, 0, f_getqflist}, - {"getreg", 0, 3, f_getreg}, - {"getregtype", 0, 1, f_getregtype}, - {"gettabvar", 2, 3, f_gettabvar}, - {"gettabwinvar", 3, 4, f_gettabwinvar}, - {"getwinposx", 0, 0, f_getwinposx}, - {"getwinposy", 0, 0, f_getwinposy}, - {"getwinvar", 2, 3, f_getwinvar}, - {"glob", 1, 3, f_glob}, - {"glob2regpat", 1, 1, f_glob2regpat}, - {"globpath", 2, 4, f_globpath}, - {"has", 1, 1, f_has}, - {"has_key", 2, 2, f_has_key}, - {"haslocaldir", 0, 0, f_haslocaldir}, - {"hasmapto", 1, 3, f_hasmapto}, - {"highlightID", 1, 1, f_hlID}, /* obsolete */ - {"highlight_exists",1, 1, f_hlexists}, /* obsolete */ - {"histadd", 2, 2, f_histadd}, - {"histdel", 1, 2, f_histdel}, - {"histget", 1, 2, f_histget}, - {"histnr", 1, 1, f_histnr}, - {"hlID", 1, 1, f_hlID}, - {"hlexists", 1, 1, f_hlexists}, - {"hostname", 0, 0, f_hostname}, - {"iconv", 3, 3, f_iconv}, - {"indent", 1, 1, f_indent}, - {"index", 2, 4, f_index}, - {"input", 1, 3, f_input}, - {"inputdialog", 1, 3, f_inputdialog}, - {"inputlist", 1, 1, f_inputlist}, - {"inputrestore", 0, 0, f_inputrestore}, - {"inputsave", 0, 0, f_inputsave}, - {"inputsecret", 1, 2, f_inputsecret}, - {"insert", 2, 3, f_insert}, - {"invert", 1, 1, f_invert}, - {"isdirectory", 1, 1, f_isdirectory}, - {"islocked", 1, 1, f_islocked}, - {"items", 1, 1, f_items}, - {"jobclose", 1, 2, f_jobclose}, - {"jobresize", 3, 3, f_jobresize}, - {"jobsend", 2, 2, f_jobsend}, - {"jobstart", 1, 2, f_jobstart}, - {"jobstop", 1, 1, f_jobstop}, - {"jobwait", 1, 2, f_jobwait}, - {"join", 1, 2, f_join}, - {"keys", 1, 1, f_keys}, - {"last_buffer_nr", 0, 0, f_last_buffer_nr}, /* obsolete */ - {"len", 1, 1, f_len}, - {"libcall", 3, 3, f_libcall}, - {"libcallnr", 3, 3, f_libcallnr}, - {"line", 1, 1, f_line}, - {"line2byte", 1, 1, f_line2byte}, - {"lispindent", 1, 1, f_lispindent}, - {"localtime", 0, 0, f_localtime}, - {"log", 1, 1, f_log}, - {"log10", 1, 1, f_log10}, - {"map", 2, 2, f_map}, - {"maparg", 1, 4, f_maparg}, - {"mapcheck", 1, 3, f_mapcheck}, - {"match", 2, 4, f_match}, - {"matchadd", 2, 4, f_matchadd}, - {"matchaddpos", 2, 4, f_matchaddpos}, - {"matcharg", 1, 1, f_matcharg}, - {"matchdelete", 1, 1, f_matchdelete}, - {"matchend", 2, 4, f_matchend}, - {"matchlist", 2, 4, f_matchlist}, - {"matchstr", 2, 4, f_matchstr}, - {"max", 1, 1, f_max}, - {"min", 1, 1, f_min}, - {"mkdir", 1, 3, f_mkdir}, - {"mode", 0, 1, f_mode}, - {"msgpackdump", 1, 1, f_msgpackdump}, - {"msgpackparse", 1, 1, f_msgpackparse}, - {"nextnonblank", 1, 1, f_nextnonblank}, - {"nr2char", 1, 2, f_nr2char}, - {"or", 2, 2, f_or}, - {"pathshorten", 1, 1, f_pathshorten}, - {"pow", 2, 2, f_pow}, - {"prevnonblank", 1, 1, f_prevnonblank}, - {"printf", 2, 19, f_printf}, - {"pumvisible", 0, 0, f_pumvisible}, - {"py3eval", 1, 1, f_py3eval}, - {"pyeval", 1, 1, f_pyeval}, - {"range", 1, 3, f_range}, - {"readfile", 1, 3, f_readfile}, - {"reltime", 0, 2, f_reltime}, - {"reltimestr", 1, 1, f_reltimestr}, - {"remove", 2, 3, f_remove}, - {"rename", 2, 2, f_rename}, - {"repeat", 2, 2, f_repeat}, - {"resolve", 1, 1, f_resolve}, - {"reverse", 1, 1, f_reverse}, - {"round", 1, 1, f_round}, - {"rpcnotify", 2, 64, f_rpcnotify}, - {"rpcrequest", 2, 64, f_rpcrequest}, - {"rpcstart", 1, 2, f_rpcstart}, - {"rpcstop", 1, 1, f_rpcstop}, - {"screenattr", 2, 2, f_screenattr}, - {"screenchar", 2, 2, f_screenchar}, - {"screencol", 0, 0, f_screencol}, - {"screenrow", 0, 0, f_screenrow}, - {"search", 1, 4, f_search}, - {"searchdecl", 1, 3, f_searchdecl}, - {"searchpair", 3, 7, f_searchpair}, - {"searchpairpos", 3, 7, f_searchpairpos}, - {"searchpos", 1, 4, f_searchpos}, - {"serverlist", 0, 0, f_serverlist}, - {"serverstart", 0, 1, f_serverstart}, - {"serverstop", 1, 1, f_serverstop}, - {"setbufvar", 3, 3, f_setbufvar}, - {"setcharsearch", 1, 1, f_setcharsearch}, - {"setcmdpos", 1, 1, f_setcmdpos}, - {"setline", 2, 2, f_setline}, - {"setloclist", 2, 3, f_setloclist}, - {"setmatches", 1, 1, f_setmatches}, - {"setpos", 2, 2, f_setpos}, - {"setqflist", 1, 2, f_setqflist}, - {"setreg", 2, 3, f_setreg}, - {"settabvar", 3, 3, f_settabvar}, - {"settabwinvar", 4, 4, f_settabwinvar}, - {"setwinvar", 3, 3, f_setwinvar}, - {"sha256", 1, 1, f_sha256}, - {"shellescape", 1, 2, f_shellescape}, - {"shiftwidth", 0, 0, f_shiftwidth}, - {"simplify", 1, 1, f_simplify}, - {"sin", 1, 1, f_sin}, - {"sinh", 1, 1, f_sinh}, - {"sort", 1, 3, f_sort}, - {"soundfold", 1, 1, f_soundfold}, - {"spellbadword", 0, 1, f_spellbadword}, - {"spellsuggest", 1, 3, f_spellsuggest}, - {"split", 1, 3, f_split}, - {"sqrt", 1, 1, f_sqrt}, - {"str2float", 1, 1, f_str2float}, - {"str2nr", 1, 2, f_str2nr}, - {"strchars", 1, 1, f_strchars}, - {"strdisplaywidth", 1, 2, f_strdisplaywidth}, - {"strftime", 1, 2, f_strftime}, - {"stridx", 2, 3, f_stridx}, - {"string", 1, 1, f_string}, - {"strlen", 1, 1, f_strlen}, - {"strpart", 2, 3, f_strpart}, - {"strridx", 2, 3, f_strridx}, - {"strtrans", 1, 1, f_strtrans}, - {"strwidth", 1, 1, f_strwidth}, - {"submatch", 1, 2, f_submatch}, - {"substitute", 4, 4, f_substitute}, - {"synID", 3, 3, f_synID}, - {"synIDattr", 2, 3, f_synIDattr}, - {"synIDtrans", 1, 1, f_synIDtrans}, - {"synconcealed", 2, 2, f_synconcealed}, - {"synstack", 2, 2, f_synstack}, - {"system", 1, 2, f_system}, - {"systemlist", 1, 3, f_systemlist}, - {"tabpagebuflist", 0, 1, f_tabpagebuflist}, - {"tabpagenr", 0, 1, f_tabpagenr}, - {"tabpagewinnr", 1, 2, f_tabpagewinnr}, - {"tagfiles", 0, 0, f_tagfiles}, - {"taglist", 1, 1, f_taglist}, - {"tan", 1, 1, f_tan}, - {"tanh", 1, 1, f_tanh}, - {"tempname", 0, 0, f_tempname}, - {"termopen", 1, 2, f_termopen}, - {"test", 1, 1, f_test}, - {"tolower", 1, 1, f_tolower}, - {"toupper", 1, 1, f_toupper}, - {"tr", 3, 3, f_tr}, - {"trunc", 1, 1, f_trunc}, - {"type", 1, 1, f_type}, - {"undofile", 1, 1, f_undofile}, - {"undotree", 0, 0, f_undotree}, - {"uniq", 1, 3, f_uniq}, - {"values", 1, 1, f_values}, - {"virtcol", 1, 1, f_virtcol}, - {"visualmode", 0, 1, f_visualmode}, - {"wildmenumode", 0, 0, f_wildmenumode}, - {"winbufnr", 1, 1, f_winbufnr}, - {"wincol", 0, 0, f_wincol}, - {"winheight", 1, 1, f_winheight}, - {"winline", 0, 0, f_winline}, - {"winnr", 0, 1, f_winnr}, - {"winrestcmd", 0, 0, f_winrestcmd}, - {"winrestview", 1, 1, f_winrestview}, - {"winsaveview", 0, 0, f_winsaveview}, - {"winwidth", 1, 1, f_winwidth}, - {"writefile", 2, 3, f_writefile}, - {"xor", 2, 2, f_xor}, + { "abs", 1, 1, f_abs }, + { "acos", 1, 1, f_acos }, // WJMc + { "add", 2, 2, f_add }, + { "and", 2, 2, f_and }, + { "append", 2, 2, f_append }, + { "argc", 0, 0, f_argc }, + { "argidx", 0, 0, f_argidx }, + { "arglistid", 0, 2, f_arglistid }, + { "argv", 0, 1, f_argv }, + { "asin", 1, 1, f_asin }, // WJMc + { "assert_equal", 2, 3, f_assert_equal }, + { "assert_false", 1, 2, f_assert_false }, + { "assert_true", 1, 2, f_assert_true }, + { "atan", 1, 1, f_atan }, + { "atan2", 2, 2, f_atan2 }, + { "browse", 4, 4, f_browse }, + { "browsedir", 2, 2, f_browsedir }, + { "bufexists", 1, 1, f_bufexists }, + { "buffer_exists", 1, 1, f_bufexists }, // obsolete + { "buffer_name", 1, 1, f_bufname }, // obsolete + { "buffer_number", 1, 1, f_bufnr }, // obsolete + { "buflisted", 1, 1, f_buflisted }, + { "bufloaded", 1, 1, f_bufloaded }, + { "bufname", 1, 1, f_bufname }, + { "bufnr", 1, 2, f_bufnr }, + { "bufwinnr", 1, 1, f_bufwinnr }, + { "byte2line", 1, 1, f_byte2line }, + { "byteidx", 2, 2, f_byteidx }, + { "byteidxcomp", 2, 2, f_byteidxcomp }, + { "call", 2, 3, f_call }, + { "ceil", 1, 1, f_ceil }, + { "changenr", 0, 0, f_changenr }, + { "char2nr", 1, 2, f_char2nr }, + { "cindent", 1, 1, f_cindent }, + { "clearmatches", 0, 0, f_clearmatches }, + { "col", 1, 1, f_col }, + { "complete", 2, 2, f_complete }, + { "complete_add", 1, 1, f_complete_add }, + { "complete_check", 0, 0, f_complete_check }, + { "confirm", 1, 4, f_confirm }, + { "copy", 1, 1, f_copy }, + { "cos", 1, 1, f_cos }, + { "cosh", 1, 1, f_cosh }, + { "count", 2, 4, f_count }, + { "cscope_connection", 0, 3, f_cscope_connection }, + { "cursor", 1, 3, f_cursor }, + { "deepcopy", 1, 2, f_deepcopy }, + { "delete", 1, 1, f_delete }, + { "dictwatcheradd", 3, 3, f_dictwatcheradd }, + { "dictwatcherdel", 3, 3, f_dictwatcherdel }, + { "did_filetype", 0, 0, f_did_filetype }, + { "diff_filler", 1, 1, f_diff_filler }, + { "diff_hlID", 2, 2, f_diff_hlID }, + { "empty", 1, 1, f_empty }, + { "escape", 2, 2, f_escape }, + { "eval", 1, 1, f_eval }, + { "eventhandler", 0, 0, f_eventhandler }, + { "executable", 1, 1, f_executable }, + { "exepath", 1, 1, f_exepath }, + { "exists", 1, 1, f_exists }, + { "exp", 1, 1, f_exp }, + { "expand", 1, 3, f_expand }, + { "extend", 2, 3, f_extend }, + { "feedkeys", 1, 2, f_feedkeys }, + { "file_readable", 1, 1, f_filereadable }, // obsolete + { "filereadable", 1, 1, f_filereadable }, + { "filewritable", 1, 1, f_filewritable }, + { "filter", 2, 2, f_filter }, + { "finddir", 1, 3, f_finddir }, + { "findfile", 1, 3, f_findfile }, + { "float2nr", 1, 1, f_float2nr }, + { "floor", 1, 1, f_floor }, + { "fmod", 2, 2, f_fmod }, + { "fnameescape", 1, 1, f_fnameescape }, + { "fnamemodify", 2, 2, f_fnamemodify }, + { "foldclosed", 1, 1, f_foldclosed }, + { "foldclosedend", 1, 1, f_foldclosedend }, + { "foldlevel", 1, 1, f_foldlevel }, + { "foldtext", 0, 0, f_foldtext }, + { "foldtextresult", 1, 1, f_foldtextresult }, + { "foreground", 0, 0, f_foreground }, + { "function", 1, 1, f_function }, + { "garbagecollect", 0, 1, f_garbagecollect }, + { "get", 2, 3, f_get }, + { "getbufline", 2, 3, f_getbufline }, + { "getbufvar", 2, 3, f_getbufvar }, + { "getchar", 0, 1, f_getchar }, + { "getcharmod", 0, 0, f_getcharmod }, + { "getcharsearch", 0, 0, f_getcharsearch }, + { "getcmdline", 0, 0, f_getcmdline }, + { "getcmdpos", 0, 0, f_getcmdpos }, + { "getcmdtype", 0, 0, f_getcmdtype }, + { "getcmdwintype", 0, 0, f_getcmdwintype }, + { "getcurpos", 0, 0, f_getcurpos }, + { "getcwd", 0, 0, f_getcwd }, + { "getfontname", 0, 1, f_getfontname }, + { "getfperm", 1, 1, f_getfperm }, + { "getfsize", 1, 1, f_getfsize }, + { "getftime", 1, 1, f_getftime }, + { "getftype", 1, 1, f_getftype }, + { "getline", 1, 2, f_getline }, + { "getloclist", 1, 1, f_getqflist }, + { "getmatches", 0, 0, f_getmatches }, + { "getpid", 0, 0, f_getpid }, + { "getpos", 1, 1, f_getpos }, + { "getqflist", 0, 0, f_getqflist }, + { "getreg", 0, 3, f_getreg }, + { "getregtype", 0, 1, f_getregtype }, + { "gettabvar", 2, 3, f_gettabvar }, + { "gettabwinvar", 3, 4, f_gettabwinvar }, + { "getwinposx", 0, 0, f_getwinposx }, + { "getwinposy", 0, 0, f_getwinposy }, + { "getwinvar", 2, 3, f_getwinvar }, + { "glob", 1, 3, f_glob }, + { "glob2regpat", 1, 1, f_glob2regpat }, + { "globpath", 2, 4, f_globpath }, + { "has", 1, 1, f_has }, + { "has_key", 2, 2, f_has_key }, + { "haslocaldir", 0, 0, f_haslocaldir }, + { "hasmapto", 1, 3, f_hasmapto }, + { "highlightID", 1, 1, f_hlID }, // obsolete + { "highlight_exists", 1, 1, f_hlexists }, // obsolete + { "histadd", 2, 2, f_histadd }, + { "histdel", 1, 2, f_histdel }, + { "histget", 1, 2, f_histget }, + { "histnr", 1, 1, f_histnr }, + { "hlID", 1, 1, f_hlID }, + { "hlexists", 1, 1, f_hlexists }, + { "hostname", 0, 0, f_hostname }, + { "iconv", 3, 3, f_iconv }, + { "indent", 1, 1, f_indent }, + { "index", 2, 4, f_index }, + { "input", 1, 3, f_input }, + { "inputdialog", 1, 3, f_inputdialog }, + { "inputlist", 1, 1, f_inputlist }, + { "inputrestore", 0, 0, f_inputrestore }, + { "inputsave", 0, 0, f_inputsave }, + { "inputsecret", 1, 2, f_inputsecret }, + { "insert", 2, 3, f_insert }, + { "invert", 1, 1, f_invert }, + { "isdirectory", 1, 1, f_isdirectory }, + { "islocked", 1, 1, f_islocked }, + { "items", 1, 1, f_items }, + { "jobclose", 1, 2, f_jobclose }, + { "jobresize", 3, 3, f_jobresize }, + { "jobsend", 2, 2, f_jobsend }, + { "jobstart", 1, 2, f_jobstart }, + { "jobstop", 1, 1, f_jobstop }, + { "jobwait", 1, 2, f_jobwait }, + { "join", 1, 2, f_join }, + { "keys", 1, 1, f_keys }, + { "last_buffer_nr", 0, 0, f_last_buffer_nr }, // obsolete + { "len", 1, 1, f_len }, + { "libcall", 3, 3, f_libcall }, + { "libcallnr", 3, 3, f_libcallnr }, + { "line", 1, 1, f_line }, + { "line2byte", 1, 1, f_line2byte }, + { "lispindent", 1, 1, f_lispindent }, + { "localtime", 0, 0, f_localtime }, + { "log", 1, 1, f_log }, + { "log10", 1, 1, f_log10 }, + { "map", 2, 2, f_map }, + { "maparg", 1, 4, f_maparg }, + { "mapcheck", 1, 3, f_mapcheck }, + { "match", 2, 4, f_match }, + { "matchadd", 2, 4, f_matchadd }, + { "matchaddpos", 2, 4, f_matchaddpos }, + { "matcharg", 1, 1, f_matcharg }, + { "matchdelete", 1, 1, f_matchdelete }, + { "matchend", 2, 4, f_matchend }, + { "matchlist", 2, 4, f_matchlist }, + { "matchstr", 2, 4, f_matchstr }, + { "max", 1, 1, f_max }, + { "min", 1, 1, f_min }, + { "mkdir", 1, 3, f_mkdir }, + { "mode", 0, 1, f_mode }, + { "msgpackdump", 1, 1, f_msgpackdump }, + { "msgpackparse", 1, 1, f_msgpackparse }, + { "nextnonblank", 1, 1, f_nextnonblank }, + { "nr2char", 1, 2, f_nr2char }, + { "or", 2, 2, f_or }, + { "pathshorten", 1, 1, f_pathshorten }, + { "pow", 2, 2, f_pow }, + { "prevnonblank", 1, 1, f_prevnonblank }, + { "printf", 2, 19, f_printf }, + { "pumvisible", 0, 0, f_pumvisible }, + { "py3eval", 1, 1, f_py3eval }, + { "pyeval", 1, 1, f_pyeval }, + { "range", 1, 3, f_range }, + { "readfile", 1, 3, f_readfile }, + { "reltime", 0, 2, f_reltime }, + { "reltimestr", 1, 1, f_reltimestr }, + { "remove", 2, 3, f_remove }, + { "rename", 2, 2, f_rename }, + { "repeat", 2, 2, f_repeat }, + { "resolve", 1, 1, f_resolve }, + { "reverse", 1, 1, f_reverse }, + { "round", 1, 1, f_round }, + { "rpcnotify", 2, 64, f_rpcnotify }, + { "rpcrequest", 2, 64, f_rpcrequest }, + { "rpcstart", 1, 2, f_rpcstart }, + { "rpcstop", 1, 1, f_rpcstop }, + { "screenattr", 2, 2, f_screenattr }, + { "screenchar", 2, 2, f_screenchar }, + { "screencol", 0, 0, f_screencol }, + { "screenrow", 0, 0, f_screenrow }, + { "search", 1, 4, f_search }, + { "searchdecl", 1, 3, f_searchdecl }, + { "searchpair", 3, 7, f_searchpair }, + { "searchpairpos", 3, 7, f_searchpairpos }, + { "searchpos", 1, 4, f_searchpos }, + { "serverlist", 0, 0, f_serverlist }, + { "serverstart", 0, 1, f_serverstart }, + { "serverstop", 1, 1, f_serverstop }, + { "setbufvar", 3, 3, f_setbufvar }, + { "setcharsearch", 1, 1, f_setcharsearch }, + { "setcmdpos", 1, 1, f_setcmdpos }, + { "setline", 2, 2, f_setline }, + { "setloclist", 2, 3, f_setloclist }, + { "setmatches", 1, 1, f_setmatches }, + { "setpos", 2, 2, f_setpos }, + { "setqflist", 1, 2, f_setqflist }, + { "setreg", 2, 3, f_setreg }, + { "settabvar", 3, 3, f_settabvar }, + { "settabwinvar", 4, 4, f_settabwinvar }, + { "setwinvar", 3, 3, f_setwinvar }, + { "sha256", 1, 1, f_sha256 }, + { "shellescape", 1, 2, f_shellescape }, + { "shiftwidth", 0, 0, f_shiftwidth }, + { "simplify", 1, 1, f_simplify }, + { "sin", 1, 1, f_sin }, + { "sinh", 1, 1, f_sinh }, + { "sort", 1, 3, f_sort }, + { "soundfold", 1, 1, f_soundfold }, + { "spellbadword", 0, 1, f_spellbadword }, + { "spellsuggest", 1, 3, f_spellsuggest }, + { "split", 1, 3, f_split }, + { "sqrt", 1, 1, f_sqrt }, + { "str2float", 1, 1, f_str2float }, + { "str2nr", 1, 2, f_str2nr }, + { "strchars", 1, 1, f_strchars }, + { "strdisplaywidth", 1, 2, f_strdisplaywidth }, + { "strftime", 1, 2, f_strftime }, + { "stridx", 2, 3, f_stridx }, + { "string", 1, 1, f_string }, + { "strlen", 1, 1, f_strlen }, + { "strpart", 2, 3, f_strpart }, + { "strridx", 2, 3, f_strridx }, + { "strtrans", 1, 1, f_strtrans }, + { "strwidth", 1, 1, f_strwidth }, + { "submatch", 1, 2, f_submatch }, + { "substitute", 4, 4, f_substitute }, + { "synID", 3, 3, f_synID }, + { "synIDattr", 2, 3, f_synIDattr }, + { "synIDtrans", 1, 1, f_synIDtrans }, + { "synconcealed", 2, 2, f_synconcealed }, + { "synstack", 2, 2, f_synstack }, + { "system", 1, 2, f_system }, + { "systemlist", 1, 3, f_systemlist }, + { "tabpagebuflist", 0, 1, f_tabpagebuflist }, + { "tabpagenr", 0, 1, f_tabpagenr }, + { "tabpagewinnr", 1, 2, f_tabpagewinnr }, + { "tagfiles", 0, 0, f_tagfiles }, + { "taglist", 1, 1, f_taglist }, + { "tan", 1, 1, f_tan }, + { "tanh", 1, 1, f_tanh }, + { "tempname", 0, 0, f_tempname }, + { "termopen", 1, 2, f_termopen }, + { "test", 1, 1, f_test }, + { "tolower", 1, 1, f_tolower }, + { "toupper", 1, 1, f_toupper }, + { "tr", 3, 3, f_tr }, + { "trunc", 1, 1, f_trunc }, + { "type", 1, 1, f_type }, + { "undofile", 1, 1, f_undofile }, + { "undotree", 0, 0, f_undotree }, + { "uniq", 1, 3, f_uniq }, + { "values", 1, 1, f_values }, + { "virtcol", 1, 1, f_virtcol }, + { "visualmode", 0, 1, f_visualmode }, + { "wildmenumode", 0, 0, f_wildmenumode }, + { "winbufnr", 1, 1, f_winbufnr }, + { "wincol", 0, 0, f_wincol }, + { "winheight", 1, 1, f_winheight }, + { "winline", 0, 0, f_winline }, + { "winnr", 0, 1, f_winnr }, + { "winrestcmd", 0, 0, f_winrestcmd }, + { "winrestview", 1, 1, f_winrestview }, + { "winsaveview", 0, 0, f_winsaveview }, + { "winwidth", 1, 1, f_winwidth }, + { "writefile", 2, 3, f_writefile }, + { "xor", 2, 2, f_xor }, }; @@ -7981,6 +7986,110 @@ static void f_argv(typval_T *argvars, typval_T *rettv) } } +// Prepare "gap" for an assert error and add the sourcing position. +static void prepare_assert_error(garray_T *gap) +{ + char buf[NUMBUFLEN]; + + ga_init(gap, 1, 100); + if (sourcing_name != NULL) { + ga_concat(gap, sourcing_name); + if (sourcing_lnum > 0) { + ga_concat(gap, (char_u *)" "); + } + } + if (sourcing_lnum > 0) { + vim_snprintf(buf, ARRAY_SIZE(buf), "line %" PRId64, (long)sourcing_lnum); + ga_concat(gap, (char_u *)buf); + } + if (sourcing_name != NULL || sourcing_lnum > 0) { + ga_concat(gap, (char_u *)": "); + } +} + +// Fill "gap" with information about an assert error. +static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, + char_u *exp_str, typval_T *exp_tv, + typval_T *got_tv) +{ + char_u *tofree; + + if (opt_msg_tv->v_type != VAR_UNKNOWN) { + tofree = (char_u *) tv2string(opt_msg_tv, NULL); + ga_concat(gap, tofree); + xfree(tofree); + } else { + ga_concat(gap, (char_u *)"Expected "); + if (exp_str == NULL) { + tofree = (char_u *) tv2string(exp_tv, NULL); + ga_concat(gap, tofree); + xfree(tofree); + } else { + ga_concat(gap, exp_str); + } + tofree = (char_u *) tv2string(got_tv, NULL); + ga_concat(gap, (char_u *)" but got "); + ga_concat(gap, tofree); + xfree(tofree); + } +} + +// Add an assert error to v:errors. +static void assert_error(garray_T *gap) +{ + struct vimvar *vp = &vimvars[VV_ERRORS]; + + if (vp->vv_type != VAR_LIST || vimvars[VV_ERRORS].vv_list == NULL) { + // Make sure v:errors is a list. + set_vim_var_list(VV_ERRORS, list_alloc()); + } + list_append_string(vimvars[VV_ERRORS].vv_list, + gap->ga_data, gap->ga_len); +} + +// "assert_equal(expected, actual[, msg])" function +static void f_assert_equal(typval_T *argvars, typval_T *rettv) +{ + garray_T ga; + + if (!tv_equal(&argvars[0], &argvars[1], false, false)) { + prepare_assert_error(&ga); + fill_assert_error(&ga, &argvars[2], NULL, + &argvars[0], &argvars[1]); + assert_error(&ga); + ga_clear(&ga); + } +} + +// Common for assert_true() and assert_false(). +static void assert_bool(typval_T *argvars, bool isTrue) +{ + int error = (int)false; + garray_T ga; + + if (argvars[0].v_type != VAR_NUMBER || + (get_tv_number_chk(&argvars[0], &error) == 0) == isTrue || error) { + prepare_assert_error(&ga); + fill_assert_error(&ga, &argvars[1], + (char_u *)(isTrue ? "True" : "False"), + NULL, &argvars[0]); + assert_error(&ga); + ga_clear(&ga); + } +} + +// "assert_false(actual[, msg])" function +static void f_assert_false(typval_T *argvars, typval_T *rettv) +{ + assert_bool(argvars, false); +} + +// "assert_true(actual[, msg])" function +static void f_assert_true(typval_T *argvars, typval_T *rettv) +{ + assert_bool(argvars, true); +} + /* * "asin()" function */ diff --git a/src/nvim/eval.h b/src/nvim/eval.h index ea8b5bc253..79a1341d98 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -111,6 +111,7 @@ enum { VV_OPTION_NEW, VV_OPTION_OLD, VV_OPTION_TYPE, + VV_ERRORS, VV_MSGPACK_TYPES, VV_LEN, /* number of v: vars */ }; diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 75c3fb9a73..e6cbd9332b 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -174,6 +174,7 @@ char_u* ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET } /// Concatenate a string to a growarray which contains characters. +/// When "s" is NULL does not do anything. /// /// WARNING: /// - Does NOT copy the NUL at the end! @@ -183,6 +184,10 @@ char_u* ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET /// @param s void ga_concat(garray_T *gap, const char_u *restrict s) { + if (s == NULL) { + return; + } + int len = (int)strlen((char *) s); if (len) { ga_grow(gap, len); diff --git a/src/nvim/path.c b/src/nvim/path.c index d689eaf8cb..23b22b67f1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -581,9 +581,9 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL #ifndef WIN32 || (!p_fic && (flags & EW_ICASE) - && isalpha(PTR2CHAR(path_end)))) + && isalpha(PTR2CHAR(path_end))) #endif - ) { + )) { e = p; } if (has_mbyte) { diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 1a414a8847..b4292dbd4b 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -31,6 +31,8 @@ SCRIPTS := test_eval.out \ test_command_count.out \ test_cdo.out \ +NEW_TESTS = + SCRIPTS_GUI := test16.out @@ -62,9 +64,9 @@ ifdef TESTNUM SCRIPTS := test$(TESTNUM).out endif -nongui: nolog $(SCRIPTS) report +nongui: nolog $(SCRIPTS) newtests report -gui: nolog $(SCRIPTS) $(SCRIPTS_GUI) report +gui: nolog $(SCRIPTS) $(SCRIPTS_GUI) newtests report .gdbinit: echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit @@ -91,6 +93,7 @@ RUN_VIM := VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(VIMPROG) clean: -rm -rf *.out \ *.failed \ + *.res \ *.rej \ *.orig \ test.log \ @@ -147,3 +150,19 @@ test49.out: test49.vim nolog: -rm -f test.log + + +# New style of tests uses Vim script with assert calls. These are easier +# to write and a lot easier to read and debug. +# Limitation: Only works with the +eval feature. +RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin + +newtests: newtestssilent + @/bin/sh -c "if test -f messages && grep -q 'FAILED' messages; then \ + cat messages && cat test.log; \ + fi" \ + +newtestssilent: $(NEW_TESTS) + +%.res: %.vim .gdbinit + $(RUN_VIMTEST) -u runtest.vim $*.vim diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim new file mode 100644 index 0000000000..0dc142eb97 --- /dev/null +++ b/src/nvim/testdir/runtest.vim @@ -0,0 +1,97 @@ +" This script is sourced while editing the .vim file with the tests. +" When the script is successful the .res file will be created. +" Errors are appended to the test.log file. +" +" The test script may contain anything, only functions that start with +" "Test_" are special. These will be invoked and should contain assert +" functions. See test_assert.vim for an example. +" +" It is possible to source other files that contain "Test_" functions. This +" can speed up testing, since Vim does not need to restart. But be careful +" that the tests do not interfere with each other. +" +" If an error cannot be detected properly with an assert function add the +" error to the v:errors list: +" call add(v:errors, 'test foo failed: Cannot find xyz') +" +" If preparation for each Test_ function is needed, define a SetUp function. +" It will be called before each Test_ function. +" +" If cleanup after each Test_ function is needed, define a TearDown function. +" It will be called after each Test_ function. + +" Without the +eval feature we can't run these tests, bail out. +if 0 + quit! +endif + +" Check that the screen size is at least 24 x 80 characters. +if &lines < 24 || &columns < 80 + let error = 'Screen size too small! Tests require at least 24 lines with 80 characters' + echoerr error + split test.log + $put =error + w + cquit +endif + +" Source the test script. First grab the file name, in case the script +" navigates away. +let testname = expand('%') +source % + +" Locate Test_ functions and execute them. +redir @q +function /^Test_ +redir END +let tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g')) + +let done = 0 +let fail = 0 +let errors = [] +for test in tests + if exists("*SetUp") + call SetUp() + endif + + let done += 1 + try + exe 'call ' . test + catch + let fail += 1 + call add(v:errors, 'Caught exception in ' . test . ': ' . v:exception . ' @ ' . v:throwpoint) + endtry + + if len(v:errors) > 0 + let fail += 1 + call add(errors, 'Found errors in ' . test . ':') + call extend(errors, v:errors) + let v:errors = [] + endif + + if exists("*TearDown") + call TearDown() + endif +endfor + +if fail == 0 + " Success, create the .res file so that make knows it's done. + exe 'split ' . fnamemodify(testname, ':r') . '.res' + write +endif + +if len(errors) > 0 + " Append errors to test.log + split test.log + call append(line('$'), '') + call append(line('$'), 'From ' . testname . ':') + call append(line('$'), errors) + write +endif + +echo 'Executed ' . done . (done > 1 ? ' tests': ' test') +if fail > 0 + echo fail . ' FAILED' +endif + +qall! diff --git a/src/nvim/version.c b/src/nvim/version.c index 6919efe871..d0a2771a19 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -69,6 +69,61 @@ static char *features[] = { // clang-format off static int included_patches[] = { + 1055, + // 1054, + // 1053, + // 1052, + // 1051, + // 1050, + // 1049, + // 1048, + // 1047, + // 1046, + // 1045, + // 1044, + // 1043, + // 1042, + // 1041, + // 1040, + // 1039, + // 1038, + // 1037, + // 1036, + // 1035, + // 1034, + // 1033, + 1032, + // 1031, + // 1030, + // 1029, + // 1028, + // 1027, + // 1026, + // 1025, + // 1024, + // 1023, + // 1022, + // 1021, + // 1020, + // 1019, + // 1018, + // 1017, + // 1016, + // 1015, + // 1014, + // 1013, + // 1012, + // 1011, + // 1010, + // 1009, + // 1008, + // 1007, + // 1006, + // 1005, + // 1004, + // 1003, + // 1002, + // 1001, // 1000, // 999 NA // 998, @@ -116,16 +171,16 @@ static int included_patches[] = { // 956, // 955, // 954 NA - // 953, + 953, // 952, // 951, - // 950, + 950, // 949, // 948 NA // 947, - // 946, - // 945, - // 944, + 946, + 945, + 944, // 943, // 942, // 941, diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 50fa3fb1bd..1fba15c2c3 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,4 +1,5 @@ require('coxpcall') +local ffi = require('ffi') local lfs = require('lfs') local assert = require('luassert') local Loop = require('nvim.loop') @@ -246,9 +247,13 @@ end local function source(code) local tmpname = os.tmpname() + if ffi.os == 'OSX' and string.match(tmpname, '^/tmp') then + tmpname = '/private'..tmpname + end write_file(tmpname, code) nvim_command('source '..tmpname) os.remove(tmpname) + return tmpname end local function eq(expected, actual) diff --git a/test/functional/legacy/100_lispwords_spec.lua b/test/functional/legacy/100_lispwords_spec.lua new file mode 100644 index 0000000000..739a02f0b3 --- /dev/null +++ b/test/functional/legacy/100_lispwords_spec.lua @@ -0,0 +1,47 @@ +-- Tests for 'lispwords' setting being global-local + +local helpers = require('test.functional.helpers') +local source = helpers.source +local clear, expect = helpers.clear, helpers.expect + +describe('lispwords', function() + setup(clear) + + it('global-local', function() + source([[ + setglobal lispwords=foo,bar,baz + setlocal lispwords-=foo + setlocal lispwords+=quux + redir @A + echo "Testing 'lispwords' local value" + setglobal lispwords? + setlocal lispwords? + echo &lispwords + echo '' + redir end + setlocal lispwords< + redir @A + echo "Testing 'lispwords' value reset" + setglobal lispwords? + setlocal lispwords? + echo &lispwords + redir end + + 0put a + $d + ]]) + + -- Assert buffer contents. + expect([[ + + Testing 'lispwords' local value + lispwords=foo,bar,baz + lispwords=bar,baz,quux + bar,baz,quux + + Testing 'lispwords' value reset + lispwords=foo,bar,baz + lispwords=foo,bar,baz + foo,bar,baz]]) + end) +end) diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua deleted file mode 100644 index 3bf72341d6..0000000000 --- a/test/functional/legacy/100_undo_level_spec.lua +++ /dev/null @@ -1,142 +0,0 @@ --- Tests for 'undolevel' setting being global-local - -local helpers = require('test.functional.helpers') -local source = helpers.source -local clear, expect = helpers.clear, helpers.expect - -describe('undolevel', function() - setup(clear) - - it('is working', function() - source([[ - set ul=5 - fu! FillBuffer() - for i in range(1,13) - put=i - exe "setg ul=" . &g:ul - endfor - endfu - fu! UndoLevel() - redir @z - setglobal undolevels? - echon ' global' - setlocal undolevels? - echon ' local' - redir end - $put z - endfu - - 0put ='ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' - call FillBuffer() - setlocal undolevels< - earlier 10 - call UndoLevel() - set ff=unix - %yank A - %delete - - 0put ='TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards)' - setlocal ul=2 - call FillBuffer() - earlier 10 - call UndoLevel() - setlocal ul=10 - call UndoLevel() - set ff=unix - %yank A - %delete - setlocal undolevels< - redir @A - echo "global value shouldn't be changed and still be 5!" - echo 'ONE: expecting global undolevels: 5, local undolevels: -123456 (default)' - setglobal undolevels? - echon ' global' - setlocal undolevels? - echon ' local' - echo "" - redir end - - setglobal ul=50 - 1put ='global value should be changed to 50' - 2put ='THREE: expecting global undolevels: 50, local undolevels: -123456 (default)' - call UndoLevel() - set ff=unix - %yank A - %delete - setglobal lispwords=foo,bar,baz - setlocal lispwords-=foo - setlocal lispwords+=quux - redir @A - echo "Testing 'lispwords' local value" - setglobal lispwords? - setlocal lispwords? - echo &lispwords - echo '' - redir end - setlocal lispwords< - redir @A - echo "Testing 'lispwords' value reset" - setglobal lispwords? - setlocal lispwords? - echo &lispwords - redir end - - 0put a - $d - ]]) - - -- Assert buffer contents. - expect([[ - ONE: expecting global undolevels: 5, local undolevels: -123456 (default) - 1 - 2 - 3 - 4 - 5 - 6 - 7 - - - undolevels=5 global - undolevels=-123456 local - TWO: expecting global undolevels: 5, local undolevels: 2 (first) then 10 (afterwards) - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - - - undolevels=5 global - undolevels=2 local - - undolevels=5 global - undolevels=10 local - - global value shouldn't be changed and still be 5! - ONE: expecting global undolevels: 5, local undolevels: -123456 (default) - undolevels=5 global - undolevels=-123456 local - - global value should be changed to 50 - THREE: expecting global undolevels: 50, local undolevels: -123456 (default) - - undolevels=50 global - undolevels=-123456 local - - Testing 'lispwords' local value - lispwords=foo,bar,baz - lispwords=bar,baz,quux - bar,baz,quux - - Testing 'lispwords' value reset - lispwords=foo,bar,baz - lispwords=foo,bar,baz - foo,bar,baz]]) - end) -end) diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua new file mode 100644 index 0000000000..1ce665360d --- /dev/null +++ b/test/functional/legacy/assert_spec.lua @@ -0,0 +1,145 @@ +local helpers = require('test.functional.helpers') +local nvim, call = helpers.meths, helpers.call +local clear, eq = helpers.clear, helpers.eq +local source, execute = helpers.source, helpers.execute + +local function expected_errors(errors) + eq(errors, nvim.get_vvar('errors')) +end + +local function expected_empty() + eq({}, nvim.get_vvar('errors')) +end + +describe('assert function:', function() + + before_each(function() + clear() + end) + + -- assert_equal({expected}, {actual}, [, {msg}]) + describe('assert_equal', function() + it('should not change v:errors when expected is equal to actual', function() + source([[ + let s = 'foo' + call assert_equal('foo', s) + let n = 4 + call assert_equal(4, n) + let l = [1, 2, 3] + call assert_equal([1, 2, 3], l) + fu Func() + endfu + let F1 = function('Func') + let F2 = function('Func') + call assert_equal(F1, F2) + ]]) + expected_empty() + end) + + it('should not change v:errors when expected is equal to actual', function() + call('assert_equal', '', '') + call('assert_equal', 'string', 'string') + expected_empty() + end) + + it('should change v:errors when expected is not equal to actual', function() + call('assert_equal', 0, {0}) + expected_errors({'Expected 0 but got [0]'}) + end) + + it('should change v:errors when expected is not equal to actual', function() + call('assert_equal', 0, "0") + expected_errors({"Expected 0 but got '0'"}) + end) + + it('should change v:errors when expected is not equal to actual', function() + -- Lua does not tell integer from float. + execute('call assert_equal(1, 1.0)') + expected_errors({'Expected 1 but got 1.0'}) + end) + + it('should change v:errors when expected is not equal to actual', function() + call('assert_equal', 'true', 'false') + expected_errors({"Expected 'true' but got 'false'"}) + end) + end) + + -- assert_false({actual}, [, {msg}]) + describe('assert_false', function() + it('should not change v:errors when actual is false', function() + call('assert_false', 0) + call('assert_false', false) + expected_empty() + end) + + it('should change v:errors when actual is not false', function() + call('assert_false', 1) + expected_errors({'Expected False but got 1'}) + end) + + it('should change v:errors when actual is not false', function() + call('assert_false', {}) + expected_errors({'Expected False but got []'}) + end) + end) + + -- assert_true({actual}, [, {msg}]) + describe('assert_true', function() + it('should not change v:errors when actual is true', function() + call('assert_true', 1) + call('assert_true', -1) -- In Vim script, non-zero Numbers are TRUE. + call('assert_true', true) + expected_empty() + end) + + it('should change v:errors when actual is not true', function() + call('assert_true', 1.5) + expected_errors({'Expected True but got 1.5'}) + end) + end) + + describe('v:errors', function() + it('should be initialized at startup', function() + expected_empty() + end) + + it('should have function names and relative line numbers', function() + source([[ + fu Func_one() + call assert_equal([0], {'0' : 0}) + call assert_false('False') + call assert_true("True") + endfu + fu Func_two() + " for shifting a line number + call assert_true('line two') + endfu + ]]) + call('Func_one') + call('Func_two') + expected_errors({ + "function Func_one line 1: Expected [0] but got {'0': 0}", + "function Func_one line 2: Expected False but got 'False'", + "function Func_one line 3: Expected True but got 'True'", + "function Func_two line 2: Expected True but got 'line two'", + }) + end) + + it('should have file names and passed messages', function() + local tmpname_one = source([[ + call assert_equal(1, 100, 'equal assertion failed') + call assert_false('true', 'true assertion failed') + call assert_true('false', 'false assertion failed') + ]]) + local tmpname_two = source([[ + call assert_true('', 'file two') + ]]) + expected_errors({ + tmpname_one .. " line 1: 'equal assertion failed'", + tmpname_one .. " line 2: 'true assertion failed'", + tmpname_one .. " line 3: 'false assertion failed'", + tmpname_two .. " line 1: 'file two'", + }) + end) + end) +end) diff --git a/test/functional/legacy/undolevels_spec.lua b/test/functional/legacy/undolevels_spec.lua new file mode 100644 index 0000000000..41274b3a04 --- /dev/null +++ b/test/functional/legacy/undolevels_spec.lua @@ -0,0 +1,58 @@ +local helpers = require('test.functional.helpers') +local source, clear = helpers.source, helpers.clear +local eq, nvim = helpers.eq, helpers.meths + +describe('undolevel', function() + setup(clear) + + it('is working', function() + source([[ + func FillBuffer() + for i in range(1,13) + put=i + " Set 'undolevels' to split undo. + exe "setg ul=" . &g:ul + endfor + endfunc + + func Test_global_local_undolevels() + new one + set undolevels=5 + call FillBuffer() + " will only undo the last 5 changes, end up with 13 - (5 + 1) = 7 lines + earlier 10 + call assert_equal(5, &g:undolevels) + call assert_equal(-123456, &l:undolevels) + call assert_equal('7', getline('$')) + + new two + setlocal undolevels=2 + call FillBuffer() + " will only undo the last 2 changes, end up with 13 - (2 + 1) = 10 lines + earlier 10 + call assert_equal(5, &g:undolevels) + call assert_equal(2, &l:undolevels) + call assert_equal('10', getline('$')) + + setlocal ul=10 + call assert_equal(5, &g:undolevels) + call assert_equal(10, &l:undolevels) + + " Setting local value in "two" must not change local value in "one" + wincmd p + call assert_equal(5, &g:undolevels) + call assert_equal(-123456, &l:undolevels) + + new three + setglobal ul=50 + call assert_equal(50, &g:undolevels) + call assert_equal(-123456, &l:undolevels) + + endfunc + + call Test_global_local_undolevels() + ]]) + + eq({}, nvim.get_vvar('errors')) + end) +end) |