Skip to content

Commit 9da951a

Browse files
committed
vim-patch:0b0f0992d46e
Update runtime files. vim/vim@0b0f099
1 parent 633ae52 commit 9da951a

File tree

10 files changed

+651
-334
lines changed

10 files changed

+651
-334
lines changed

runtime/autoload/xmlformat.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Vim plugin for formatting XML
2-
" Last Change: Thu, 15 Jan 2015 21:26:55 +0100
2+
" Last Change: Thu, 22 May 2018 21:26:55 +0100
33
" Version: 0.1
44
" Author: Christian Brabandt <cb@256bit.org>
55
" Script: http://www.vim.org/scripts/script.php?script_id=
@@ -30,7 +30,7 @@ func! xmlformat#Format()
3030
let lastitem = prev ? getline(prev) : ''
3131
let is_xml_decl = 0
3232
" split on `<`, but don't split on very first opening <
33-
for item in split(getline(v:lnum), '.\@<=[>]\zs')
33+
for item in split(join(getline(v:lnum, (v:lnum + v:count - 1))), '.\@<=[>]\zs')
3434
if s:EndTag(item)
3535
let s:indent = s:DecreaseIndent()
3636
call add(result, s:Indent(item))

runtime/doc/eval.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,7 +5358,8 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
53585358
listing.
53595359

53605360
When there is no mapping for {name}, an empty String is
5361-
returned.
5361+
returned. When the mapping for {name} is empty, then "<Nop>"
5362+
is returned.
53625363

53635364
The {name} can have special key names, like in the ":map"
53645365
command.
@@ -5425,9 +5426,10 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
54255426
mapping that matches with {name}, while maparg() only finds a
54265427
mapping for {name} exactly.
54275428
When there is no mapping that starts with {name}, an empty
5428-
String is returned. If there is one, the rhs of that mapping
5429+
String is returned. If there is one, the RHS of that mapping
54295430
is returned. If there are several mappings that start with
5430-
{name}, the rhs of one of them is returned.
5431+
{name}, the RHS of one of them is returned. This will be
5432+
"<Nop>" if the RHS is empty.
54315433
The mappings local to the current buffer are checked first,
54325434
then the global mappings.
54335435
This function can be used to check if a mapping can be added

runtime/doc/indent.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,25 @@ In PHP braces are not required inside 'case/default' blocks therefore 'case:'
903903
and 'default:' are indented at the same level than the 'switch()' to avoid
904904
meaningless indentation. You can use the above option to return to the
905905
traditional way.
906+
-------------
907+
908+
*PHP_noArrowMatching*
909+
By default the indent script will indent multi-line chained calls by matching
910+
the position of the '->': >
911+
912+
$user_name_very_long->name()
913+
->age()
914+
->info();
915+
916+
You can revert to the classic way of indenting by setting this option to 1: >
917+
:let g:PHP_noArrowMatching = 1
918+
919+
You will obtain the following result: >
920+
921+
$user_name_very_long->name()
922+
->age()
923+
->info();
924+
906925
907926
908927
PYTHON *ft-python-indent*

runtime/doc/options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3786,7 +3786,7 @@ A jump table for the options with a short description can be found at |Q_op|.
37863786
more depth, set 'maxfuncdepth' to a bigger number. But this will use
37873787
more memory, there is the danger of failing when memory is exhausted.
37883788
Increasing this limit above 200 also changes the maximum for Ex
3789-
command resursion, see |E169|.
3789+
command recursion, see |E169|.
37903790
See also |:function|.
37913791

37923792
*'maxmapdepth'* *'mmd'* *E223*

runtime/doc/tabpage.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ gT Go to the previous tab page. Wraps around from the first one
203203
:tabN[ext] {count}
204204
{count}<C-PageUp>
205205
{count}gT Go {count} tab pages back. Wraps around from the first one
206-
to the last one.
206+
to the last one. Note that the use of {count} is different
207+
from |:tabnext|, where it is used as the tab page number.
207208

208209
:tabr[ewind] *:tabfir* *:tabfirst* *:tabr* *:tabrewind*
209210
:tabfir[st] Go to the first tab page.

runtime/indent/php.vim

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
" Author: John Wellesz <John.wellesz (AT) teaser (DOT) fr>
44
" URL: http://www.2072productions.com/vim/indent/php.vim
55
" Home: https://github.com/2072/PHP-Indenting-for-VIm
6-
" Last Change: 2017 Jun 13
7-
" Version: 1.62
6+
" Last Change: 2018 May 18th
7+
" Version: 1.66
88
"
99
"
1010
" Type :help php-indent for available options
@@ -82,6 +82,12 @@ else
8282
let b:PHP_outdentphpescape = 1
8383
endif
8484

85+
if exists("PHP_noArrowMatching")
86+
let b:PHP_noArrowMatching = PHP_noArrowMatching
87+
else
88+
let b:PHP_noArrowMatching = 0
89+
endif
90+
8591

