Mercurial > vim
annotate runtime/indent/php.vim @ 10960:d7b78cbf85e4 v8.0.0369
patch 8.0.0369: a few options are not defined, depending on features
commit https://github.com/vim/vim/commit/c43a8b8de0676caf8a460b6af1310d7aba8221bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 25 21:12:29 2017 +0100
patch 8.0.0369: a few options are not defined, depending on features
Problem: The 'balloondelay', 'ballooneval' and 'balloonexpr' options are
not defined without the +balloon_eval feature. Testing that an
option value fails does not work for unsupported options.
Solution: Make the options defined but not supported. Don't test if
setting unsupported options fails.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 25 Feb 2017 21:15:03 +0100 |
parents | 78106b0f2c56 |
children | 214f228718cf |
rev | line source |
---|---|
7 | 1 " Vim indent file |
2 " Language: PHP | |
409 | 3 " Author: John Wellesz <John.wellesz (AT) teaser (DOT) fr> |
4 " URL: http://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 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
6 " Last Change: 2015 September 8th |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
7 " Version: 1.60 |
557 | 8 " |
856 | 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 | 13 " |
14 " | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
15 " If you find a bug, please open a ticket on github.org |
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 | 18 " |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
19 |
409 | 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 |
1668 | 22 " script by Peter Hodge (http://www.vim.org/scripts/script.php?script_id=1571 ) |
2034 | 23 " the later is bunbdled by default with Vim 7. |
409 | 24 " |
25 " | |
1668 | 26 " In the case you have syntax errors in your script such as HereDoc end |
27 " identifiers not at col 1 you'll have to indent your file 2 times (This | |
28 " script will automatically put HereDoc end identifiers at col 1 if | |
29 " they are followed by a ';'). | |
856 | 30 " |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
31 |
2034 | 32 " NOTE: If you are editing files in Unix file format and that (by accident) |
33 " there are '\r' before new lines, this script won't be able to proceed | |
34 " correctly and will make many mistakes because it won't be able to match | |
35 " '\s*$' correctly. | |
36 " So you have to remove those useless characters first with a command like: | |
409 | 37 " |
2034 | 38 " :%s /\r$//g |
7 | 39 " |
2034 | 40 " or simply 'let' the option PHP_removeCRwhenUnix to 1 and the script will |
41 " silently remove them when VIM load this script (at each bufread). | |
5862 | 42 |
43 | |
557 | 44 |
7 | 45 if exists("b:did_indent") |
532 | 46 finish |
7 | 47 endif |
48 let b:did_indent = 1 | |
49 | |
409 | 50 |
6421 | 51 let g:php_sync_method = 0 |
409 | 52 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
53 if exists('*shiftwidth') |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
54 function! s:sw() |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
55 return shiftwidth() |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
56 endfunction |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
57 else |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
58 function! s:sw() |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
59 return &shiftwidth |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
60 endfunction |
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
61 endif |
409 | 62 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
63 |
409 | 64 if exists("PHP_default_indenting") |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
65 let b:PHP_default_indenting = PHP_default_indenting * s:sw() |
409 | 66 else |
532 | 67 let b:PHP_default_indenting = 0 |
409 | 68 endif |
69 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
70 if exists("PHP_outdentSLComments") |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
71 let b:PHP_outdentSLComments = PHP_outdentSLComments * s:sw() |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
72 else |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
73 let b:PHP_outdentSLComments = 0 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
74 endif |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
75 |
409 | 76 if exists("PHP_BracesAtCodeLevel") |
532 | 77 let b:PHP_BracesAtCodeLevel = PHP_BracesAtCodeLevel |
409 | 78 else |
532 | 79 let b:PHP_BracesAtCodeLevel = 0 |
409 | 80 endif |
81 | |
1668 | 82 |
557 | 83 if exists("PHP_autoformatcomment") |
84 let b:PHP_autoformatcomment = PHP_autoformatcomment | |
85 else | |
86 let b:PHP_autoformatcomment = 1 | |
87 endif | |
7 | 88 |
2442 | 89 if exists("PHP_outdentphpescape") |
90 let b:PHP_outdentphpescape = PHP_outdentphpescape | |
91 else | |
92 let b:PHP_outdentphpescape = 1 | |
93 endif | |
94 | |
95 | |
96 if exists("PHP_vintage_case_default_indent") && PHP_vintage_case_default_indent | |
97 let b:PHP_vintage_case_default_indent = 1 | |
1668 | 98 else |
99 let b:PHP_vintage_case_default_indent = 0 | |
100 endif | |
101 | |
102 | |
103 | |
409 | 104 let b:PHP_lastindented = 0 |
105 let b:PHP_indentbeforelast = 0 | |
106 let b:PHP_indentinghuge = 0 | |
107 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
108 let b:PHP_LastIndentedWasComment = 0 | |
109 let b:PHP_InsideMultilineComment = 0 | |
110 let b:InPHPcode = 0 | |
111 let b:InPHPcode_checked = 0 | |
112 let b:InPHPcode_and_script = 0 | |
113 let b:InPHPcode_tofind = "" | |
114 let b:PHP_oldchangetick = b:changedtick | |
115 let b:UserIsTypingComment = 0 | |
116 let b:optionsset = 0 | |
117 | |
118 setlocal nosmartindent | |
856 | 119 setlocal noautoindent |
409 | 120 setlocal nocindent |
532 | 121 setlocal nolisp |
409 | 122 |
123 setlocal indentexpr=GetPhpIndent() | |
6421 | 124 setlocal indentkeys=0{,0},0),0],:,!^F,o,O,e,*<Return>,=?>,=<?,=*/ |
409 | 125 |
126 | |
532 | 127 |
128 let s:searchpairflags = 'bWr' | |
409 | 129 |
130 if &fileformat == "unix" && exists("PHP_removeCRwhenUnix") && PHP_removeCRwhenUnix | |
532 | 131 silent! %s/\r$//g |
409 | 132 endif |
133 | |
7 | 134 if exists("*GetPhpIndent") |
2034 | 135 call ResetPhpOptions() |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
136 finish |
7 | 137 endif |
138 | |
5862 | 139 |
6421 | 140 let s:PHP_validVariable = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*' |
5862 | 141 let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|die\|else\)' |
142 let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|\%(}\s*\)\?else\>\|do\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|trait\>\|use\>\|interface\>\|abstract\>\|final\>\|try\>\|\%(}\s*\)\=catch\>\|\%(}\s*\)\=finally\>\)' | |
6421 | 143 let s:functionDecl = '\<function\>\%(\s\+'.s:PHP_validVariable.'\)\=\s*(.*' |
409 | 144 let s:endline= '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$' |
6421 | 145 |
146 | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
147 let s:terminated = '\%(\%(;\%(\s*\%(?>\|}\)\)\=\|<<<\s*[''"]\=\a\w*[''"]\=$\|^\s*}\|^\s*'.s:PHP_validVariable.':\)'.s:endline.'\)\|^[^''"`]*[''"`]$' |
409 | 148 let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!' |
149 | |
150 | |
5862 | 151 |
152 let s:escapeDebugStops = 0 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
153 function! DebugPrintReturn(scriptLine) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
154 |
6421 | 155 if ! s:escapeDebugStops |
5862 | 156 echo "debug:" . a:scriptLine |
157 let c = getchar() | |
158 if c == "\<Del>" | |
159 let s:escapeDebugStops = 1 | |
160 end | |
161 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
162 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
163 endfunction |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
164 |
409 | 165 function! GetLastRealCodeLNum(startline) " {{{ |
856 | 166 |
532 | 167 let lnum = a:startline |
856 | 168 |
631 | 169 if b:GetLastRealCodeLNum_ADD && b:GetLastRealCodeLNum_ADD == lnum + 1 |
170 let lnum = b:GetLastRealCodeLNum_ADD | |
171 endif | |
856 | 172 |
532 | 173 while lnum > 1 |
174 let lnum = prevnonblank(lnum) | |
175 let lastline = getline(lnum) | |
409 | 176 |
532 | 177 if b:InPHPcode_and_script && lastline =~ '?>\s*$' |
178 let lnum = lnum - 1 | |
179 elseif lastline =~ '^\s*?>.*<?\%(php\)\=\s*$' | |
180 let lnum = lnum - 1 | |
181 elseif lastline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' | |
182 let lnum = lnum - 1 | |
183 elseif lastline =~ '\*/\s*$' | |
184 call cursor(lnum, 1) | |
185 if lastline !~ '^\*/' | |
186 call search('\*/', 'W') | |
187 endif | |
557 | 188 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
409 | 189 |
532 | 190 let lastline = getline(lnum) |
191 if lastline =~ '^\s*/\*' | |
192 let lnum = lnum - 1 | |
193 else | |
194 break | |
195 endif | |
409 | 196 |
197 | |
532 | 198 elseif lastline =~? '\%(//\s*\|?>.*\)\@<!<?\%(php\)\=\s*$\|^\s*<script\>' |
199 | |
200 while lastline !~ '\(<?.*\)\@<!?>' && lnum > 1 | |
201 let lnum = lnum - 1 | |
202 let lastline = getline(lnum) | |
203 endwhile | |
204 if lastline =~ '^\s*?>' | |
205 let lnum = lnum - 1 | |
206 else | |
207 break | |
208 endif | |
209 | |
409 | 210 |
2442 | 211 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
|
212 let tofind=substitute( lastline, '\(\a\w*\);\=', '<<<\\s*[''"]\\=\1[''"]\\=$', '') |
532 | 213 while getline(lnum) !~? tofind && lnum > 1 |
214 let lnum = lnum - 1 | |
215 endwhile | |
5862 | 216 elseif lastline =~ '^[^''"`]*[''"`][;,]'.s:endline |
217 let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$', '') | |
218 while getline(lnum) !~? tofind && lnum > 1 | |
219 let lnum = lnum - 1 | |
220 endwhile | |
532 | 221 else |
856 | 222 break |
409 | 223 endif |
532 | 224 endwhile |
225 | |
2442 | 226 if lnum==1 && getline(lnum) !~ '<?' |
532 | 227 let lnum=0 |
228 endif | |
229 | |
6421 | 230 if b:InPHPcode_and_script && 1 > b:InPHPcode |
532 | 231 let b:InPHPcode_and_script = 0 |
232 endif | |
1120 | 233 |
532 | 234 return lnum |
235 endfunction " }}} | |
409 | 236 |
557 | 237 function! Skippmatch2() |
238 | |
239 let line = getline(".") | |
240 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
241 if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\).*/\*' |
5862 | 242 return 1 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
243 else |
5862 | 244 return 0 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
245 endif |
557 | 246 endfun |
247 | |
2442 | 248 function! Skippmatch() " {{{ |
532 | 249 let synname = synIDattr(synID(line("."), col("."), 0), "name") |
6421 | 250 if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname =~# '^php\%(Doc\)\?Comment' && b:UserIsTypingComment |
532 | 251 return 0 |
252 else | |
253 return 1 | |
254 endif | |
255 endfun " }}} | |
409 | 256 |
5862 | 257 function! FindOpenBracket(lnum, blockStarter) " {{{ |
532 | 258 call cursor(a:lnum, 1) |
5862 | 259 let line = searchpair('{', '', '}', 'bW', 'Skippmatch()') |
260 | |
261 if a:blockStarter == 1 | |
6421 | 262 while line > 1 |
5862 | 263 let linec = getline(line) |
264 | |
265 if linec =~ s:terminated || linec =~ '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline | |
266 break | |
267 endif | |
268 | |
269 let line = GetLastRealCodeLNum(line - 1) | |
270 endwhile | |
271 endif | |
272 | |
273 return line | |
532 | 274 endfun " }}} |
409 | 275 |
276 function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{ | |
532 | 277 |
278 if getline(a:lnum) =~# '^\s*}\s*else\%(if\)\=\>' | |
279 let beforeelse = a:lnum | |
280 else | |
281 let beforeelse = GetLastRealCodeLNum(a:lnum - 1) | |
282 endif | |
409 | 283 |
532 | 284 if !s:level |
285 let s:iftoskip = 0 | |
286 endif | |
287 | |
288 if getline(beforeelse) =~# '^\s*\%(}\s*\)\=else\%(\s*if\)\@!\>' | |
289 let s:iftoskip = s:iftoskip + 1 | |
290 endif | |
291 | |
292 if getline(beforeelse) =~ '^\s*}' | |
5862 | 293 let beforeelse = FindOpenBracket(beforeelse, 0) |
532 | 294 |
295 if getline(beforeelse) =~ '^\s*{' | |
296 let beforeelse = GetLastRealCodeLNum(beforeelse - 1) | |
409 | 297 endif |
532 | 298 endif |
409 | 299 |
300 | |
532 | 301 if !s:iftoskip && a:StopAfterFirstPrevElse && getline(beforeelse) =~# '^\s*\%([}]\s*\)\=else\%(if\)\=\>' |
302 return beforeelse | |
303 endif | |
304 | |
305 if getline(beforeelse) !~# '^\s*if\>' && beforeelse>1 || s:iftoskip && beforeelse>1 | |
306 | |
2442 | 307 if s:iftoskip && getline(beforeelse) =~# '^\s*if\>' |
532 | 308 let s:iftoskip = s:iftoskip - 1 |
409 | 309 endif |
310 | |
532 | 311 let s:level = s:level + 1 |
312 let beforeelse = FindTheIfOfAnElse(beforeelse, a:StopAfterFirstPrevElse) | |
313 endif | |
409 | 314 |
532 | 315 return beforeelse |
409 | 316 |
532 | 317 endfunction " }}} |
409 | 318 |
2442 | 319 let s:defaultORcase = '^\s*\%(default\|case\).*:' |
320 | |
321 function! FindTheSwitchIndent (lnum) " {{{ | |
322 | |
323 let test = GetLastRealCodeLNum(a:lnum - 1) | |
324 | |
325 if test <= 1 | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
326 return indent(1) - s:sw() * b:PHP_vintage_case_default_indent |
2442 | 327 end |
328 | |
5862 | 329 while getline(test) =~ '^\s*}' && test > 1 |
330 let test = GetLastRealCodeLNum(FindOpenBracket(test, 0) - 1) | |
2442 | 331 |
5862 | 332 if getline(test) =~ '^\s*switch\>' |
333 let test = GetLastRealCodeLNum(test - 1) | |
2442 | 334 endif |
5862 | 335 endwhile |
2442 | 336 |
337 if getline(test) =~# '^\s*switch\>' | |
338 return indent(test) | |
339 elseif getline(test) =~# s:defaultORcase | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
340 return indent(test) - s:sw() * b:PHP_vintage_case_default_indent |
2442 | 341 else |
342 return FindTheSwitchIndent(test) | |
343 endif | |
344 | |
345 endfunction "}}} | |
346 | |
5294 | 347 let s:SynPHPMatchGroups = {'phpParent':1, 'Delimiter':1, 'Define':1, 'Storageclass':1, 'StorageClass':1, 'Structure':1, 'Exception':1} |
409 | 348 function! IslinePHP (lnum, tofind) " {{{ |
532 | 349 let cline = getline(a:lnum) |
409 | 350 |
532 | 351 if a:tofind=="" |
5862 | 352 let tofind = "^\\s*[\"'`]*\\s*\\zs\\S" |
532 | 353 else |
354 let tofind = a:tofind | |
355 endif | |
409 | 356 |
532 | 357 let tofind = tofind . '\c' |
409 | 358 |
532 | 359 let coltotest = match (cline, tofind) + 1 |
360 | |
361 let synname = synIDattr(synID(a:lnum, coltotest, 0), "name") | |
409 | 362 |
5862 | 363 if synname == 'phpStringSingle' || synname == 'phpStringDouble' || synname == 'phpBacktick' |
364 if cline !~ '^\s*[''"`]' | |
6421 | 365 return "SpecStringEntrails" |
5862 | 366 else |
367 return synname | |
368 end | |
369 end | |
370 | |
5277 | 371 if get(s:SynPHPMatchGroups, synname) || synname =~ '^php' || synname =~? '^javaScript' |
532 | 372 return synname |
373 else | |
374 return "" | |
375 endif | |
376 endfunction " }}} | |
409 | 377 |
2034 | 378 let s:autoresetoptions = 0 |
379 if ! s:autoresetoptions | |
380 let s:autoresetoptions = 1 | |
7 | 381 endif |
382 | |
2034 | 383 function! ResetPhpOptions() |
6421 | 384 if ! b:optionsset && &filetype =~ "php" |
557 | 385 if b:PHP_autoformatcomment |
386 | |
387 setlocal comments=s1:/*,mb:*,ex:*/,://,:# | |
856 | 388 |
1668 | 389 setlocal formatoptions-=t |
557 | 390 setlocal formatoptions+=q |
391 setlocal formatoptions+=r | |
392 setlocal formatoptions+=o | |
393 setlocal formatoptions+=c | |
394 setlocal formatoptions+=b | |
395 endif | |
532 | 396 let b:optionsset = 1 |
397 endif | |
409 | 398 endfunc |
399 | |
2034 | 400 call ResetPhpOptions() |
401 | |
409 | 402 function! GetPhpIndent() |
403 | |
631 | 404 let b:GetLastRealCodeLNum_ADD = 0 |
405 | |
532 | 406 let UserIsEditing=0 |
407 if b:PHP_oldchangetick != b:changedtick | |
408 let b:PHP_oldchangetick = b:changedtick | |
409 let UserIsEditing=1 | |
410 endif | |
409 | 411 |
532 | 412 if b:PHP_default_indenting |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
413 let b:PHP_default_indenting = g:PHP_default_indenting * s:sw() |
532 | 414 endif |
415 | |
416 let cline = getline(v:lnum) | |
409 | 417 |
856 | 418 if !b:PHP_indentinghuge && b:PHP_lastindented > b:PHP_indentbeforelast |
532 | 419 if b:PHP_indentbeforelast |
420 let b:PHP_indentinghuge = 1 | |
421 endif | |
422 let b:PHP_indentbeforelast = b:PHP_lastindented | |
423 endif | |
409 | 424 |
532 | 425 if b:InPHPcode_checked && prevnonblank(v:lnum - 1) != b:PHP_lastindented |
426 if b:PHP_indentinghuge | |
427 let b:PHP_indentinghuge = 0 | |
428 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
409 | 429 endif |
6421 | 430 let real_PHP_lastindented = v:lnum |
532 | 431 let b:PHP_LastIndentedWasComment=0 |
432 let b:PHP_InsideMultilineComment=0 | |
433 let b:PHP_indentbeforelast = 0 | |
409 | 434 |
532 | 435 let b:InPHPcode = 0 |
436 let b:InPHPcode_checked = 0 | |
437 let b:InPHPcode_and_script = 0 | |
438 let b:InPHPcode_tofind = "" | |
409 | 439 |
532 | 440 elseif v:lnum > b:PHP_lastindented |
441 let real_PHP_lastindented = b:PHP_lastindented | |
6421 | 442 else |
443 let real_PHP_lastindented = v:lnum | |
532 | 444 endif |
409 | 445 |
6421 | 446 let b:PHP_lastindented = v:lnum |
447 | |
409 | 448 |
532 | 449 if !b:InPHPcode_checked " {{{ One time check |
450 let b:InPHPcode_checked = 1 | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
451 let b:UserIsTypingComment = 0 |
409 | 452 |
631 | 453 let synname = "" |
454 if cline !~ '<?.*?>' | |
455 let synname = IslinePHP (prevnonblank(v:lnum), "") | |
456 endif | |
409 | 457 |
532 | 458 if synname!="" |
6421 | 459 if synname == "SpecStringEntrails" |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
460 let b:InPHPcode = -1 |
6421 | 461 let b:InPHPcode_tofind = "" |
462 elseif synname != "phpHereDoc" && synname != "phpHereDocDelimiter" | |
532 | 463 let b:InPHPcode = 1 |
464 let b:InPHPcode_tofind = "" | |
409 | 465 |
6421 | 466 if synname =~# '^php\%(Doc\)\?Comment' |
532 | 467 let b:UserIsTypingComment = 1 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
468 let b:InPHPcode_checked = 0 |
409 | 469 endif |
470 | |
532 | 471 if synname =~? '^javaScript' |
472 let b:InPHPcode_and_script = 1 | |
473 endif | |
409 | 474 |
532 | 475 else |
476 let b:InPHPcode = 0 | |
409 | 477 |
532 | 478 let lnum = v:lnum - 1 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
479 while getline(lnum) !~? '<<<\s*[''"]\=\a\w*[''"]\=$' && lnum > 1 |
532 | 480 let lnum = lnum - 1 |
481 endwhile | |
409 | 482 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
483 let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '') |
532 | 484 endif |
485 else | |
486 let b:InPHPcode = 0 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
487 let b:InPHPcode_tofind = s:PHP_startindenttag |
409 | 488 endif |
532 | 489 endif "!b:InPHPcode_checked }}} |
409 | 490 |
491 | |
532 | 492 " Test if we are indenting PHP code {{{ |
493 let lnum = prevnonblank(v:lnum - 1) | |
494 let last_line = getline(lnum) | |
5862 | 495 let endline= s:endline |
409 | 496 |
532 | 497 if b:InPHPcode_tofind!="" |
498 if cline =~? b:InPHPcode_tofind | |
499 let b:InPHPcode_tofind = "" | |
500 let b:UserIsTypingComment = 0 | |
6421 | 501 |
502 if b:InPHPcode == -1 | |
503 let b:InPHPcode = 1 | |
504 return -1 | |
505 end | |
506 | |
507 let b:InPHPcode = 1 | |
508 | |
532 | 509 if cline =~ '\*/' |
409 | 510 call cursor(v:lnum, 1) |
532 | 511 if cline !~ '^\*/' |
512 call search('\*/', 'W') | |
513 endif | |
557 | 514 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
409 | 515 |
516 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
517 | |
532 | 518 let b:PHP_LastIndentedWasComment = 0 |
409 | 519 |
532 | 520 if cline =~ '^\s*\*/' |
521 return indent(lnum) + 1 | |
522 else | |
523 return indent(lnum) | |
7 | 524 endif |
532 | 525 |
526 elseif cline =~? '<script\>' | |
527 let b:InPHPcode_and_script = 1 | |
631 | 528 let b:GetLastRealCodeLNum_ADD = v:lnum |
532 | 529 endif |
7 | 530 endif |
532 | 531 endif |
409 | 532 |
6421 | 533 if 1 == b:InPHPcode |
409 | 534 |
1120 | 535 if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~"Delimiter" |
532 | 536 if cline !~? s:PHP_startindenttag |
537 let b:InPHPcode = 0 | |
538 let b:InPHPcode_tofind = s:PHP_startindenttag | |
539 elseif cline =~? '<script\>' | |
540 let b:InPHPcode_and_script = 1 | |
541 endif | |
409 | 542 |
6421 | 543 elseif last_line =~ '^[^''"`]\+[''"`]$' |
544 let b:InPHPcode = -1 | |
5862 | 545 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
|
546 elseif last_line =~? '<<<\s*[''"]\=\a\w*[''"]\=$' |
532 | 547 let b:InPHPcode = 0 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
548 let b:InPHPcode_tofind = substitute( last_line, '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '') |
532 | 549 |
550 elseif !UserIsEditing && cline =~ '^\s*/\*\%(.*\*/\)\@!' && getline(v:lnum + 1) !~ '^\s*\*' | |
551 let b:InPHPcode = 0 | |
552 let b:InPHPcode_tofind = '\*/' | |
409 | 553 |
532 | 554 elseif cline =~? '^\s*</script>' |
555 let b:InPHPcode = 0 | |
556 let b:InPHPcode_tofind = s:PHP_startindenttag | |
557 endif | |
558 endif " }}} | |
559 | |
856 | 560 |
6421 | 561 if 1 > b:InPHPcode && !b:InPHPcode_and_script |
532 | 562 return -1 |
563 endif | |
409 | 564 |
532 | 565 " 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
|
566 let addSpecial = 0 |
532 | 567 if cline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
568 let addSpecial = b:PHP_outdentSLComments |
532 | 569 if b:PHP_LastIndentedWasComment == 1 |
570 return indent(real_PHP_lastindented) | |
571 endif | |
572 let b:PHP_LastIndentedWasComment = 1 | |
573 else | |
574 let b:PHP_LastIndentedWasComment = 0 | |
575 endif " }}} | |
576 | |
577 " Indent multiline /* comments correctly {{{ | |
578 | |
579 if b:PHP_InsideMultilineComment || b:UserIsTypingComment | |
580 if cline =~ '^\s*\*\%(\/\)\@!' | |
581 if last_line =~ '^\s*/\*' | |
582 return indent(lnum) + 1 | |
583 else | |
584 return indent(lnum) | |
585 endif | |
586 else | |
587 let b:PHP_InsideMultilineComment = 0 | |
588 endif | |
589 endif | |
590 | |
6421 | 591 if !b:PHP_InsideMultilineComment && cline =~ '^\s*/\*\%(.*\*/\)\@!' |
631 | 592 if getline(v:lnum + 1) !~ '^\s*\*' |
593 return -1 | |
594 endif | |
532 | 595 let b:PHP_InsideMultilineComment = 1 |
596 endif " }}} | |
409 | 597 |
598 | |
532 | 599 " Things always indented at col 1 (PHP delimiter: <?, ?>, Heredoc end) {{{ |
2442 | 600 if cline =~# '^\s*<?' && cline !~ '?>' && b:PHP_outdentphpescape |
532 | 601 return 0 |
602 endif | |
409 | 603 |
2442 | 604 if cline =~ '^\s*?>' && cline !~# '<?' && b:PHP_outdentphpescape |
532 | 605 return 0 |
606 endif | |
409 | 607 |
5862 | 608 if cline =~? '^\s*\a\w*;$\|^\a\w*$\|^\s*[''"`][;,]' && cline !~? s:notPhpHereDoc |
532 | 609 return 0 |
610 endif " }}} | |
409 | 611 |
532 | 612 let s:level = 0 |
409 | 613 |
532 | 614 let lnum = GetLastRealCodeLNum(v:lnum - 1) |
631 | 615 |
532 | 616 let last_line = getline(lnum) |
617 let ind = indent(lnum) | |
409 | 618 |
532 | 619 if ind==0 && b:PHP_default_indenting |
620 let ind = b:PHP_default_indenting | |
621 endif | |
409 | 622 |
532 | 623 if lnum == 0 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
624 return b:PHP_default_indenting + addSpecial |
532 | 625 endif |
409 | 626 |
627 | |
532 | 628 if cline =~ '^\s*}\%(}}\)\@!' |
5862 | 629 let ind = indent(FindOpenBracket(v:lnum, 1)) |
532 | 630 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting |
631 return ind | |
632 endif | |
409 | 633 |
532 | 634 if cline =~ '^\s*\*/' |
635 call cursor(v:lnum, 1) | |
636 if cline !~ '^\*/' | |
637 call search('\*/', 'W') | |
638 endif | |
557 | 639 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
532 | 640 |
641 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
409 | 642 |
532 | 643 if cline =~ '^\s*\*/' |
644 return indent(lnum) + 1 | |
645 else | |
646 return indent(lnum) | |
647 endif | |
648 endif | |
649 | |
650 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
651 if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase |
532 | 652 if ind==b:PHP_default_indenting |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
653 return b:PHP_default_indenting + addSpecial |
532 | 654 elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)' && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
655 return b:PHP_CurrentIndentLevel + addSpecial |
532 | 656 endif |
657 endif | |
658 | |
659 let LastLineClosed = 0 | |
660 | |
5862 | 661 let terminated = s:terminated |
532 | 662 |
663 let unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.endline | |
409 | 664 |
532 | 665 if ind != b:PHP_default_indenting && cline =~# '^\s*else\%(if\)\=\>' |
666 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
667 return indent(FindTheIfOfAnElse(v:lnum, 1)) | |
2442 | 668 elseif cline =~# s:defaultORcase |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
669 return FindTheSwitchIndent(v:lnum) + s:sw() * b:PHP_vintage_case_default_indent |
1668 | 670 elseif cline =~ '^\s*)\=\s*{' |
532 | 671 let previous_line = last_line |
672 let last_line_num = lnum | |
673 | |
674 while last_line_num > 1 | |
675 | |
5862 | 676 if previous_line =~ terminated || previous_line =~ '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . endline |
532 | 677 |
678 let ind = indent(last_line_num) | |
679 | |
680 if b:PHP_BracesAtCodeLevel | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
681 let ind = ind + s:sw() |
532 | 682 endif |
683 | |
856 | 684 return ind |
532 | 685 endif |
686 | |
5862 | 687 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) |
532 | 688 let previous_line = getline(last_line_num) |
689 endwhile | |
409 | 690 |
1668 | 691 elseif last_line =~# unstated && cline !~ '^\s*);\='.endline |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
692 let ind = ind + s:sw() |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
693 return ind + addSpecial |
532 | 694 |
6421 | 695 elseif (ind != b:PHP_default_indenting || last_line =~ '^[)\]]' ) && last_line =~ terminated |
532 | 696 let previous_line = last_line |
697 let last_line_num = lnum | |
698 let LastLineClosed = 1 | |
699 | |
5862 | 700 let isSingleLineBlock = 0 |
532 | 701 while 1 |
6421 | 702 if ! isSingleLineBlock && previous_line =~ '^\s*}\|;\s*}'.endline |
532 | 703 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
704 call cursor(last_line_num, 1) |
5862 | 705 if previous_line !~ '^}' |
706 call search('}\|;\s*}'.endline, 'W') | |
707 end | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
708 let oldLastLine = last_line_num |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
709 let last_line_num = searchpair('{', '', '}', 'bW', 'Skippmatch()') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
710 |
5862 | 711 if getline(last_line_num) =~ '^\s*{' |
532 | 712 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) |
5862 | 713 elseif oldLastLine == last_line_num |
714 let isSingleLineBlock = 1 | |
715 continue | |
409 | 716 endif |
532 | 717 |
718 let previous_line = getline(last_line_num) | |
7 | 719 |
532 | 720 continue |
721 else | |
5862 | 722 let isSingleLineBlock = 0 |
409 | 723 |
532 | 724 if getline(last_line_num) =~# '^\s*else\%(if\)\=\>' |
725 let last_line_num = FindTheIfOfAnElse(last_line_num, 0) | |
726 continue | |
727 endif | |
409 | 728 |
729 | |
532 | 730 let last_match = last_line_num |
409 | 731 |
532 | 732 let one_ahead_indent = indent(last_line_num) |
733 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) | |
734 let two_ahead_indent = indent(last_line_num) | |
735 let after_previous_line = previous_line | |
736 let previous_line = getline(last_line_num) | |
409 | 737 |
738 | |
2442 | 739 if previous_line =~# s:defaultORcase.'\|{'.endline |
532 | 740 break |
741 endif | |
409 | 742 |
532 | 743 if after_previous_line=~# '^\s*'.s:blockstart.'.*)'.endline && previous_line =~# '[;}]'.endline |
744 break | |
7 | 745 endif |
409 | 746 |
856 | 747 if one_ahead_indent == two_ahead_indent || last_line_num < 1 |
1668 | 748 if previous_line =~# '\%(;\|^\s*}\)'.endline || last_line_num < 1 |
532 | 749 break |
750 endif | |
751 endif | |
752 endif | |
753 endwhile | |
754 | |
755 if indent(last_match) != ind | |
756 let ind = indent(last_match) | |
757 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
758 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
759 return ind + addSpecial |
532 | 760 endif |
761 endif | |
762 | |
6421 | 763 if (last_line !~ '^\s*}\%(}}\)\@!') |
764 let plinnum = GetLastRealCodeLNum(lnum - 1) | |
765 else | |
766 let plinnum = GetLastRealCodeLNum(FindOpenBracket(lnum, 1) - 1) | |
767 endif | |
768 | |
2442 | 769 let AntepenultimateLine = getline(plinnum) |
532 | 770 |
771 let last_line = substitute(last_line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','') | |
772 | |
773 | |
774 if ind == b:PHP_default_indenting | |
6421 | 775 if last_line =~ terminated && last_line !~# s:defaultORcase |
532 | 776 let LastLineClosed = 1 |
777 endif | |
778 endif | |
779 | |
780 if !LastLineClosed | |
781 | |
2034 | 782 |
6421 | 783 if last_line =~# '[{(\[]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(\[]'.endline |
532 | 784 |
5862 | 785 let dontIndent = 0 |
6421 | 786 if last_line =~ '\S\+\s*{'.endline && last_line !~ '^\s*)\s*{'.endline && last_line !~ '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline |
5862 | 787 let dontIndent = 1 |
788 endif | |
789 | |
790 if !dontIndent && (!b:PHP_BracesAtCodeLevel || last_line !~# '^\s*{') | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
791 let ind = ind + s:sw() |
532 | 792 endif |
793 | |
2442 | 794 if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1 |
532 | 795 let b:PHP_CurrentIndentLevel = ind |
1668 | 796 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
797 return ind + addSpecial |
532 | 798 endif |
799 | |
800 elseif last_line =~ '\S\+\s*),'.endline | |
801 call cursor(lnum, 1) | |
6421 | 802 call search('),'.endline, 'W') |
532 | 803 let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()') |
804 if openedparent != lnum | |
805 let ind = indent(openedparent) | |
806 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
807 |
1668 | 808 elseif last_line =~ '^\s*'.s:blockstart |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
809 let ind = ind + s:sw() |
1668 | 810 |
532 | 811 |
6421 | 812 elseif AntepenultimateLine =~ '{'.endline || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
813 let ind = ind + s:sw() |
409 | 814 endif |
7 | 815 |
532 | 816 endif |
409 | 817 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
818 if cline =~ '^\s*[)\]];\=' |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
819 let ind = ind - s:sw() |
532 | 820 endif |
821 | |
822 let b:PHP_CurrentIndentLevel = ind | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
823 return ind + addSpecial |
7 | 824 endfunction |