annotate runtime/indent/php.vim @ 33235:44fa2b82a642 v9.0.1891

patch 9.0.1891: No runtime support for Mojo Commit: https://github.com/vim/vim/commit/0ce2c594d0704f27a16d2c13fce85d596cc91489 Author: Mahmoud Abduljawad <mahmoud@masaar.com> Date: Sun Sep 10 18:23:04 2023 +0200 patch 9.0.1891: No runtime support for Mojo Problem: No runtime support for Mojo Solution: Add basic filetype and syntax plugins closes: #13062 closes: #13063 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Doug Kearns <dougkearns@gmail.com> Co-authored-by: Mahmoud Abduljawad <mahmoud@masaar.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Sep 2023 18:30:06 +0200
parents 345c8a959d76
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: PHP
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
3 " Author: John Wellesz <John.wellesz (AT) gmail (DOT) com>
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
4 " URL: https://www.2072productions.com/vim/indent/php.vim
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
5 " Home: https://github.com/2072/PHP-Indenting-for-VIm
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
6 " Last Change: 2023 August 18th
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
7 " Version: 1.75
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
8 "
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
9 "
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
10 " Type :help php-indent for available options
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
11 "
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
12 " A fully commented version of this file is available on github
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
13 "
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
14 "
13950
741b1feeac9f patch 8.0.1845: various comment updates needed, missing white space
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
15 " If you find a bug, please open a ticket on github.com
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
16 " ( https://github.com/2072/PHP-Indenting-for-VIm/issues ) with an example of
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
17 " code that breaks the algorithm.
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
18 "
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
19
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
20 " NOTE: This script must be used with PHP syntax ON and with the php syntax
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
21 " script by Lutz Eymers (http://www.isp.de/data/php.vim ) or with the
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
22 " script by Peter Hodge (https://www.vim.org/scripts/script.php?script_id=1571 )
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
23 " the later is bunbdled by default with Vim 7.
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
24 "
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
25 "
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
26 " In the case you have syntax errors in your script such as HereDoc end
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
27 " identifiers not at col 1 you'll have to indent your file 2 times (This
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
28 " script will automatically put HereDoc end identifiers at col 1 if
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
29 " they are followed by a ';').
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
30 "
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
31
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
32 " NOTE: If you are editing files in Unix file format and that (by accident)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
33 " there are '\r' before new lines, this script won't be able to proceed
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
34 " correctly and will make many mistakes because it won't be able to match
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
35 " '\s*$' correctly.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
36 " So you have to remove those useless characters first with a command like:
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
37 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
38 " :%s /\r$//g
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
40 " or simply 'let' the option PHP_removeCRwhenUnix to 1 and the script will
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
41 " silently remove them when VIM load this script (at each bufread).
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
42
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
43
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 if exists("b:did_indent")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
45 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
49
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
50 let g:php_sync_method = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
51
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
52
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
53 if exists("PHP_default_indenting")
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
54 let b:PHP_default_indenting = PHP_default_indenting * shiftwidth()
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
55 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
56 let b:PHP_default_indenting = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
57 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
58
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
59 if exists("PHP_outdentSLComments")
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
60 let b:PHP_outdentSLComments = PHP_outdentSLComments * shiftwidth()
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
61 else
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
62 let b:PHP_outdentSLComments = 0
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
63 endif
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
64
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
65 if exists("PHP_BracesAtCodeLevel")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
66 let b:PHP_BracesAtCodeLevel = PHP_BracesAtCodeLevel
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
67 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
68 let b:PHP_BracesAtCodeLevel = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
69 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
70
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
71
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
72 if exists("PHP_autoformatcomment")
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
73 let b:PHP_autoformatcomment = PHP_autoformatcomment
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
74 else
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
75 let b:PHP_autoformatcomment = 1
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
76 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
78 if exists("PHP_outdentphpescape")
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
79 let b:PHP_outdentphpescape = PHP_outdentphpescape
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
80 else
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
81 let b:PHP_outdentphpescape = 1
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
82 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
83
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
84 if exists("PHP_noArrowMatching")
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
85 let b:PHP_noArrowMatching = PHP_noArrowMatching
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
86 else
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
87 let b:PHP_noArrowMatching = 0
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
88 endif
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
89
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
90
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
91 if exists("PHP_vintage_case_default_indent") && PHP_vintage_case_default_indent
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
92 let b:PHP_vintage_case_default_indent = 1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
93 else
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
94 let b:PHP_vintage_case_default_indent = 0
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
95 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
96
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
97 if exists("PHP_IndentFunctionCallParameters")
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
98 let b:PHP_IndentFunctionCallParameters = PHP_IndentFunctionCallParameters
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
99 else
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
100 let b:PHP_IndentFunctionCallParameters = 0
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
101 endif
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
102
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
103 if exists("PHP_IndentFunctionDeclarationParameters")
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
104 let b:PHP_IndentFunctionDeclarationParameters = PHP_IndentFunctionDeclarationParameters
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
105 else
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
106 let b:PHP_IndentFunctionDeclarationParameters = 0
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
107 endif
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
108
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
109 let b:PHP_lastindented = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
110 let b:PHP_indentbeforelast = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
111 let b:PHP_indentinghuge = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
112 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
113 let b:PHP_LastIndentedWasComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
114 let b:PHP_InsideMultilineComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
115 let b:InPHPcode = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
116 let b:InPHPcode_checked = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
117 let b:InPHPcode_and_script = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
118 let b:InPHPcode_tofind = ""
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
119 let b:PHP_oldchangetick = b:changedtick
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
120 let b:UserIsTypingComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
121 let b:optionsset = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
122
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
123 setlocal nosmartindent
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
124 setlocal noautoindent
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
125 setlocal nocindent
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
126 setlocal nolisp
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
127
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
128 setlocal indentexpr=GetPhpIndent()
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
129 setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
130
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 32984
diff changeset
131 let b:undo_indent = "setl ai< cin< inde< indk< lisp< si<"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
132
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
133 let s:searchpairflags = 'bWr'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
134
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
135 if &fileformat == "unix" && exists("PHP_removeCRwhenUnix") && PHP_removeCRwhenUnix
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
136 silent! %s/\r$//g
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
137 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
138
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 if exists("*GetPhpIndent")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
140 call ResetPhpOptions()
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
141 finish " XXX -- comment this line for easy dev
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
144
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
145 let s:endline = '\s*\%(//.*\|#\[\@!.*\|/\*.*\*/\s*\)\=$'
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
146 let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
147 let s:notPhpHereDoc = '\<\%(break\|return\|continue\|exit\|die\|true\|false\|elseif\|else\|end\%(if\|while\|for\|foreach\|match\|switch\)\)\>'
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
148 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\>\)'
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
149 let s:functionDeclPrefix = '\<function\>\%(\s\+&\='.s:PHP_validVariable.'\)\=\s*('
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
150 let s:functionDecl = s:functionDeclPrefix.'.*'
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
151 let s:multilineFunctionDecl = s:functionDeclPrefix.s:endline
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
152 let s:arrayDecl = '\<array\>\s*(.*'
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
153 let s:multilineFunctionCall = s:PHP_validVariable.'\s*('.s:endline
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
154 let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.s:endline
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
155
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
156
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
157 let s:terminated = '\%(\%(;\%(\s*\%(?>\|}\)\)\=\|<<<\s*[''"]\=\a\w*[''"]\=$\|^\s*}\|^\s*'.s:PHP_validVariable.':\)'.s:endline.'\)'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
158 let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!'
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
159 let s:matchStart = 'match\s*(\s*\$\?'.s:PHP_validVariable.'\s*)\s*{'. s:endline
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
160 let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\<new\s\+class\>\|' . s:matchStart
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
161
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
162
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
163 let s:escapeDebugStops = 0
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
164 function! DebugPrintReturn(scriptLine)
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
165
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
166 if ! s:escapeDebugStops
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
167 echo "debug:" . a:scriptLine
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
168 let c = getchar()
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
169 if c == "\<Del>"
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
170 let s:escapeDebugStops = 1
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
171 end
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
172 endif
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
173
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
174 endfunction
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
175
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
176 function! GetLastRealCodeLNum(startline) " {{{
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
177
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
178 let lnum = a:startline
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
179
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
180 if b:GetLastRealCodeLNum_ADD && b:GetLastRealCodeLNum_ADD == lnum + 1
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
181 let lnum = b:GetLastRealCodeLNum_ADD
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
182 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
183
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
184 while lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
185 let lnum = prevnonblank(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
186 let lastline = getline(lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
187
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
188 if b:InPHPcode_and_script && lastline =~ '?>\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
189 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
190 elseif lastline =~ '^\s*?>.*<?\%(php\)\=\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
191 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
192 elseif lastline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
193 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
194 elseif lastline =~ '\*/\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
195 call cursor(lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
196 if lastline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
197 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
198 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
199 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
200
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
201 let lastline = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
202 if lastline =~ '^\s*/\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
203 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
204 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
205 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
206 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
207
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
208
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
209 elseif lastline =~? '\%(//\s*\|?>.*\)\@<!<?\%(php\)\=\s*$\|^\s*<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
210
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
211 while lastline !~ '\(<?.*\)\@<!?>' && lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
212 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
213 let lastline = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
214 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
215 if lastline =~ '^\s*?>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
216 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
217 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
218 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
219 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
220
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
221
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
222 elseif lastline =~? '^\a\w*;\=$' && lastline !~? s:notPhpHereDoc
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
223 let tofind=substitute( lastline, '\(\a\w*\);\=', '<<<\\s*[''"]\\=\1[''"]\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
224 while getline(lnum) !~? tofind && lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
225 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
226 endwhile
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
227 elseif lastline =~ '^\s*[''"`][;,]'.s:endline || (lastline =~ '^[^''"`]*[''"`][;,]'.s:endline && IslinePHP(lnum, "") == "SpecStringEntrails")
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
228
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
229 let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$\\|^[^\1]\\+[=([]\\s*[\1]', '')
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
230 let trylnum = lnum
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
231 while getline(trylnum) !~? tofind && trylnum > 1
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
232 let trylnum = trylnum - 1
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
233 endwhile
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
234
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
235 if trylnum == 1
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
236 break
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
237 else
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
238 if lastline =~ ';'.s:endline
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
239 while getline(trylnum) !~? s:terminated && getline(trylnum) !~? '{'.s:endline && trylnum > 1
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
240 let trylnum = prevnonblank(trylnum - 1)
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
241 endwhile
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
242
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
243
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
244 if trylnum == 1
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
245 break
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
246 end
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
247 end
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
248 let lnum = trylnum
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
249 end
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
250 else
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
251 break
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
252 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
253 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
254
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
255 if lnum==1 && getline(lnum) !~ '<?'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
256 let lnum=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
257 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
258
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
259 if b:InPHPcode_and_script && 1 > b:InPHPcode
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
260 let b:InPHPcode_and_script = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
261 endif
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
262
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
263 return lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
264 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
265
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
266 function! Skippmatch2()
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
267
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
268 let line = getline(".")
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
269
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
270 if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\[\@!\).*/\*'
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
271 return 1
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
272 else
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
273 return 0
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
274 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
275 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
276
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
277 function! Skippmatch() " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
278 let synname = synIDattr(synID(line("."), col("."), 0), "name")
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
279 if synname ==? "Delimiter" || synname ==? "phpRegionDelimiter" || synname =~? "^phpParent" || synname ==? "phpArrayParens" || synname =~? '^php\%(Block\|Brace\)' || synname ==? "javaScriptBraces" || synname =~? '^php\%(Doc\)\?Comment' && b:UserIsTypingComment
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
280 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
281 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
282 return 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
283 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
284 endfun " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
285
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
286 function! FindOpenBracket(lnum, blockStarter) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
287 call cursor(a:lnum, 1)
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
288 let line = searchpair('{', '', '}', 'bW', 'Skippmatch()')
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
289
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
290 if a:blockStarter == 1
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
291 while line > 1
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
292 let linec = getline(line)
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
293
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
294 if linec =~ s:terminated || linec =~ s:structureHead
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
295 break
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
296 endif
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
297
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
298 let line = GetLastRealCodeLNum(line - 1)
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
299 endwhile
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
300 endif
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
301
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
302 return line
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
303 endfun " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
304
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
305 let s:blockChars = {'{':1, '[': 1, '(': 1, ')':-1, ']':-1, '}':-1}
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
306 let s:blockCharsLUT = {'{':'{', '}':'{', '[':'[', ']':'[', '(':'(', ')':'('}
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
307 function! BalanceDirection (str)
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
308
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
309 let balance = {'{':0, '[': 0, '(': 0, 'none':0}
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
310 let director = 'none'
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
311
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
312 for c in split(a:str, '\zs')
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
313 if has_key(s:blockChars, c)
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
314 let balance[s:blockCharsLUT[c]] += s:blockChars[c]
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
315
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
316 if balance[s:blockCharsLUT[c]]
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
317 let director = s:blockCharsLUT[c]
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
318 endif
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
319 endif
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
320 endfor
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
321
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
322 return balance[director]
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
323 endfun
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
324
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
325 function! StripEndlineComments (line)
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
326
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
327 let cleaned = substitute(a:line,'\v(//|#\[\@!)((([^"'']*(["''])[^"'']*\5)+[^"'']*$)|([^"'']*$))','','')
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
328 if cleaned != a:line
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
329 endif
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
330 return cleaned
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
331 endfun
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
332
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
333 function! FindArrowIndent (lnum) " {{{
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
334
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
335 let parentArrowPos = -1
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
336 let cursorPos = -1
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
337 let lnum = a:lnum
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
338 while lnum > 1
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
339 let last_line = getline(lnum)
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
340 if last_line =~ '^\s*->'
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
341 let parentArrowPos = indent(a:lnum)
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
342 break
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
343 else
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
344
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
345 if b:PHP_noArrowMatching
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
346 break
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
347 endif
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
348
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
349 let cleanedLnum = StripEndlineComments(last_line)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
350
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
351 if cleanedLnum =~ ')'.s:endline
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
352 if BalanceDirection(cleanedLnum) <= 0
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
353 call cursor(lnum, 1)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
354 call searchpos(')'.s:endline, 'cW', lnum)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
355 let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()')
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
356 let cursorPos = col(".")
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
357 if openedparent != lnum
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
358 let lnum = openedparent
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
359 continue
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
360 else
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
361 endif
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
362 else
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
363 let parentArrowPos = -1
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
364 break
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
365 end
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
366 endif
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
367
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
368 if cleanedLnum =~ '->'
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
369 call cursor(lnum, cursorPos == -1 ? strwidth(cleanedLnum) : cursorPos)
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
370 let parentArrowPos = searchpos('->', 'cWb', lnum)[1] - 1
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
371
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
372 break
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
373 else
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
374 let parentArrowPos = -1
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
375 break
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
376 endif
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
377 endif
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
378 endwhile
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
379
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
380 if parentArrowPos == -1
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
381 let parentArrowPos = indent(lnum) + shiftwidth()
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
382 end
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
383
32984
75c283beb74f re-sync with git
Christian Brabandt <cb@256bit.org>
parents: 19646
diff changeset
384 return parentArrowPos
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
385 endfun "}}}
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
386
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
387 function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
388
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
389 if getline(a:lnum) =~# '^\s*}\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
390 let beforeelse = a:lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
391 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
392 let beforeelse = GetLastRealCodeLNum(a:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
393 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
394
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
395 if !s:level
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
396 let s:iftoskip = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
397 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
398
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
399 if getline(beforeelse) =~# '^\s*\%(}\s*\)\=else\%(\s*if\)\@!\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
400 let s:iftoskip = s:iftoskip + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
401 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
402
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
403 if getline(beforeelse) =~ '^\s*}'
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
404 let beforeelse = FindOpenBracket(beforeelse, 0)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
405
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
406 if getline(beforeelse) =~ '^\s*{'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
407 let beforeelse = GetLastRealCodeLNum(beforeelse - 1)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
408 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
409 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
410
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
411
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
412 if !s:iftoskip && a:StopAfterFirstPrevElse && getline(beforeelse) =~# '^\s*\%([}]\s*\)\=else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
413 return beforeelse
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
414 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
415
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
416 if getline(beforeelse) !~# '^\s*if\>' && beforeelse>1 || s:iftoskip && beforeelse>1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
417
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
418 if s:iftoskip && getline(beforeelse) =~# '^\s*if\>'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
419 let s:iftoskip = s:iftoskip - 1
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
420 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
421
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
422 let s:level = s:level + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
423 let beforeelse = FindTheIfOfAnElse(beforeelse, a:StopAfterFirstPrevElse)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
424 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
425
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
426 return beforeelse
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
427
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
428 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
429
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
430 let s:defaultORcase = '^\s*\%(default\|case\).*:'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
431
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
432 function! FindTheSwitchIndent (lnum) " {{{
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
433
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
434 let test = GetLastRealCodeLNum(a:lnum - 1)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
435
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
436 if test <= 1
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
437 return indent(1) - shiftwidth() * b:PHP_vintage_case_default_indent
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
438 end
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
439
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
440 while getline(test) =~ '^\s*}' && test > 1
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
441 let test = GetLastRealCodeLNum(FindOpenBracket(test, 0) - 1)
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
442
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
443 if getline(test) =~ '^\s*switch\>'
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
444 let test = GetLastRealCodeLNum(test - 1)
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
445 endif
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
446 endwhile
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
447
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
448 if getline(test) =~# '^\s*switch\>'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
449 return indent(test)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
450 elseif getline(test) =~# s:defaultORcase
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
451 return indent(test) - shiftwidth() * b:PHP_vintage_case_default_indent
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
452 else
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
453 return FindTheSwitchIndent(test)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
454 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
455
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
456 endfunction "}}}
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
457
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
458 let s:SynPHPMatchGroups = {'phpparent':1, 'delimiter':1, 'define':1, 'storageclass':1, 'structure':1, 'exception':1}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
459 function! IslinePHP (lnum, tofind) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
460 let cline = getline(a:lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
461
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
462 if a:tofind==""
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
463 let tofind = "^\\s*[\"'`]*\\s*\\zs\\S"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
464 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
465 let tofind = a:tofind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
466 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
467
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
468 let tofind = tofind . '\c'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
469
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
470 let coltotest = match (cline, tofind) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
471
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
472 let synname = synIDattr(synID(a:lnum, coltotest, 0), "name")
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
473
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
474 if synname ==? 'phpStringSingle' || synname ==? 'phpStringDouble' || synname ==? 'phpBacktick'
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
475 if cline !~ '^\s*[''"`]' " ??? XXX
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
476 return "SpecStringEntrails"
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
477 else
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
478 return synname
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
479 end
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
480 end
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
481
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
482 if get(s:SynPHPMatchGroups, tolower(synname)) || synname =~ '^php' || synname =~? '^javaScript'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
483 return synname
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
484 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
485 return ""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
486 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
487 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
488
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
489 let s:autoresetoptions = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
490 if ! s:autoresetoptions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
491 let s:autoresetoptions = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
494 function! ResetPhpOptions()
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
495 if ! b:optionsset && &filetype =~ "php"
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
496 if b:PHP_autoformatcomment
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
497
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
498 setlocal comments=s1:/*,mb:*,ex:*/,://,f:#[,:#
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
499
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
500 setlocal formatoptions-=t
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
501 setlocal formatoptions+=q
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
502 setlocal formatoptions+=r
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
503 setlocal formatoptions+=o
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
504 setlocal formatoptions+=c
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
505 setlocal formatoptions+=b
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
506 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
507 let b:optionsset = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
508 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
509 endfunc
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
510
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
511 call ResetPhpOptions()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
512
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
513 function! GetPhpIndentVersion()
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
514 return "1.75"
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
515 endfun
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
516
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
517 function! GetPhpIndent()
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
518
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
519 let b:GetLastRealCodeLNum_ADD = 0
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
520
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
521 let UserIsEditing=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
522 if b:PHP_oldchangetick != b:changedtick
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
523 let b:PHP_oldchangetick = b:changedtick
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
524 let UserIsEditing=1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
525 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
526
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
527 if b:PHP_default_indenting
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
528 let b:PHP_default_indenting = g:PHP_default_indenting * shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
529 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
530
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
531 let cline = getline(v:lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
532
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
533 if !b:PHP_indentinghuge && b:PHP_lastindented > b:PHP_indentbeforelast
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
534 if b:PHP_indentbeforelast
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
535 let b:PHP_indentinghuge = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
536 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
537 let b:PHP_indentbeforelast = b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
538 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
539
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
540 if b:InPHPcode_checked && prevnonblank(v:lnum - 1) != b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
541 if b:PHP_indentinghuge
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
542 let b:PHP_indentinghuge = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
543 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
544 endif
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
545 let real_PHP_lastindented = v:lnum
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
546 let b:PHP_LastIndentedWasComment=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
547 let b:PHP_InsideMultilineComment=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
548 let b:PHP_indentbeforelast = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
549
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
550 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
551 let b:InPHPcode_checked = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
552 let b:InPHPcode_and_script = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
553 let b:InPHPcode_tofind = ""
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
554
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
555 elseif v:lnum > b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
556 let real_PHP_lastindented = b:PHP_lastindented
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
557 else
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
558 let real_PHP_lastindented = v:lnum
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
559 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
560
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
561 let b:PHP_lastindented = v:lnum
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
562
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
563
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
564 if !b:InPHPcode_checked " {{{ One time check
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
565 let b:InPHPcode_checked = 1
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
566 let b:UserIsTypingComment = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
567
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
568 let synname = ""
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
569 if cline !~ '<?.*?>'
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
570 let synname = IslinePHP (prevnonblank(v:lnum), "")
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
571 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
572
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
573 if synname!=""
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
574 if synname ==? "SpecStringEntrails"
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
575 let b:InPHPcode = -1 " thumb down
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
576 let b:InPHPcode_tofind = ""
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
577 elseif synname !=? "phpHereDoc" && synname !=? "phpHereDocDelimiter"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
578 let b:InPHPcode = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
579 let b:InPHPcode_tofind = ""
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
580
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
581 if synname =~? '^php\%(Doc\)\?Comment'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
582 let b:UserIsTypingComment = 1
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
583 let b:InPHPcode_checked = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
584 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
585
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
586 if synname =~? '^javaScript'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
587 let b:InPHPcode_and_script = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
588 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
589
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
590 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
591 let b:InPHPcode = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
592
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
593 let lnum = v:lnum - 1
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
594 while getline(lnum) !~? '<<<\s*[''"]\=\a\w*[''"]\=$' && lnum > 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
595 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
596 endwhile
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
597
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
598 let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
599 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
600 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
601 let b:InPHPcode = 0
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
602 let b:InPHPcode_tofind = s:PHP_startindenttag
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
603 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
604 endif "!b:InPHPcode_checked }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
605
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
606
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
607 " Test if we are indenting PHP code {{{
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
608 let lnum = prevnonblank(v:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
609 let last_line = getline(lnum)
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
610 let endline= s:endline
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
611
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
612 if b:InPHPcode_tofind!=""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
613 if cline =~? b:InPHPcode_tofind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
614 let b:InPHPcode_tofind = ""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
615 let b:UserIsTypingComment = 0
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
616
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
617 if b:InPHPcode == -1
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
618 let b:InPHPcode = 1
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
619 return -1
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
620 end
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
621
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
622 let b:InPHPcode = 1
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
623
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
624 if cline =~ '\*/'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
625 call cursor(v:lnum, 1)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
626 if cline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
627 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
628 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
629 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
630
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
631 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
632
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
633 let b:PHP_LastIndentedWasComment = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
634
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
635 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
636 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
637 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
638 return indent(lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
640
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
641 elseif cline =~? '<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
642 let b:InPHPcode_and_script = 1
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
643 let b:GetLastRealCodeLNum_ADD = v:lnum
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
644 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
646 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
647
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
648 if 1 == b:InPHPcode
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
649
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
650 if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~?"Delimiter"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
651 if cline !~? s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
652 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
653 let b:InPHPcode_tofind = s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
654 elseif cline =~? '<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
655 let b:InPHPcode_and_script = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
656 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
657
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
658 elseif last_line =~ '^[^''"`]\+[''"`]$' && last_line !~ '^\s*\%(//\|#\[\@!\|/\*.*\*/\s*$\)' " a string identifier with nothing after it and no other string identifier before
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
659 let b:InPHPcode = -1
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
660 let b:InPHPcode_tofind = substitute( last_line, '^.*\([''"`]\).*$', '^[^\1]*\1[;,]$', '')
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
661 elseif last_line =~? '<<<\s*[''"]\=\a\w*[''"]\=$'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
662 let b:InPHPcode = 0
7992
78106b0f2c56 commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents: 6421
diff changeset
663 let b:InPHPcode_tofind = substitute( last_line, '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
664
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
665 elseif !UserIsEditing && cline =~ '^\s*/\*\%(.*\*/\)\@!' && getline(v:lnum + 1) !~ '^\s*\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
666 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
667 let b:InPHPcode_tofind = '\*/'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
668
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
669 elseif cline =~? '^\s*</script>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
670 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
671 let b:InPHPcode_tofind = s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
672 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
673 endif " }}}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
674
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
675
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
676 if 1 > b:InPHPcode && !b:InPHPcode_and_script
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
677 return -1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
678 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
679
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
680 " Indent successive // or # comment the same way the first is {{{
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
681 let addSpecial = 0
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
682 if cline =~ '^\s*\%(//\|#\[\@!\|/\*.*\*/\s*$\)'
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
683 let addSpecial = b:PHP_outdentSLComments
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
684 if b:PHP_LastIndentedWasComment == 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
685 return indent(real_PHP_lastindented)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
686 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
687 let b:PHP_LastIndentedWasComment = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
688 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
689 let b:PHP_LastIndentedWasComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
690 endif " }}}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
691
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
692 " Indent multiline /* comments correctly {{{
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
693
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
694 if b:PHP_InsideMultilineComment || b:UserIsTypingComment
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
695 if cline =~ '^\s*\*\%(\/\)\@!'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
696 if last_line =~ '^\s*/\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
697 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
698 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
699 return indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
700 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
701 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
702 let b:PHP_InsideMultilineComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
703 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
704 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
705
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
706 if !b:PHP_InsideMultilineComment && cline =~ '^\s*/\*\%(.*\*/\)\@!'
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
707 if getline(v:lnum + 1) !~ '^\s*\*'
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
708 return -1
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
709 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
710 let b:PHP_InsideMultilineComment = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
711 endif " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
712
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
713
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
714 " Things always indented at col 1 (PHP delimiter: <?, ?>, Heredoc end) {{{
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
715 if cline =~# '^\s*<?' && cline !~ '?>' && b:PHP_outdentphpescape
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
716 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
717 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
718
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
719 if cline =~ '^\s*?>' && cline !~# '<?' && b:PHP_outdentphpescape
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
720 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
721 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
722
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
723 if (cline =~? '^\s*\a\w*;$\|^\a\w*$' || (cline =~? '^\s*[''"`][;,]' && IslinePHP(v:lnum, '[;,]') !~? '^\(phpString[SD]\|phpBacktick\)') ) && cline !~? s:notPhpHereDoc
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
724 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
725 endif " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
726
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
727 let s:level = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
728
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
729 let lnum = GetLastRealCodeLNum(v:lnum - 1)
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
730
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
731 let last_line = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
732 let ind = indent(lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
733
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
734 if ind==0 && b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
735 let ind = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
736 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
737
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
738 if lnum == 0
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
739 return b:PHP_default_indenting + addSpecial
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
740 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
741
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
742
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
743 if cline =~ '^\s*}\%(}}\)\@!'
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
744 let ind = indent(FindOpenBracket(v:lnum, 1))
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
745 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
746 if b:PHP_BracesAtCodeLevel
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
747 let ind = ind + shiftwidth()
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
748 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
749 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
750 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
751
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
752 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
753 call cursor(v:lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
754 if cline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
755 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
756 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
757 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
758
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
759 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
760
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
761 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
762 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
763 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
764 return indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
765 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
766 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
767
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
768
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
769 if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase && last_line !~ '^\s*[''"`][;,]'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
770 if ind==b:PHP_default_indenting
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
771 return b:PHP_default_indenting + addSpecial
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
772 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
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
773 return b:PHP_CurrentIndentLevel + addSpecial
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
774 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
775 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
776
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
777 let LastLineClosed = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
778
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
779 let terminated = s:terminated
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
780
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
781 let unstated = s:unstated
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
782
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
783
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
784 if ind != b:PHP_default_indenting && cline =~# '^\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
785 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
786 return indent(FindTheIfOfAnElse(v:lnum, 1))
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
787 elseif cline =~# s:defaultORcase
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
788 return FindTheSwitchIndent(v:lnum) + shiftwidth() * b:PHP_vintage_case_default_indent
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
789 elseif cline =~ '^\s*)\=\s*{'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
790 let previous_line = last_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
791 let last_line_num = lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
792
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
793 while last_line_num > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
794
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
795 if previous_line =~ terminated || previous_line =~ s:structureHead
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
796
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
797 let ind = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
798
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
799 if b:PHP_BracesAtCodeLevel
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
800 let ind = ind + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
801 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
802
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
803 return ind
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
804 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
805
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
806 let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
807 let previous_line = getline(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
808 endwhile
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
809 elseif cline =~ '^\s*->'
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
810 return FindArrowIndent(lnum)
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
811 elseif last_line =~# unstated && cline !~ '^\s*);\='.endline
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
812 let ind = ind + shiftwidth() " we indent one level further when the preceding line is not stated
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
813 return ind + addSpecial
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
814
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
815 elseif (ind != b:PHP_default_indenting || last_line =~ '^[)\]]' ) && last_line =~ terminated
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
816 let previous_line = last_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
817 let last_line_num = lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
818 let LastLineClosed = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
819
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
820 let isSingleLineBlock = 0
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
821 while 1
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
822 if ! isSingleLineBlock && previous_line =~ '^\s*}\|;\s*}'.endline
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
823
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
824 call cursor(last_line_num, 1)
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
825 if previous_line !~ '^}'
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
826 call search('}\|;\s*}'.endline, 'W')
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
827 end
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
828 let oldLastLine = last_line_num
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
829 let last_line_num = searchpair('{', '', '}', 'bW', 'Skippmatch()')
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
830
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
831 if getline(last_line_num) =~ '^\s*{'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
832 let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
833 elseif oldLastLine == last_line_num
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
834 let isSingleLineBlock = 1
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
835 continue
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
836 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
837
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
838 let previous_line = getline(last_line_num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
840 continue
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
841 else
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
842 let isSingleLineBlock = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
843
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
844 if getline(last_line_num) =~# '^\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
845 let last_line_num = FindTheIfOfAnElse(last_line_num, 0)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
846 continue
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
847 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
848
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
849
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
850 let last_match = last_line_num
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
851
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
852 let one_ahead_indent = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
853 let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
854 let two_ahead_indent = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
855 let after_previous_line = previous_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
856 let previous_line = getline(last_line_num)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
857
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
858
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
859 if previous_line =~# s:defaultORcase.'\|{'.endline
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
860 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
861 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
862
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
863 if after_previous_line=~# '^\s*'.s:blockstart.'.*)'.endline && previous_line =~# '[;}]'.endline
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
864 break
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
866
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
867 if one_ahead_indent == two_ahead_indent || last_line_num < 1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
868 if previous_line =~# '\%(;\|^\s*}\)'.endline || last_line_num < 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
869 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
870 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
871 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
872 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
873 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
874
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
875 if indent(last_match) != ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
876 let ind = indent(last_match)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
877 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
878
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
879 return ind + addSpecial
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
880 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
881 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
882
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
883 if (last_line !~ '^\s*}\%(}}\)\@!')
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
884 let plinnum = GetLastRealCodeLNum(lnum - 1)
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
885 else
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
886 let plinnum = GetLastRealCodeLNum(FindOpenBracket(lnum, 1) - 1)
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
887 endif
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
888
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
889 let AntepenultimateLine = getline(plinnum)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
890
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
891 let last_line = StripEndlineComments(last_line)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
892
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
893 if ind == b:PHP_default_indenting
6421
5d89d9b40499 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5862
diff changeset
894 if last_line =~ terminated && last_line !~# s:defaultORcase
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
895 let LastLineClosed = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
896 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
897 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
898
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
899 if !LastLineClosed
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
900
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
901 let openedparent = -1
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
902
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
903
11262
214f228718cf Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 7992
diff changeset
904 if last_line =~# '[{(\[]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(\[]'.endline && BalanceDirection(last_line) > 0
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
905
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
906 let dontIndent = 0
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
907 if last_line =~ '\S\+\s*{'.endline && last_line !~ '^\s*[)\]]\+\(\s*:\s*'.s:PHP_validVariable.'\)\=\s*{'.endline && last_line !~ s:structureHead
5862
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
908 let dontIndent = 1
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
909 endif
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
910
306caa30d83b Runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 5618
diff changeset
911 if !dontIndent && (!b:PHP_BracesAtCodeLevel || last_line !~# '^\s*{')
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
912 let ind = ind + shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
913 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
914
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
915 if b:PHP_IndentFunctionCallParameters && last_line =~ s:multilineFunctionCall && last_line !~ s:structureHead && last_line !~ s:arrayDecl
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
916 let ind = ind + b:PHP_IndentFunctionCallParameters * shiftwidth()
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
917 endif
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
918
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
919 if b:PHP_IndentFunctionDeclarationParameters && last_line =~ s:multilineFunctionDecl
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
920 let ind = ind + b:PHP_IndentFunctionDeclarationParameters * shiftwidth()
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
921 endif
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
922
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
923 if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
924 let b:PHP_CurrentIndentLevel = ind
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
925
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
926 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
927
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
928 elseif last_line =~ '),'.endline && BalanceDirection(last_line) < 0
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
929 call cursor(lnum, 1)
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
930 call searchpos('),'.endline, 'cW')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
931 let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
932 if openedparent != lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
933 let ind = indent(openedparent)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
934 endif
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
935
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
936 elseif last_line =~ s:structureHead
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
937 let ind = ind + shiftwidth()
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
938
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
939
33170
345c8a959d76 runtime(php): Update the php indent script to the 1.75 (from 1.70) (#13025)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
940 elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' && AntepenultimateLine !~? s:matchStart || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
941 let ind = ind + shiftwidth()
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
942 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
944
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
945 if openedparent >= 0
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
946 let last_line = StripEndlineComments(getline(openedparent))
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
947 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
948 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
949
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
950 if cline =~ '^\s*[)\]];\='
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
951 call cursor(v:lnum, 1)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
952 call searchpos('[)\]]', 'cW')
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
953 let matchedBlockChar = cline[col('.')-1]
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
954 let openedparent = searchpair('\M'.s:blockCharsLUT[matchedBlockChar], '', '\M'.matchedBlockChar, 'bW', 'Skippmatch()')
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
955 if openedparent != v:lnum
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
956 let ind = indent(openedparent)
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
957 endif
14006
665fe1f419b0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13950
diff changeset
958
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14006
diff changeset
959 elseif last_line =~ '^\s*->' && last_line !~? s:structureHead && BalanceDirection(last_line) <= 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11262
diff changeset
960 let ind = ind - shiftwidth()
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
961 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
962
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
963 let b:PHP_CurrentIndentLevel = ind
4502
605c9ce57ec3 Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents: 2442
diff changeset
964 return ind + addSpecial
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 endfunction