8692
if exists("PHP_vintage_case_default_indent") && PHP_vintage_case_default_indent
8793
let b:PHP_vintage_case_default_indent = 1
@@ -130,7 +136,7 @@ endif
130136
let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
131137
let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\)'
132138
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\>\)'
133-
let s:functionDecl = '\<function\>\%(\s\+'.s:PHP_validVariable.'\)\=\s*(.*'
139+
let s:functionDecl = '\<function\>\%(\s\+&\='.s:PHP_validVariable.'\)\=\s*(.*'
134140
let s:endline = '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$'
135141
let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.s:endline
136142

@@ -140,7 +146,6 @@ let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!'
140146
let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\<new\s\+class\>'
141147

142148

143-
144149
let s:escapeDebugStops = 0
145150
function! DebugPrintReturn(scriptLine)
146151

@@ -257,7 +262,7 @@ endfun
257262

258263
function! Skippmatch() " {{{
259264
let synname = synIDattr(synID(line("."), col("."), 0), "name")
260-
if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname =~# '^php\%(Doc\)\?Comment' && b:UserIsTypingComment
265+
if synname ==? "Delimiter" || synname ==? "phpRegionDelimiter" || synname =~? "^phpParent" || synname ==? "phpArrayParens" || synname =~? '^php\%(Block\|Brace\)' || synname ==? "javaScriptBraces" || synname =~? '^php\%(Doc\)\?Comment' && b:UserIsTypingComment
261266
return 0
262267
else
263268
return 1
@@ -297,6 +302,48 @@ function! BalanceDirection (str)
297302
return balance
298303
endfun
299304

