From 327e3fab9e66701334a55dd7893283acb85899a2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 24 Aug 2023 09:07:35 +0900 Subject: vim-patch:3fc7a7e44abd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime: Fix typos in various files closes: vim/vim#12836 https://github.com/vim/vim/commit/3fc7a7e44abda6505ccd39a6d067db6e5173cbf6 Co-authored-by: Viktor Szépe --- runtime/indent/php.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'runtime/indent/php.vim') diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim index 0e623689d5..6b3d700059 100644 --- a/runtime/indent/php.vim +++ b/runtime/indent/php.vim @@ -327,13 +327,13 @@ endfun function! FindArrowIndent (lnum) " {{{ - let parrentArrowPos = -1 + let parentArrowPos = -1 let cursorPos = -1 let lnum = a:lnum while lnum > 1 let last_line = getline(lnum) if last_line =~ '^\s*->' - let parrentArrowPos = indent(a:lnum) + let parentArrowPos = indent(a:lnum) break else @@ -355,28 +355,28 @@ function! FindArrowIndent (lnum) " {{{ else endif else - let parrentArrowPos = -1 + let parentArrowPos = -1 break end endif if cleanedLnum =~ '->' call cursor(lnum, cursorPos == -1 ? strwidth(cleanedLnum) : cursorPos) - let parrentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1 + let parentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1 break else - let parrentArrowPos = -1 + let parentArrowPos = -1 break endif endif endwhile - if parrentArrowPos == -1 - let parrentArrowPos = indent(lnum) + shiftwidth() + if parentArrowPos == -1 + let parentArrowPos = indent(lnum) + shiftwidth() end - return parrentArrowPos + return parentArrowPos endfun "}}} function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{ -- cgit From ae7ab9015999ba417642a5e0c785709f104d75cf Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 29 Aug 2023 11:03:29 +0200 Subject: vim-patch:0382f05dbd65 runtime: Set b:undo_indent where missing (vim/vim#12944) https://github.com/vim/vim/commit/0382f05dbd659d8e39ee4e71c1e5062ac5c0a8fd Co-authored-by: dkearns --- runtime/indent/php.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/indent/php.vim') diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim index 6b3d700059..350accaa11 100644 --- a/runtime/indent/php.vim +++ b/runtime/indent/php.vim @@ -4,6 +4,7 @@ " URL: https://www.2072productions.com/vim/indent/php.vim " Home: https://github.com/2072/PHP-Indenting-for-VIm " Last Change: 2020 Mar 05 +" 2023 Aug 28 by Vim Project (undo_indent) " Version: 1.70 " " @@ -128,7 +129,7 @@ setlocal nolisp setlocal indentexpr=GetPhpIndent() setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*,=?>,= Date: Mon, 4 Sep 2023 23:17:59 +0200 Subject: vim-patch:3170342af304 runtime(php): Update the php indent script to the 1.75 (from 1.70) (vim/vim#13025) Changes: 1.75: - Fix 2072/PHP-Indenting-for-VImvim/vim#87: The indent optimization was causing wrong indentation of lines preceded by a line ending with '}' when preceded by non white characters. - Fix long standing non-reported regex escaping issue in cleaning end of line comments function. This should help fixing some other unreported issues when parts of codes are commented out at ends of lines... 1.74: - Fix 2072/PHP-Indenting-for-VImvim/vim#86: Add support for `match` expression. 1.73: - Fix 2072/PHP-Indenting-for-VImvim/vim#77 where multi line strings and true/false keywords at beginning of a line would cause indentation failures. 1.72: - Fix vim/vimvim/vim#5722 where it was reported that the option PHP_BracesAtCodeLevel had not been working for the last 6 years. 1.71: - Fix 2072/PHP-Indenting-for-VImvim/vim#75 where the indent script would hang on some multi-line quoted strings. https://github.com/vim/vim/commit/3170342af3049852afb2fbca85df37baf5fec82f Co-authored-by: John Wellesz --- runtime/indent/php.vim | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'runtime/indent/php.vim') diff --git a/runtime/indent/php.vim b/runtime/indent/php.vim index 350accaa11..377ffd5afb 100644 --- a/runtime/indent/php.vim +++ b/runtime/indent/php.vim @@ -3,9 +3,8 @@ " Author: John Wellesz " URL: https://www.2072productions.com/vim/indent/php.vim " Home: https://github.com/2072/PHP-Indenting-for-VIm -" Last Change: 2020 Mar 05 -" 2023 Aug 28 by Vim Project (undo_indent) -" Version: 1.70 +" Last Change: 2023 August 18th +" Version: 1.75 " " " Type :help php-indent for available options @@ -143,10 +142,10 @@ if exists("*GetPhpIndent") endif -let s:endline = '\s*\%(//.*\|#.*\|/\*.*\*/\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:notPhpHereDoc = '\<\%(break\|return\|continue\|exit\|die\|true\|false\|elseif\|else\|end\%(if\|while\|for\|foreach\|match\|switch\)\)\>' +let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|match\>\|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 @@ -157,7 +156,8 @@ let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@\)'.s:endl let s:terminated = '\%(\%(;\%(\s*\%(?>\|}\)\)\=\|<<<\s*[''"]\=\a\w*[''"]\=$\|^\s*}\|^\s*'.s:PHP_validVariable.':\)'.s:endline.'\)' let s:PHP_startindenttag = '\)\@!\|]*>\%(.*<\/script>\)\@!' -let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\' +let s:matchStart = 'match\s*(\s*\$\?'.s:PHP_validVariable.'\s*)\s*{'. s:endline +let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\\|' . s:matchStart let s:escapeDebugStops = 0 @@ -224,7 +224,7 @@ function! GetLastRealCodeLNum(startline) " {{{ while getline(lnum) !~? tofind && lnum > 1 let lnum = lnum - 1 endwhile - elseif lastline =~ '^\s*[''"`][;,]' || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails") + elseif lastline =~ '^\s*[''"`][;,]'.s:endline || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails") let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$\\|^[^\1]\\+[=([]\\s*[\1]', '') let trylnum = lnum @@ -267,7 +267,7 @@ function! Skippmatch2() let line = getline(".") - if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\).*/\*' + if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\[\@!\).*/\*' return 1 else return 0 @@ -323,7 +323,11 @@ function! BalanceDirection (str) endfun function! StripEndlineComments (line) - return substitute(a:line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','') + + let cleaned = substitute(a:line,'\v(//|#\[\@!)((([^"'']*(["''])[^"'']*\5)+[^"'']*$)|([^"'']*$))','','') + if cleaned != a:line + endif + return cleaned endfun function! FindArrowIndent (lnum) " {{{ @@ -491,7 +495,7 @@ function! ResetPhpOptions() if ! b:optionsset && &filetype =~ "php" if b:PHP_autoformatcomment - setlocal comments=s1:/*,mb:*,ex:*/,://,:# + setlocal comments=s1:/*,mb:*,ex:*/,://,f:#[,:# setlocal formatoptions-=t setlocal formatoptions+=q @@ -507,7 +511,7 @@ endfunc call ResetPhpOptions() function! GetPhpIndentVersion() - return "1.70-bundle" + return "1.75" endfun function! GetPhpIndent() @@ -651,7 +655,7 @@ function! GetPhpIndent() let b:InPHPcode_and_script = 1 endif - elseif last_line =~ '^[^''"`]\+[''"`]$' && last_line !~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' " 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*[''"]\=$' @@ -675,7 +679,7 @@ function! GetPhpIndent() " Indent successive // or # comment the same way the first is {{{ let addSpecial = 0 - if cline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' + if cline =~ '^\s*\%(//\|#\[\@!\|/\*.*\*/\s*$\)' let addSpecial = b:PHP_outdentSLComments if b:PHP_LastIndentedWasComment == 1 return indent(real_PHP_lastindented) @@ -716,7 +720,7 @@ function! GetPhpIndent() return 0 endif - if cline =~? '^\s*\a\w*;$\|^\a\w*$\|^\s*[''"`][;,]' && cline !~? s:notPhpHereDoc + if (cline =~? '^\s*\a\w*;$\|^\a\w*$' || (cline =~? '^\s*[''"`][;,]' && IslinePHP(v:lnum, '[;,]') !~? '^\(phpString[SD]\|phpBacktick\)') ) && cline !~? s:notPhpHereDoc return 0 endif " }}} @@ -739,6 +743,9 @@ function! GetPhpIndent() if cline =~ '^\s*}\%(}}\)\@!' let ind = indent(FindOpenBracket(v:lnum, 1)) let b:PHP_CurrentIndentLevel = b:PHP_default_indenting + if b:PHP_BracesAtCodeLevel + let ind = ind + shiftwidth() + endif return ind endif @@ -762,7 +769,7 @@ function! GetPhpIndent() 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 + elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)\|^\(\s*\S\+\s*\)\+}'.endline && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline return b:PHP_CurrentIndentLevel + addSpecial endif endif @@ -930,7 +937,7 @@ function! GetPhpIndent() let ind = ind + shiftwidth() - elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase + elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' && AntepenultimateLine !~? s:matchStart || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase let ind = ind + shiftwidth() endif -- cgit