diff --git a/runtime/compiler/cs.vim b/runtime/compiler/cs.vim index 4cc1784678..4f6dd3cdfd 100644 --- a/runtime/compiler/cs.vim +++ b/runtime/compiler/cs.vim @@ -1,8 +1,8 @@ " Vim compiler file -" Compiler: Microsoft Visual Studio C# -" Maintainer: Zhou YiChao (broken.zhou@gmail.com) -" Previous Maintainer: Joseph H. Yao (hyao@sina.com) -" Last Change: 2012 Apr 30 +" Compiler: Microsoft Visual Studio C# +" Maintainer: Yichao Zhou (broken.zhou@gmail.com) +" Previous Maintainer: Joseph H. Yao (hyao@sina.com) +" Last Change: Jul 22, 2019 if exists("current_compiler") finish @@ -20,7 +20,7 @@ CompilerSet errorformat+=%f(%l\\,%v):\ %t%*[^:]:\ %m, \%trror%*[^:]:\ %m, \%tarning%*[^:]:\ %m -CompilerSet makeprg=csc\ % +CompilerSet makeprg=csc\ %:S let &cpo = s:keepcpo unlet s:keepcpo diff --git a/runtime/compiler/erlang.vim b/runtime/compiler/erlang.vim index e177a279c5..e22887e05e 100644 --- a/runtime/compiler/erlang.vim +++ b/runtime/compiler/erlang.vim @@ -1,13 +1,13 @@ " Vim compiler file " Compiler: Erlang " Maintainer: Dmitry Vasiliev -" Last Change: 2012-02-13 +" Last Change: 2019 Jul 23 if exists("current_compiler") finish endif let current_compiler = "erlang" -CompilerSet makeprg=erlc\ -Wall\ % +CompilerSet makeprg=erlc\ -Wall\ %:S CompilerSet errorformat=%f:%l:\ %m diff --git a/runtime/compiler/fortran_cv.vim b/runtime/compiler/fortran_cv.vim index 089d3b27c2..bc217bdc66 100644 --- a/runtime/compiler/fortran_cv.vim +++ b/runtime/compiler/fortran_cv.vim @@ -22,7 +22,7 @@ CompilerSet errorformat= \%-Z%p%^%.%#, \%-G%.%#, " Compiler call -CompilerSet makeprg=df\ /nologo\ /noobj\ /c\ % +CompilerSet makeprg=df\ /nologo\ /noobj\ /c\ %:S " Visual fortran defaults to printing output on stderr " Adjust option shellpipe accordingly diff --git a/runtime/compiler/jikes.vim b/runtime/compiler/jikes.vim index 5125128535..2d4500e894 100644 --- a/runtime/compiler/jikes.vim +++ b/runtime/compiler/jikes.vim @@ -1,7 +1,7 @@ " Vim Compiler File " Compiler: Jikes " Maintainer: Dan Sharp -" Last Change: 20 Jan 2009 +" Last Change: 2019 Jul 23 " URL: http://dwsharp.users.sourceforge.net/vim/compiler if exists("current_compiler") @@ -14,5 +14,5 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal endif " Jikes defaults to printing output on stderr -CompilerSet makeprg=jikes\ -Xstdout\ +E\ \"%\" +CompilerSet makeprg=jikes\ -Xstdout\ +E\ \"%:S\" CompilerSet errorformat=%f:%l:%v:%*\\d:%*\\d:%*\\s%m diff --git a/runtime/compiler/onsgmls.vim b/runtime/compiler/onsgmls.vim index 130d3e21b3..68925ef459 100644 --- a/runtime/compiler/onsgmls.vim +++ b/runtime/compiler/onsgmls.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: onsgmls " Maintainer: Robert Rowsome -" Last Change: 2004 Mar 27 +" Last Change: 2019 Jul 23 if exists("current_compiler") finish @@ -15,7 +15,7 @@ endif let s:cpo_save = &cpo set cpo-=C -CompilerSet makeprg=onsgmls\ -s\ % +CompilerSet makeprg=onsgmls\ -s\ %:S CompilerSet errorformat=onsgmls:%f:%l:%c:%t:%m, \onsgmls:%f:%l:%c:%m diff --git a/runtime/compiler/perl.vim b/runtime/compiler/perl.vim index 583c6c3787..a857caed8f 100644 --- a/runtime/compiler/perl.vim +++ b/runtime/compiler/perl.vim @@ -1,7 +1,7 @@ " Vim Compiler File " Compiler: Perl syntax checks (perl -Wc) " Maintainer: Christian J. Robinson -" Last Change: 2006 Aug 13 +" Last Change: 2019 Jul 22 if exists("current_compiler") finish @@ -27,7 +27,7 @@ else let s:taintopt = '' endif -exe 'CompilerSet makeprg=perl\ -' . s:warnopt . s:taintopt . 'c\ %' +exe 'CompilerSet makeprg=perl\ -' . s:warnopt . s:taintopt . 'c\ %:S' CompilerSet errorformat= \%-G%.%#had\ compilation\ errors., diff --git a/runtime/compiler/rustc.vim b/runtime/compiler/rustc.vim index c27bdc9c0c..5e5b9a4e0a 100644 --- a/runtime/compiler/rustc.vim +++ b/runtime/compiler/rustc.vim @@ -19,7 +19,7 @@ endif if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent != 0 CompilerSet makeprg=rustc else - CompilerSet makeprg=rustc\ \% + CompilerSet makeprg=rustc\ \%:S endif " Old errorformat (before nightly 2016/08/10) diff --git a/runtime/compiler/splint.vim b/runtime/compiler/splint.vim index 6239ca7139..3d7ada6d1d 100644 --- a/runtime/compiler/splint.vim +++ b/runtime/compiler/splint.vim @@ -2,7 +2,7 @@ " Compiler: splint/lclint (C source code checker) " Maintainer: Ralf Wildenhues " Splint Home: http://www.splint.org/ -" Last Change: 2005 Apr 21 +" Last Change: 2019 Jul 23 " $Revision: 1.3 $ if exists("current_compiler") @@ -19,7 +19,7 @@ set cpo-=C " adapt this if you want to check more than one file at a time. " put command line options in .splintrc or ~/.splintrc -CompilerSet makeprg=splint\ % +CompilerSet makeprg=splint\ %:S " Note: when using the new array bounds checking flags: Each warning " usually has several lines and several references to source code mostly diff --git a/runtime/compiler/xmlwf.vim b/runtime/compiler/xmlwf.vim index cd2e2bb6ad..3de9d08d55 100644 --- a/runtime/compiler/xmlwf.vim +++ b/runtime/compiler/xmlwf.vim @@ -1,7 +1,7 @@ " Vim Compiler File " Compiler: xmlwf " Maintainer: Robert Rowsome -" Last Change: 2004 Mar 27 +" Last Change: 2019 Jul 23 if exists("current_compiler") finish @@ -15,7 +15,7 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal endif -CompilerSet makeprg=xmlwf\ % +CompilerSet makeprg=xmlwf\ %:S CompilerSet errorformat=%f:%l%c:%m diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index ae8039f7ca..dcc3035d41 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -325,7 +325,7 @@ After setting this variable, reload the syntax script: > FINDING THE DIFFERENCES *diff-diffexpr* The 'diffexpr' option can be set to use something else than the standard -"diff" program to compare two files and find the differences. +"diff" program to compare two files and find the differences. *E959* When 'diffexpr' is empty, Vim uses this command to find the differences between file1 and file2: > diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4dd10bff9c..85a0cefe38 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1589,7 +1589,7 @@ v:exception The value of the exception most recently caught and not :try : throw "oops" :catch /.*/ - : echo "caught" v:exception + : echo "caught " .. v:exception :endtry < Output: "caught oops". @@ -3983,7 +3983,10 @@ get({list}, {idx} [, {default}]) *get()* get({dict}, {key} [, {default}]) Get item with key {key} from |Dictionary| {dict}. When this item is not available return {default}. Return zero when - {default} is omitted. + {default} is omitted. Useful example: > + let val = get(g:, 'var_name', 'default') +< This gets the value of g:var_name if it exists, and uses + 'default' when it does not exist. get({func}, {what}) Get item {what} from Funcref {func}. Possible values for {what} are: @@ -6645,7 +6648,8 @@ remove({list}, {idx} [, {end}]) *remove()* :echo "last item: " . remove(mylist, -1) :call remove(mylist, 0, 9) remove({dict}, {key}) - Remove the entry from {dict} with key {key}. Example: > + Remove the entry from {dict} with key {key} and return it. + Example: > :echo "removed " . remove(dict, "one") < If there is no {key} in {dict} this is an error. diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index 6dcf3f9fa9..f886fd28c5 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -189,16 +189,16 @@ To see the LuaJIT version: > :lua print(jit.version) < -:[range]lua << {endmarker} +:[range]lua << [endmarker] {script} {endmarker} - Execute Lua script {script}. + Execute Lua script {script}. Useful for including Lua + code in Vim scripts. -{endmarker} must NOT be preceded by any white space. If {endmarker} is -omitted from after the "<<", a dot '.' must be used after {script}, like -for the |:append| and |:insert| commands. -This form of the |:lua| command is mainly useful for including Lua code -in Vim scripts. +The {endmarker} must NOT be preceded by any white space. + +If [endmarker] is omitted from after the "<<", a dot '.' must be used after +{script}, like for the |:append| and |:insert| commands. Example: > diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index ac725a9b5d..ed3bdcf277 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -19,18 +19,17 @@ Commands *python-commands* the `:python` command is working: > :python print "Hello" -:[range]py[thon] << {endmarker} +:[range]py[thon] << [endmarker] {script} {endmarker} - Execute Python script {script}. - Note: This command doesn't work when Python isn't - available. To avoid errors, see |script-here|. + Execute Python script {script}. Useful for including + python code in Vim scripts. Requires Python, see + |script-here|. -{endmarker} must NOT be preceded by any white space. If {endmarker} is -omitted from after the "<<", a dot '.' must be used after {script}, like -for the |:append| and |:insert| commands. -This form of the |:python| command is mainly useful for including python code -in Vim scripts. +The {endmarker} below the {script} must NOT be preceded by any white space. + +If [endmarker] is omitted from after the "<<", a dot '.' must be used after +{script}, like for the |:append| and |:insert| commands. Example: > function! IcecreamInitialize() diff --git a/runtime/doc/if_ruby.txt b/runtime/doc/if_ruby.txt index 3c7c800fbf..6468e4c81e 100644 --- a/runtime/doc/if_ruby.txt +++ b/runtime/doc/if_ruby.txt @@ -19,15 +19,19 @@ downloading Ruby there. :rub[y] {cmd} Execute Ruby command {cmd}. A command to try it out: > :ruby print "Hello" -:rub[y] << {endpattern} +:rub[y] << [endpattern] {script} {endpattern} Execute Ruby script {script}. - {endpattern} must NOT be preceded by any white space. - If {endpattern} is omitted, it defaults to a dot '.' - like for the |:append| and |:insert| commands. This - form of the |:ruby| command is mainly useful for + The {endpattern} after {script} must NOT be preceded + by any white space. + + If [endpattern] is omitted, it defaults to a dot '.' + like for the |:append| and |:insert| commands. + + This form of the |:ruby| command is mainly useful for including ruby code in vim scripts. + Note: This command doesn't work when the Ruby feature wasn't compiled in. To avoid errors, see |script-here|. diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt index e69497e1ab..a99d84e969 100644 --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -827,7 +827,7 @@ PHP indenting can be altered in several ways by modifying the values of some global variables: *php-comment* *PHP_autoformatcomment* -To not enable auto-formatting of comments by default (if you want to use your +To not enable auto-formating of comments by default (if you want to use your own 'formatoptions'): > :let g:PHP_autoformatcomment = 0 @@ -897,7 +897,7 @@ NOTE: Indenting will be a bit slower if this option is used because some optimizations won't be available. ------------- - *PHP_vintage_case_default_indent* + *PHP_vintage_case_default_indent* To indent 'case:' and 'default:' statements in switch() blocks: > :let g:PHP_vintage_case_default_indent = 1 @@ -924,6 +924,41 @@ You will obtain the following result: > ->age() ->info(); +------------- + + *PHP_IndentFunctionCallParameters* +Extra indentation levels to add to parameters in multi-line function calls. > + let g:PHP_IndentFunctionCallParameters = 1 + +Function call arguments will indent 1 extra level. For two-space indentation: > + + function call_the_thing( + $with_this, + $and_that + ) { + $this->do_the_thing( + $with_this, + $and_that + ); + } + +------------- + + *PHP_IndentFunctionDeclarationParameters* +Extra indentation levels to add to arguments in multi-line function definitions. > + let g:PHP_IndentFunctionDeclarationParameters = 1 + +Function arguments in declarations will indent 1 extra level. For two-space indentation: > + + function call_the_thing( + $with_this, + $and_that + ) { + $this->do_the_thing( + $with_this, + $and_that + ); + } PYTHON *ft-python-indent* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 389bc486f0..7e6f4529b8 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -676,7 +676,7 @@ After doing this once, Nvim sets the $VIMRUNTIME environment variable. In case you need the value of $VIMRUNTIME in a shell (e.g., for a script that greps in the help files) you might be able to use this: > - VIMRUNTIME="$(nvim -e --cmd 'echo $VIMRUNTIME|quit' 2>&1)" + VIMRUNTIME="$(nvim --clean --headless --cmd 'echo $VIMRUNTIME|q')" ============================================================================== 4. Suspending *suspend* diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 0bad1c87d6..18a58a569e 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -138,6 +138,10 @@ CTRL-W CTRL-S *CTRL-W_CTRL-S* Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. Also see |++opt| and |+cmd|. + *E242* + Be careful when splitting a window in an autocommand, it may + mess up the window layout if this happens while making other + window layout changes. CTRL-W CTRL-V *CTRL-W_CTRL-V* CTRL-W v *CTRL-W_v* @@ -635,6 +639,8 @@ can also get to them with the buffer list commands, like ":bnext". |:vertical| was prepended). Buf/Win Enter/Leave autocommands are not executed for the new windows here, that's only done when they are really entered. + If autocommands change the window layout while this command is + busy an error will be given. *E249* :[N]sa[rgument][!] [++opt] [+cmd] [N] *:sa* *:sargument* Short for ":split | argument [N]": split window and go to Nth diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim index 5dee6c9f47..67a1327dc9 100644 --- a/runtime/indent/php.vim +++ b/runtime/indent/php.vim @@ -1,10 +1,10 @@ " Vim indent file " Language: PHP -" Author: John Wellesz -" URL: http://www.2072productions.com/vim/indent/php.vim +" Author: John Wellesz +" URL: https://www.2072productions.com/vim/indent/php.vim " Home: https://github.com/2072/PHP-Indenting-for-VIm -" Last Change: 2018 May 18th -" Version: 1.66 +" Last Change: 2019 Jully 21st +" Version: 1.70 " " " Type :help php-indent for available options @@ -19,7 +19,7 @@ " NOTE: This script must be used with PHP syntax ON and with the php syntax " script by Lutz Eymers (http://www.isp.de/data/php.vim ) or with the -" script by Peter Hodge (http://www.vim.org/scripts/script.php?script_id=1571 ) +" script by Peter Hodge (https://www.vim.org/scripts/script.php?script_id=1571 ) " the later is bunbdled by default with Vim 7. " " @@ -41,7 +41,6 @@ " silently remove them when VIM load this script (at each bufread). - if exists("b:did_indent") finish endif @@ -95,7 +94,17 @@ else let b:PHP_vintage_case_default_indent = 0 endif +if exists("PHP_IndentFunctionCallParameters") + let b:PHP_IndentFunctionCallParameters = PHP_IndentFunctionCallParameters +else + let b:PHP_IndentFunctionCallParameters = 0 +endif +if exists("PHP_IndentFunctionDeclarationParameters") + let b:PHP_IndentFunctionDeclarationParameters = PHP_IndentFunctionDeclarationParameters +else + let b:PHP_IndentFunctionDeclarationParameters = 0 +endif let b:PHP_lastindented = 0 let b:PHP_indentbeforelast = 0 @@ -129,15 +138,19 @@ endif if exists("*GetPhpIndent") call ResetPhpOptions() - finish + finish " XXX -- comment this line for easy dev endif -let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' -let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\)' -let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|trait\>\|use\>\|interface\>\|abstract\>\|final\>\|try\>\|\%(}\s*\)\=catch\>\|\%(}\s*\)\=finally\>\)' -let s:functionDecl = '\\%(\s\+&\='.s:PHP_validVariable.'\)\=\s*(.*' let s:endline = '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$' +let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' +let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\|end\%(if\|while\|for\|foreach\|switch\)\)' +let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|trait\>\|\%()\s*\)\=use\>\|interface\>\|abstract\>\|final\>\|try\>\|\%(}\s*\)\=catch\>\|\%(}\s*\)\=finally\>\)' +let s:functionDeclPrefix = '\\%(\s\+&\='.s:PHP_validVariable.'\)\=\s*(' +let s:functionDecl = s:functionDeclPrefix.'.*' +let s:multilineFunctionDecl = s:functionDeclPrefix.s:endline +let s:arrayDecl = '\\s*(.*' +let s:multilineFunctionCall = s:PHP_validVariable.'\s*('.s:endline let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@\)'.s:endline @@ -210,7 +223,7 @@ function! GetLastRealCodeLNum(startline) " {{{ while getline(lnum) !~? tofind && lnum > 1 let lnum = lnum - 1 endwhile - elseif lastline =~ '^[^''"`]*[''"`][;,]'.s:endline + elseif lastline =~ '^\s*[''"`][;,]' || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails") let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$\\|^[^\1]\\+[=([]\\s*[\1]', '') let trylnum = lnum @@ -289,17 +302,23 @@ function! FindOpenBracket(lnum, blockStarter) " {{{ endfun " }}} let s:blockChars = {'{':1, '[': 1, '(': 1, ')':-1, ']':-1, '}':-1} +let s:blockCharsLUT = {'{':'{', '}':'{', '[':'[', ']':'[', '(':'(', ')':'('} function! BalanceDirection (str) - let balance = 0 + let balance = {'{':0, '[': 0, '(': 0, 'none':0} + let director = 'none' for c in split(a:str, '\zs') if has_key(s:blockChars, c) - let balance += s:blockChars[c] + let balance[s:blockCharsLUT[c]] += s:blockChars[c] + + if balance[s:blockCharsLUT[c]] + let director = s:blockCharsLUT[c] + endif endif endfor - return balance + return balance[director] endfun function! StripEndlineComments (line) @@ -308,7 +327,8 @@ endfun function! FindArrowIndent (lnum) " {{{ - let parrentArrowPos = 0 + let parrentArrowPos = -1 + let cursorPos = -1 let lnum = a:lnum while lnum > 1 let last_line = getline(lnum) @@ -316,31 +336,46 @@ function! FindArrowIndent (lnum) " {{{ let parrentArrowPos = indent(a:lnum) break else - call cursor(lnum, 1) - let cleanedLnum = StripEndlineComments(last_line) - if cleanedLnum =~ '->' - if ! b:PHP_noArrowMatching - let parrentArrowPos = searchpos('->', 'W', lnum)[1] - 1 - else - let parrentArrowPos = indent(lnum) + shiftwidth() - endif - break - elseif cleanedLnum =~ ')'.s:endline && BalanceDirection(last_line) < 0 - call searchpos(')'.s:endline, 'cW', lnum) - let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()') - if openedparent != lnum - let lnum = openedparent - else - let openedparent = -1 - endif + if b:PHP_noArrowMatching + break + endif + + let cleanedLnum = StripEndlineComments(last_line) + + if cleanedLnum =~ ')'.s:endline + if BalanceDirection(cleanedLnum) <= 0 + call cursor(lnum, 1) + call searchpos(')'.s:endline, 'cW', lnum) + let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()') + let cursorPos = col(".") + if openedparent != lnum + let lnum = openedparent + continue + else + endif + else + let parrentArrowPos = -1 + break + end + endif + + if cleanedLnum =~ '->' + call cursor(lnum, cursorPos == -1 ? strwidth(cleanedLnum) : cursorPos) + let parrentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1 + + break else - let parrentArrowPos = indent(lnum) + shiftwidth() + let parrentArrowPos = -1 break endif endif endwhile + if parrentArrowPos == -1 + let parrentArrowPos = indent(lnum) + shiftwidth() + end + return parrentArrowPos endfun "}}} @@ -432,7 +467,7 @@ function! IslinePHP (lnum, tofind) " {{{ let synname = synIDattr(synID(a:lnum, coltotest, 0), "name") if synname ==? 'phpStringSingle' || synname ==? 'phpStringDouble' || synname ==? 'phpBacktick' - if cline !~ '^\s*[''"`]' + if cline !~ '^\s*[''"`]' " ??? XXX return "SpecStringEntrails" else return synname @@ -471,7 +506,7 @@ endfunc call ResetPhpOptions() function! GetPhpIndentVersion() - return "1.66-bundle" + return "1.70-bundle" endfun function! GetPhpIndent() @@ -615,7 +650,7 @@ function! GetPhpIndent() let b:InPHPcode_and_script = 1 endif - elseif last_line =~ '^[^''"`]\+[''"`]$' " a string identifier with nothing after it and no other string identifier before + elseif last_line =~ '^[^''"`]\+[''"`]$' && last_line !~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' " a string identifier with nothing after it and no other string identifier before let b:InPHPcode = -1 let b:InPHPcode_tofind = substitute( last_line, '^.*\([''"`]\).*$', '^[^\1]*\1[;,]$', '') elseif last_line =~? '<<<\s*[''"]\=\a\w*[''"]\=$' @@ -723,7 +758,7 @@ function! GetPhpIndent() endif - if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase + if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase && last_line !~ '^\s*[''"`][;,]' if ind==b:PHP_default_indenting return b:PHP_default_indenting + addSpecial elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)' && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline @@ -869,6 +904,14 @@ function! GetPhpIndent() let ind = ind + shiftwidth() endif + if b:PHP_IndentFunctionCallParameters && last_line =~ s:multilineFunctionCall && last_line !~ s:structureHead && last_line !~ s:arrayDecl + let ind = ind + b:PHP_IndentFunctionCallParameters * shiftwidth() + endif + + if b:PHP_IndentFunctionDeclarationParameters && last_line =~ s:multilineFunctionDecl + let ind = ind + b:PHP_IndentFunctionDeclarationParameters * shiftwidth() + endif + if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1 let b:PHP_CurrentIndentLevel = ind @@ -897,10 +940,15 @@ function! GetPhpIndent() endif if cline =~ '^\s*[)\]];\=' - let ind = ind - shiftwidth() - endif + call cursor(v:lnum, 1) + call searchpos('[)\]]', 'cW') + let matchedBlockChar = cline[col('.')-1] + let openedparent = searchpair('\M'.s:blockCharsLUT[matchedBlockChar], '', '\M'.matchedBlockChar, 'bW', 'Skippmatch()') + if openedparent != v:lnum + let ind = indent(openedparent) + endif - if last_line =~ '^\s*->' && last_line !~? s:structureHead && BalanceDirection(last_line) <= 0 + elseif last_line =~ '^\s*->' && last_line !~? s:structureHead && BalanceDirection(last_line) <= 0 let ind = ind - shiftwidth() endif diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index 148a86ed67..3df6abbf97 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -3,10 +3,13 @@ " Maintainer: Christian Brabandt " Original Author: Nikolai Weibull " Previous Maintainer: Peter Aronoff -" Latest Revision: 2019-04-27 +" Latest Revision: 2019-07-26 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-sh-indent " Changelog: +" 20190726 - Correctly skip if keywords in syntax comments +" (issue #17) +" 20190603 - Do not indent in zsh filetypes with an `if` in comments " 20190428 - De-indent fi correctly when typing with " https://github.com/chrisbra/vim-sh-indent/issues/15 " 20190325 - Indent fi; correctly @@ -80,8 +83,9 @@ function! GetShIndent() let ind = indent(lnum) " Check contents of previous lines + " should not apply to e.g. commented lines if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>' || - \ (&ft is# 'zsh' && line =~ '\<\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>') + \ (&ft is# 'zsh' && line =~ '^\s*\<\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>') if !s:is_end_expression(line) let ind += s:indent_value('default') endif @@ -129,7 +133,8 @@ function! GetShIndent() " Current line is a endif line, so get indent from start of "if condition" line " TODO: should we do the same for other "end" lines? if curline =~ '^\s*\%(fi\);\?\s*\%(#.*\)\=$' - let previous_line = searchpair('\', '', '\\zs', 'bnW') + let ind = indent(v:lnum) + let previous_line = searchpair('\', '', '\\zs', 'bnW', 'synIDattr(synID(line("."),col("."), 1),"name") =~? "comment"') if previous_line > 0 let ind = indent(previous_line) endif diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim index ad22de1d50..883af98563 100644 --- a/runtime/indent/xml.vim +++ b/runtime/indent/xml.vim @@ -1,9 +1,10 @@ " Language: xml " Repository: https://github.com/chrisbra/vim-xml-ftplugin -" Last Changed: Feb 04, 2019 +" Last Changed: July 27, 2019 " Maintainer: Christian Brabandt " Previous Maintainer: Johannes Zellner " Last Change: +" 20190726 - Correctly handle non-tagged data " 20190204 - correctly handle wrap tags " https://github.com/chrisbra/vim-xml-ftplugin/issues/5 " 20190128 - Make sure to find previous tag @@ -33,6 +34,8 @@ set cpo&vim " Attention: Parameter use_syntax_check is used by the docbk.vim indent script setlocal indentexpr=XmlIndentGet(v:lnum,1) setlocal indentkeys=o,O,*,<>>,<<>,/,{,},!^F +" autoindent: used when the indentexpr returns -1 +setlocal autoindent if !exists('b:xml_indent_open') let b:xml_indent_open = '.\{-}<[:A-Z_a-z]' @@ -103,37 +106,43 @@ fun! XmlIndentGet(lnum, use_syntax_check) return 0 endif " Find previous line with a tag (regardless whether open or closed, - " but always start restrict the match to a line before the current one + " but always restrict the match to a line before the current one " Note: xml declaration: " won't be found, as it is not a legal tag name - let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. line('.').'l\)' + let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. a:lnum .'l\)' let ptag = search(ptag_pattern, 'bnW') " no previous tag if ptag == 0 return 0 endif - let syn_name = '' + let pline = getline(ptag) + let pind = indent(ptag) + + let syn_name_start = '' " Syntax element at start of line (excluding whitespace) + let syn_name_end = '' " Syntax element at end of line + let curline = getline(a:lnum) if a:use_syntax_check let check_lnum = XmlIndentSynCheck(ptag) let check_alnum = XmlIndentSynCheck(a:lnum) if check_lnum == 0 || check_alnum == 0 return indent(a:lnum) endif - let syn_name = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') + let syn_name_end = synIDattr(synID(a:lnum, strlen(curline) - 1, 1), 'name') + let syn_name_start = synIDattr(synID(a:lnum, match(curline, '\S') + 1, 1), 'name') endif - if syn_name =~ 'Comment' + if syn_name_end =~ 'Comment' && syn_name_start =~ 'Comment' return XmlIndentComment(a:lnum) + elseif empty(syn_name_start) && empty(syn_name_end) + " non-xml tag content: use indent from 'autoindent' + return pind + shiftwidth() endif - let pline = getline(ptag) - let pind = indent(ptag) " Get indent from previous tag line let ind = XmlIndentSum(pline, -1, pind) - let t_ind = ind " Determine indent from current line - let ind = XmlIndentSum(getline(a:lnum), 0, ind) + let ind = XmlIndentSum(curline, 0, ind) return ind endfun @@ -148,7 +157,7 @@ func! HasNoTagEnd(line) endfunc " return indent for a commented line, -" the middle part might be indented on additional level +" the middle part might be indented one additional level func! XmlIndentComment(lnum) let ptagopen = search(b:xml_indent_open, 'bnW') let ptagclose = search(b:xml_indent_close, 'bnW') diff --git a/runtime/syntax/valgrind.vim b/runtime/syntax/valgrind.vim index d099971826..a9b4a8c8e7 100644 --- a/runtime/syntax/valgrind.vim +++ b/runtime/syntax/valgrind.vim @@ -2,8 +2,7 @@ " Language: Valgrind Memory Debugger Output " Maintainer: Roger Luethi " Program URL: http://devel-home.kde.org/~sewardj/ -" Last Change: 2015 Jan 27 -" Included improvement by Dominique Pelle +" Last Change: 2019 Jul 24 " " Notes: mostly based on strace.vim and xml.vim " @@ -26,7 +25,7 @@ syn match valgrindSpecLine "^[+-]\{2}\d\+[+-]\{2}.*$" syn region valgrindRegion \ start=+^==\z(\d\+\)== \w.*$+ - \ skip=+^==\z1==\( \| .*\)$+ + \ skip=+^==\z1==\( \| .*\| \S.*\)$+ \ end=+^+ \ fold \ keepend @@ -70,7 +69,7 @@ syn match valgrindLoc "\s\+\(by\|at\|Address\).*$" contained syn match valgrindAt "at\s\@=" contained syn match valgrindAddr "\W\zs0x\x\+" contained -syn match valgrindFunc ": \zs\h[a-zA-Z0-9_:\[\]()<>&*+\-,=%!|^ ]*\ze([^)]*)$" contained +syn match valgrindFunc ": \zs\h[a-zA-Z0-9_:\[\]()<>&*+\-,=%!|^ @.]*\ze([^)]*)$" contained syn match valgrindBin "(\(with\)\=in \zs\S\+)\@=" contained syn match valgrindSrc "(\zs[^)]*:\d\+)\@=" contained