305+
function! StripEndlineComments (line)
306+
return substitute(a:line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','')
307+
endfun
308+
309+
function! FindArrowIndent (lnum) " {{{
310+
311+
let parrentArrowPos = 0
312+
let lnum = a:lnum
313+
while lnum > 1
314+
let last_line = getline(lnum)
315+
if last_line =~ '^\s*->'
316+
let parrentArrowPos = indent(a:lnum)
317+
break
318+
else
319+
call cursor(lnum, 1)
320+
let cleanedLnum = StripEndlineComments(last_line)
321+
if cleanedLnum =~ '->'
322+
if ! b:PHP_noArrowMatching
323+
let parrentArrowPos = searchpos('->', 'W', lnum)[1] - 1
324+
else
325+
let parrentArrowPos = indent(lnum) + shiftwidth()
326+
endif
327+
break
328+
elseif cleanedLnum =~ ')'.s:endline && BalanceDirection(last_line) < 0
329+
call searchpos(')'.s:endline, 'cW', lnum)
330+
let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()')
331+
if openedparent != lnum
332+
let lnum = openedparent
333+
else
334+
let openedparent = -1
335+
endif
336+
337+
else
338+
let parrentArrowPos = indent(lnum) + shiftwidth()
339+
break
340+
endif
341+
endif
342+
endwhile
343+
344+
return parrentArrowPos
345+
endfun "}}}
346+
300347
function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{
301348

302349
if getline(a:lnum) =~# '^\s*}\s*else\%(if\)\=\>'
@@ -368,7 +415,7 @@ function! FindTheSwitchIndent (lnum) " {{{
368415

369416
endfunction "}}}
370417

371-
let s:SynPHPMatchGroups = {'phpParent':1, 'Delimiter':1, 'Define':1, 'Storageclass':1, 'StorageClass':1, 'Structure':1, 'Exception':1}
418+
let s:SynPHPMatchGroups = {'phpparent':1, 'delimiter':1, 'define':1, 'storageclass':1, 'structure':1, 'exception':1}
372419
function! IslinePHP (lnum, tofind) " {{{
373420
let cline = getline(a:lnum)
374421

@@ -384,15 +431,15 @@ function! IslinePHP (lnum, tofind) " {{{
384431

385432
let synname = synIDattr(synID(a:lnum, coltotest, 0), "name")
386433

387-
if synname == 'phpStringSingle' || synname == 'phpStringDouble' || synname == 'phpBacktick'
434+
if synname ==? 'phpStringSingle' || synname ==? 'phpStringDouble' || synname ==? 'phpBacktick'
388435
if cline !~ '^\s*[''"`]'
389436
return "SpecStringEntrails"
390437
else
391438
return synname
392439
end
393440
end
394441

395-
if get(s:SynPHPMatchGroups, synname) || synname =~ '^php' || synname =~? '^javaScript'
442+
if get(s:SynPHPMatchGroups, tolower(synname)) || synname =~ '^php' || synname =~? '^javaScript'
396443
return synname
397444
else
398445
return ""
@@ -423,6 +470,10 @@ endfunc
423470

424471
call ResetPhpOptions()
425472

473+
function! GetPhpIndentVersion()
474+
return "1.66-bundle"
475+
endfun
476+
426477
function! GetPhpIndent()
427478

428479
let b:GetLastRealCodeLNum_ADD = 0
@@ -480,14 +531,14 @@ function! GetPhpIndent()
480531
endif
481532

482533
if synname!=""
483-
if synname == "SpecStringEntrails"
534+
if synname ==? "SpecStringEntrails"
484535
let b:InPHPcode = -1 " thumb down
485536
let b:InPHPcode_tofind = ""
486-
elseif synname != "phpHereDoc" && synname != "phpHereDocDelimiter"
537+
elseif synname !=? "phpHereDoc" && synname !=? "phpHereDocDelimiter"
487538
let b:InPHPcode = 1
488539
let b:InPHPcode_tofind = ""
489540

490-
if synname =~# '^php\%(Doc\)\?Comment'
541+
if synname =~? '^php\%(Doc\)\?Comment'
491542
let b:UserIsTypingComment = 1
492543
let b:InPHPcode_checked = 0
493544
endif
@@ -556,7 +607,7 @@ function! GetPhpIndent()
556607

557608
if 1 == b:InPHPcode
558609

559-
if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~"Delimiter"
610+
if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~?"Delimiter"
560611
if cline !~? s:PHP_startindenttag
561612
let b:InPHPcode = 0
562613
let b:InPHPcode_tofind = s:PHP_startindenttag
@@ -712,7 +763,8 @@ function! GetPhpIndent()
712763
let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
713764
let previous_line = getline(last_line_num)
714765
endwhile
715-
766+
elseif cline =~ '^\s*->'
767+
return FindArrowIndent(lnum)
716768
elseif last_line =~# unstated && cline !~ '^\s*);\='.endline
717769
let ind = ind + shiftwidth() " we indent one level further when the preceding line is not stated
718770
return ind + addSpecial
@@ -724,7 +776,7 @@ function! GetPhpIndent()
724776

725777
let isSingleLineBlock = 0
726778
while 1
727-
if ! isSingleLineBlock && previous_line =~ '^\s*}\|;\s*}'.endline " XXX
779+
if ! isSingleLineBlock && previous_line =~ '^\s*}\|;\s*}'.endline
728780

729781
call cursor(last_line_num, 1)
730782
if previous_line !~ '^}'
@@ -793,8 +845,7 @@ function! GetPhpIndent()
793845

794846
let AntepenultimateLine = getline(plinnum)
795847

796-
let last_line = substitute(last_line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','')
797-
848+
let last_line = StripEndlineComments(last_line)
798849

799850
if ind == b:PHP_default_indenting
800851
if last_line =~ terminated && last_line !~# s:defaultORcase
@@ -804,11 +855,13 @@ function! GetPhpIndent()
804855

805856
if !LastLineClosed
806857

858+
let openedparent = -1
859+
807860

808861
if last_line =~# '[{(\[]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(\[]'.endline && BalanceDirection(last_line) > 0
809862

810863
let dontIndent = 0
811-
if last_line =~ '\S\+\s*{'.endline && last_line !~ '^\s*[)\]]\+\s*{'.endline && last_line !~ s:structureHead
864+
if last_line =~ '\S\+\s*{'.endline && last_line !~ '^\s*[)\]]\+\(\s*:\s*'.s:PHP_validVariable.'\)\=\s*{'.endline && last_line !~ s:structureHead
812865
let dontIndent = 1
813866
endif
814867

@@ -819,28 +872,35 @@ function! GetPhpIndent()
819872
if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1
820873
let b:PHP_CurrentIndentLevel = ind
821874

822-
return ind + addSpecial
823875
endif
824876

825-
elseif last_line =~ '\S\+\s*),'.endline && BalanceDirection(last_line) < 0
877+
elseif last_line =~ '),'.endline && BalanceDirection(last_line) < 0
826878
call cursor(lnum, 1)
827-
call search('),'.endline, 'W') " line never begins with ) so no need for 'c' flag
879+
call searchpos('),'.endline, 'cW')
828880
let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()')
829881
if openedparent != lnum
830882
let ind = indent(openedparent)
831883
endif
832884

833-
elseif last_line =~ '^\s*'.s:blockstart
885+
elseif last_line =~ s:structureHead
834886
let ind = ind + shiftwidth()
835887

836888

837889
elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase
838890
let ind = ind + shiftwidth()
839891
endif
840892

893+
894+
if openedparent >= 0
895+
let last_line = StripEndlineComments(getline(openedparent))
896+
endif
897+
endif
898+
899+
if cline =~ '^\s*[)\]];\='
900+
let ind = ind - shiftwidth()
841901
endif
842902

843-
if cline =~ '^\s*[)\]];\='
903+
if last_line =~ '^\s*->' && last_line !~? s:structureHead && BalanceDirection(last_line) <= 0
844904
let ind = ind - shiftwidth()
845905
endif
846906

0 commit comments

Comments
 (0)