Mercurial > vim
annotate runtime/indent/php.vim @ 11262:214f228718cf
Update runtime files.
commit https://github.com/vim/vim/commit/e0720cbf63eb3045be8d965e3182c0c392c7b5e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 29 13:48:40 2017 +0200
Update runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 29 Mar 2017 14:00:06 +0200 |
parents | 78106b0f2c56 |
children | 63b0b7b79b25 |
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 |
11262 | 6 " Last Change: 2017 March 12th |
7 " Version: 1.62 | |
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*(.*' |
11262 | 144 let s:endline = '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$' |
145 let s:unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.s:endline | |
6421 | 146 |
147 | |
11262 | 148 let s:terminated = '\%(\%(;\%(\s*\%(?>\|}\)\)\=\|<<<\s*[''"]\=\a\w*[''"]\=$\|^\s*}\|^\s*'.s:PHP_validVariable.':\)'.s:endline.'\)' |
409 | 149 let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!' |
11262 | 150 let s:structureHead = '^\s*\%(' . s:blockstart . '\)\|'. s:functionDecl . s:endline . '\|\<new\s\+class\>' |
409 | 151 |
152 | |
5862 | 153 |
154 let s:escapeDebugStops = 0 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
155 function! DebugPrintReturn(scriptLine) |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
156 |
6421 | 157 if ! s:escapeDebugStops |
5862 | 158 echo "debug:" . a:scriptLine |
159 let c = getchar() | |
160 if c == "\<Del>" | |
161 let s:escapeDebugStops = 1 | |
162 end | |
163 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
164 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
165 endfunction |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
166 |
409 | 167 function! GetLastRealCodeLNum(startline) " {{{ |
856 | 168 |
532 | 169 let lnum = a:startline |
856 | 170 |
631 | 171 if b:GetLastRealCodeLNum_ADD && b:GetLastRealCodeLNum_ADD == lnum + 1 |
172 let lnum = b:GetLastRealCodeLNum_ADD | |
173 endif | |
856 | 174 |
532 | 175 while lnum > 1 |
176 let lnum = prevnonblank(lnum) | |
177 let lastline = getline(lnum) | |
409 | 178 |
532 | 179 if b:InPHPcode_and_script && lastline =~ '?>\s*$' |
180 let lnum = lnum - 1 | |
181 elseif lastline =~ '^\s*?>.*<?\%(php\)\=\s*$' | |
182 let lnum = lnum - 1 | |
183 elseif lastline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' | |
184 let lnum = lnum - 1 | |
185 elseif lastline =~ '\*/\s*$' | |
186 call cursor(lnum, 1) | |
187 if lastline !~ '^\*/' | |
188 call search('\*/', 'W') | |
189 endif | |
557 | 190 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
409 | 191 |
532 | 192 let lastline = getline(lnum) |
193 if lastline =~ '^\s*/\*' | |
194 let lnum = lnum - 1 | |
195 else | |
196 break | |
197 endif | |
409 | 198 |
199 | |
532 | 200 elseif lastline =~? '\%(//\s*\|?>.*\)\@<!<?\%(php\)\=\s*$\|^\s*<script\>' |
201 | |
202 while lastline !~ '\(<?.*\)\@<!?>' && lnum > 1 | |
203 let lnum = lnum - 1 | |
204 let lastline = getline(lnum) | |
205 endwhile | |
206 if lastline =~ '^\s*?>' | |
207 let lnum = lnum - 1 | |
208 else | |
209 break | |
210 endif | |
211 | |
409 | 212 |
2442 | 213 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
|
214 let tofind=substitute( lastline, '\(\a\w*\);\=', '<<<\\s*[''"]\\=\1[''"]\\=$', '') |
532 | 215 while getline(lnum) !~? tofind && lnum > 1 |
216 let lnum = lnum - 1 | |
217 endwhile | |
5862 | 218 elseif lastline =~ '^[^''"`]*[''"`][;,]'.s:endline |
11262 | 219 |
220 let tofind=substitute( lastline, '^.*\([''"`]\)[;,].*$', '^[^\1]\\+[\1]$\\|^[^\1]\\+[=([]\\s*[\1]', '') | |
221 let trylnum = lnum | |
222 while getline(trylnum) !~? tofind && trylnum > 1 | |
223 let trylnum = trylnum - 1 | |
5862 | 224 endwhile |
11262 | 225 |
226 if trylnum == 1 | |
227 break | |
228 else | |
229 if lastline =~ ';'.s:endline | |
230 while getline(trylnum) !~? s:terminated && getline(trylnum) !~? '{'.s:endline && trylnum > 1 | |
231 let trylnum = prevnonblank(trylnum - 1) | |
232 endwhile | |
233 | |
234 | |
235 if trylnum == 1 | |
236 break | |
237 end | |
238 end | |
239 let lnum = trylnum | |
240 end | |
532 | 241 else |
856 | 242 break |
409 | 243 endif |
532 | 244 endwhile |
245 | |
2442 | 246 if lnum==1 && getline(lnum) !~ '<?' |
532 | 247 let lnum=0 |
248 endif | |
249 | |
6421 | 250 if b:InPHPcode_and_script && 1 > b:InPHPcode |
532 | 251 let b:InPHPcode_and_script = 0 |
252 endif | |
1120 | 253 |
532 | 254 return lnum |
255 endfunction " }}} | |
409 | 256 |
557 | 257 function! Skippmatch2() |
258 | |
259 let line = getline(".") | |
260 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
261 if line =~ "\\([\"']\\).*/\\*.*\\1" || line =~ '\%(//\|#\).*/\*' |
5862 | 262 return 1 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
263 else |
5862 | 264 return 0 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
265 endif |
557 | 266 endfun |
267 | |
2442 | 268 function! Skippmatch() " {{{ |
532 | 269 let synname = synIDattr(synID(line("."), col("."), 0), "name") |
6421 | 270 if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname =~# '^php\%(Doc\)\?Comment' && b:UserIsTypingComment |
532 | 271 return 0 |
272 else | |
273 return 1 | |
274 endif | |
275 endfun " }}} | |
409 | 276 |
5862 | 277 function! FindOpenBracket(lnum, blockStarter) " {{{ |
532 | 278 call cursor(a:lnum, 1) |
5862 | 279 let line = searchpair('{', '', '}', 'bW', 'Skippmatch()') |
280 | |
281 if a:blockStarter == 1 | |
6421 | 282 while line > 1 |
5862 | 283 let linec = getline(line) |
284 | |
11262 | 285 if linec =~ s:terminated || linec =~ s:structureHead |
5862 | 286 break |
287 endif | |
288 | |
289 let line = GetLastRealCodeLNum(line - 1) | |
290 endwhile | |
291 endif | |
292 | |
293 return line | |
532 | 294 endfun " }}} |
409 | 295 |
11262 | 296 let s:blockChars = {'{':1, '[': 1, '(': 1, ')':-1, ']':-1, '}':-1} |
297 function! BalanceDirection (str) | |
298 | |
299 let balance = 0 | |
300 | |
301 for c in split(a:str, '\zs') | |
302 if has_key(s:blockChars, c) | |
303 let balance += s:blockChars[c] | |
304 endif | |
305 endfor | |
306 | |
307 return balance | |
308 endfun | |
309 | |
409 | 310 function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{ |
532 | 311 |
312 if getline(a:lnum) =~# '^\s*}\s*else\%(if\)\=\>' | |
313 let beforeelse = a:lnum | |
314 else | |
315 let beforeelse = GetLastRealCodeLNum(a:lnum - 1) | |
316 endif | |
409 | 317 |
532 | 318 if !s:level |
319 let s:iftoskip = 0 | |
320 endif | |
321 | |
322 if getline(beforeelse) =~# '^\s*\%(}\s*\)\=else\%(\s*if\)\@!\>' | |
323 let s:iftoskip = s:iftoskip + 1 | |
324 endif | |
325 | |
326 if getline(beforeelse) =~ '^\s*}' | |
5862 | 327 let beforeelse = FindOpenBracket(beforeelse, 0) |
532 | 328 |
329 if getline(beforeelse) =~ '^\s*{' | |
330 let beforeelse = GetLastRealCodeLNum(beforeelse - 1) | |
409 | 331 endif |
532 | 332 endif |
409 | 333 |
334 | |
532 | 335 if !s:iftoskip && a:StopAfterFirstPrevElse && getline(beforeelse) =~# '^\s*\%([}]\s*\)\=else\%(if\)\=\>' |
336 return beforeelse | |
337 endif | |
338 | |
339 if getline(beforeelse) !~# '^\s*if\>' && beforeelse>1 || s:iftoskip && beforeelse>1 | |
340 | |
2442 | 341 if s:iftoskip && getline(beforeelse) =~# '^\s*if\>' |
532 | 342 let s:iftoskip = s:iftoskip - 1 |
409 | 343 endif |
344 | |
532 | 345 let s:level = s:level + 1 |
346 let beforeelse = FindTheIfOfAnElse(beforeelse, a:StopAfterFirstPrevElse) | |
347 endif | |
409 | 348 |
532 | 349 return beforeelse |
409 | 350 |
532 | 351 endfunction " }}} |
409 | 352 |
2442 | 353 let s:defaultORcase = '^\s*\%(default\|case\).*:' |
354 | |
355 function! FindTheSwitchIndent (lnum) " {{{ | |
356 | |
357 let test = GetLastRealCodeLNum(a:lnum - 1) | |
358 | |
359 if test <= 1 | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
360 return indent(1) - s:sw() * b:PHP_vintage_case_default_indent |
2442 | 361 end |
362 | |
5862 | 363 while getline(test) =~ '^\s*}' && test > 1 |
364 let test = GetLastRealCodeLNum(FindOpenBracket(test, 0) - 1) | |
2442 | 365 |
5862 | 366 if getline(test) =~ '^\s*switch\>' |
367 let test = GetLastRealCodeLNum(test - 1) | |
2442 | 368 endif |
5862 | 369 endwhile |
2442 | 370 |
371 if getline(test) =~# '^\s*switch\>' | |
372 return indent(test) | |
373 elseif getline(test) =~# s:defaultORcase | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
374 return indent(test) - s:sw() * b:PHP_vintage_case_default_indent |
2442 | 375 else |
376 return FindTheSwitchIndent(test) | |
377 endif | |
378 | |
379 endfunction "}}} | |
380 | |
5294 | 381 let s:SynPHPMatchGroups = {'phpParent':1, 'Delimiter':1, 'Define':1, 'Storageclass':1, 'StorageClass':1, 'Structure':1, 'Exception':1} |
409 | 382 function! IslinePHP (lnum, tofind) " {{{ |
532 | 383 let cline = getline(a:lnum) |
409 | 384 |
532 | 385 if a:tofind=="" |
5862 | 386 let tofind = "^\\s*[\"'`]*\\s*\\zs\\S" |
532 | 387 else |
388 let tofind = a:tofind | |
389 endif | |
409 | 390 |
532 | 391 let tofind = tofind . '\c' |
409 | 392 |
532 | 393 let coltotest = match (cline, tofind) + 1 |
394 | |
395 let synname = synIDattr(synID(a:lnum, coltotest, 0), "name") | |
409 | 396 |
5862 | 397 if synname == 'phpStringSingle' || synname == 'phpStringDouble' || synname == 'phpBacktick' |
398 if cline !~ '^\s*[''"`]' | |
6421 | 399 return "SpecStringEntrails" |
5862 | 400 else |
401 return synname | |
402 end | |
403 end | |
404 | |
5277 | 405 if get(s:SynPHPMatchGroups, synname) || synname =~ '^php' || synname =~? '^javaScript' |
532 | 406 return synname |
407 else | |
408 return "" | |
409 endif | |
410 endfunction " }}} | |
409 | 411 |
2034 | 412 let s:autoresetoptions = 0 |
413 if ! s:autoresetoptions | |
414 let s:autoresetoptions = 1 | |
7 | 415 endif |
416 | |
2034 | 417 function! ResetPhpOptions() |
6421 | 418 if ! b:optionsset && &filetype =~ "php" |
557 | 419 if b:PHP_autoformatcomment |
420 | |
421 setlocal comments=s1:/*,mb:*,ex:*/,://,:# | |
856 | 422 |
1668 | 423 setlocal formatoptions-=t |
557 | 424 setlocal formatoptions+=q |
425 setlocal formatoptions+=r | |
426 setlocal formatoptions+=o | |
427 setlocal formatoptions+=c | |
428 setlocal formatoptions+=b | |
429 endif | |
532 | 430 let b:optionsset = 1 |
431 endif | |
409 | 432 endfunc |
433 | |
2034 | 434 call ResetPhpOptions() |
435 | |
409 | 436 function! GetPhpIndent() |
437 | |
631 | 438 let b:GetLastRealCodeLNum_ADD = 0 |
439 | |
532 | 440 let UserIsEditing=0 |
441 if b:PHP_oldchangetick != b:changedtick | |
442 let b:PHP_oldchangetick = b:changedtick | |
443 let UserIsEditing=1 | |
444 endif | |
409 | 445 |
532 | 446 if b:PHP_default_indenting |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
447 let b:PHP_default_indenting = g:PHP_default_indenting * s:sw() |
532 | 448 endif |
449 | |
450 let cline = getline(v:lnum) | |
409 | 451 |
856 | 452 if !b:PHP_indentinghuge && b:PHP_lastindented > b:PHP_indentbeforelast |
532 | 453 if b:PHP_indentbeforelast |
454 let b:PHP_indentinghuge = 1 | |
455 endif | |
456 let b:PHP_indentbeforelast = b:PHP_lastindented | |
457 endif | |
409 | 458 |
532 | 459 if b:InPHPcode_checked && prevnonblank(v:lnum - 1) != b:PHP_lastindented |
460 if b:PHP_indentinghuge | |
461 let b:PHP_indentinghuge = 0 | |
462 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
409 | 463 endif |
6421 | 464 let real_PHP_lastindented = v:lnum |
532 | 465 let b:PHP_LastIndentedWasComment=0 |
466 let b:PHP_InsideMultilineComment=0 | |
467 let b:PHP_indentbeforelast = 0 | |
409 | 468 |
532 | 469 let b:InPHPcode = 0 |
470 let b:InPHPcode_checked = 0 | |
471 let b:InPHPcode_and_script = 0 | |
472 let b:InPHPcode_tofind = "" | |
409 | 473 |
532 | 474 elseif v:lnum > b:PHP_lastindented |
475 let real_PHP_lastindented = b:PHP_lastindented | |
6421 | 476 else |
477 let real_PHP_lastindented = v:lnum | |
532 | 478 endif |
409 | 479 |
6421 | 480 let b:PHP_lastindented = v:lnum |
481 | |
409 | 482 |
532 | 483 if !b:InPHPcode_checked " {{{ One time check |
484 let b:InPHPcode_checked = 1 | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
485 let b:UserIsTypingComment = 0 |
409 | 486 |
631 | 487 let synname = "" |
488 if cline !~ '<?.*?>' | |
489 let synname = IslinePHP (prevnonblank(v:lnum), "") | |
490 endif | |
409 | 491 |
532 | 492 if synname!="" |
6421 | 493 if synname == "SpecStringEntrails" |
11262 | 494 let b:InPHPcode = -1 " thumb down |
6421 | 495 let b:InPHPcode_tofind = "" |
496 elseif synname != "phpHereDoc" && synname != "phpHereDocDelimiter" | |
532 | 497 let b:InPHPcode = 1 |
498 let b:InPHPcode_tofind = "" | |
409 | 499 |
6421 | 500 if synname =~# '^php\%(Doc\)\?Comment' |
532 | 501 let b:UserIsTypingComment = 1 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
502 let b:InPHPcode_checked = 0 |
409 | 503 endif |
504 | |
532 | 505 if synname =~? '^javaScript' |
506 let b:InPHPcode_and_script = 1 | |
507 endif | |
409 | 508 |
532 | 509 else |
510 let b:InPHPcode = 0 | |
409 | 511 |
532 | 512 let lnum = v:lnum - 1 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
513 while getline(lnum) !~? '<<<\s*[''"]\=\a\w*[''"]\=$' && lnum > 1 |
532 | 514 let lnum = lnum - 1 |
515 endwhile | |
409 | 516 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
517 let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '') |
532 | 518 endif |
519 else | |
520 let b:InPHPcode = 0 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
521 let b:InPHPcode_tofind = s:PHP_startindenttag |
409 | 522 endif |
532 | 523 endif "!b:InPHPcode_checked }}} |
409 | 524 |
525 | |
532 | 526 " Test if we are indenting PHP code {{{ |
527 let lnum = prevnonblank(v:lnum - 1) | |
528 let last_line = getline(lnum) | |
5862 | 529 let endline= s:endline |
409 | 530 |
532 | 531 if b:InPHPcode_tofind!="" |
532 if cline =~? b:InPHPcode_tofind | |
533 let b:InPHPcode_tofind = "" | |
534 let b:UserIsTypingComment = 0 | |
6421 | 535 |
536 if b:InPHPcode == -1 | |
537 let b:InPHPcode = 1 | |
538 return -1 | |
539 end | |
540 | |
541 let b:InPHPcode = 1 | |
542 | |
532 | 543 if cline =~ '\*/' |
409 | 544 call cursor(v:lnum, 1) |
532 | 545 if cline !~ '^\*/' |
546 call search('\*/', 'W') | |
547 endif | |
557 | 548 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
409 | 549 |
550 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
551 | |
532 | 552 let b:PHP_LastIndentedWasComment = 0 |
409 | 553 |
532 | 554 if cline =~ '^\s*\*/' |
555 return indent(lnum) + 1 | |
556 else | |
557 return indent(lnum) | |
7 | 558 endif |
532 | 559 |
560 elseif cline =~? '<script\>' | |
561 let b:InPHPcode_and_script = 1 | |
631 | 562 let b:GetLastRealCodeLNum_ADD = v:lnum |
532 | 563 endif |
7 | 564 endif |
532 | 565 endif |
409 | 566 |
6421 | 567 if 1 == b:InPHPcode |
409 | 568 |
1120 | 569 if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~"Delimiter" |
532 | 570 if cline !~? s:PHP_startindenttag |
571 let b:InPHPcode = 0 | |
572 let b:InPHPcode_tofind = s:PHP_startindenttag | |
573 elseif cline =~? '<script\>' | |
574 let b:InPHPcode_and_script = 1 | |
575 endif | |
409 | 576 |
11262 | 577 elseif last_line =~ '^[^''"`]\+[''"`]$' " a string identifier with nothing after it and no other string identifier before |
6421 | 578 let b:InPHPcode = -1 |
5862 | 579 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
|
580 elseif last_line =~? '<<<\s*[''"]\=\a\w*[''"]\=$' |
532 | 581 let b:InPHPcode = 0 |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
582 let b:InPHPcode_tofind = substitute( last_line, '^.*<<<\s*[''"]\=\(\a\w*\)[''"]\=$', '^\\s*\1;\\=$', '') |
532 | 583 |
584 elseif !UserIsEditing && cline =~ '^\s*/\*\%(.*\*/\)\@!' && getline(v:lnum + 1) !~ '^\s*\*' | |
585 let b:InPHPcode = 0 | |
586 let b:InPHPcode_tofind = '\*/' | |
409 | 587 |
532 | 588 elseif cline =~? '^\s*</script>' |
589 let b:InPHPcode = 0 | |
590 let b:InPHPcode_tofind = s:PHP_startindenttag | |
591 endif | |
592 endif " }}} | |
593 | |
856 | 594 |
6421 | 595 if 1 > b:InPHPcode && !b:InPHPcode_and_script |
532 | 596 return -1 |
597 endif | |
409 | 598 |
532 | 599 " 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
|
600 let addSpecial = 0 |
532 | 601 if cline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)' |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
602 let addSpecial = b:PHP_outdentSLComments |
532 | 603 if b:PHP_LastIndentedWasComment == 1 |
604 return indent(real_PHP_lastindented) | |
605 endif | |
606 let b:PHP_LastIndentedWasComment = 1 | |
607 else | |
608 let b:PHP_LastIndentedWasComment = 0 | |
609 endif " }}} | |
610 | |
611 " Indent multiline /* comments correctly {{{ | |
612 | |
613 if b:PHP_InsideMultilineComment || b:UserIsTypingComment | |
614 if cline =~ '^\s*\*\%(\/\)\@!' | |
615 if last_line =~ '^\s*/\*' | |
616 return indent(lnum) + 1 | |
617 else | |
618 return indent(lnum) | |
619 endif | |
620 else | |
621 let b:PHP_InsideMultilineComment = 0 | |
622 endif | |
623 endif | |
624 | |
6421 | 625 if !b:PHP_InsideMultilineComment && cline =~ '^\s*/\*\%(.*\*/\)\@!' |
631 | 626 if getline(v:lnum + 1) !~ '^\s*\*' |
627 return -1 | |
628 endif | |
532 | 629 let b:PHP_InsideMultilineComment = 1 |
630 endif " }}} | |
409 | 631 |
632 | |
532 | 633 " Things always indented at col 1 (PHP delimiter: <?, ?>, Heredoc end) {{{ |
2442 | 634 if cline =~# '^\s*<?' && cline !~ '?>' && b:PHP_outdentphpescape |
532 | 635 return 0 |
636 endif | |
409 | 637 |
2442 | 638 if cline =~ '^\s*?>' && cline !~# '<?' && b:PHP_outdentphpescape |
532 | 639 return 0 |
640 endif | |
409 | 641 |
5862 | 642 if cline =~? '^\s*\a\w*;$\|^\a\w*$\|^\s*[''"`][;,]' && cline !~? s:notPhpHereDoc |
532 | 643 return 0 |
644 endif " }}} | |
409 | 645 |
532 | 646 let s:level = 0 |
409 | 647 |
532 | 648 let lnum = GetLastRealCodeLNum(v:lnum - 1) |
631 | 649 |
532 | 650 let last_line = getline(lnum) |
651 let ind = indent(lnum) | |
409 | 652 |
532 | 653 if ind==0 && b:PHP_default_indenting |
654 let ind = b:PHP_default_indenting | |
655 endif | |
409 | 656 |
532 | 657 if lnum == 0 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
658 return b:PHP_default_indenting + addSpecial |
532 | 659 endif |
409 | 660 |
661 | |
532 | 662 if cline =~ '^\s*}\%(}}\)\@!' |
5862 | 663 let ind = indent(FindOpenBracket(v:lnum, 1)) |
532 | 664 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting |
665 return ind | |
666 endif | |
409 | 667 |
532 | 668 if cline =~ '^\s*\*/' |
669 call cursor(v:lnum, 1) | |
670 if cline !~ '^\*/' | |
671 call search('\*/', 'W') | |
672 endif | |
557 | 673 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()') |
532 | 674 |
675 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
409 | 676 |
532 | 677 if cline =~ '^\s*\*/' |
678 return indent(lnum) + 1 | |
679 else | |
680 return indent(lnum) | |
681 endif | |
682 endif | |
683 | |
684 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
685 if last_line =~ '[;}]'.endline && last_line !~ '^[)\]]' && last_line !~# s:defaultORcase |
532 | 686 if ind==b:PHP_default_indenting |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
687 return b:PHP_default_indenting + addSpecial |
532 | 688 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
|
689 return b:PHP_CurrentIndentLevel + addSpecial |
532 | 690 endif |
691 endif | |
692 | |
693 let LastLineClosed = 0 | |
694 | |
5862 | 695 let terminated = s:terminated |
532 | 696 |
11262 | 697 let unstated = s:unstated |
698 | |
409 | 699 |
532 | 700 if ind != b:PHP_default_indenting && cline =~# '^\s*else\%(if\)\=\>' |
701 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
702 return indent(FindTheIfOfAnElse(v:lnum, 1)) | |
2442 | 703 elseif cline =~# s:defaultORcase |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
704 return FindTheSwitchIndent(v:lnum) + s:sw() * b:PHP_vintage_case_default_indent |
1668 | 705 elseif cline =~ '^\s*)\=\s*{' |
532 | 706 let previous_line = last_line |
707 let last_line_num = lnum | |
708 | |
709 while last_line_num > 1 | |
710 | |
11262 | 711 if previous_line =~ terminated || previous_line =~ s:structureHead |
532 | 712 |
713 let ind = indent(last_line_num) | |
714 | |
715 if b:PHP_BracesAtCodeLevel | |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
716 let ind = ind + s:sw() |
532 | 717 endif |
718 | |
856 | 719 return ind |
532 | 720 endif |
721 | |
5862 | 722 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) |
532 | 723 let previous_line = getline(last_line_num) |
724 endwhile | |
409 | 725 |
1668 | 726 elseif last_line =~# unstated && cline !~ '^\s*);\='.endline |
11262 | 727 let ind = ind + s:sw() " 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
|
728 return ind + addSpecial |
532 | 729 |
6421 | 730 elseif (ind != b:PHP_default_indenting || last_line =~ '^[)\]]' ) && last_line =~ terminated |
532 | 731 let previous_line = last_line |
732 let last_line_num = lnum | |
733 let LastLineClosed = 1 | |
734 | |
5862 | 735 let isSingleLineBlock = 0 |
532 | 736 while 1 |
11262 | 737 if ! isSingleLineBlock && previous_line =~ '^\s*}\|;\s*}'.endline " XXX |
532 | 738 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
739 call cursor(last_line_num, 1) |
5862 | 740 if previous_line !~ '^}' |
741 call search('}\|;\s*}'.endline, 'W') | |
742 end | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
743 let oldLastLine = last_line_num |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
744 let last_line_num = searchpair('{', '', '}', 'bW', 'Skippmatch()') |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
745 |
5862 | 746 if getline(last_line_num) =~ '^\s*{' |
532 | 747 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) |
5862 | 748 elseif oldLastLine == last_line_num |
749 let isSingleLineBlock = 1 | |
750 continue | |
409 | 751 endif |
532 | 752 |
753 let previous_line = getline(last_line_num) | |
7 | 754 |
532 | 755 continue |
756 else | |
5862 | 757 let isSingleLineBlock = 0 |
409 | 758 |
532 | 759 if getline(last_line_num) =~# '^\s*else\%(if\)\=\>' |
760 let last_line_num = FindTheIfOfAnElse(last_line_num, 0) | |
761 continue | |
762 endif | |
409 | 763 |
764 | |
532 | 765 let last_match = last_line_num |
409 | 766 |
532 | 767 let one_ahead_indent = indent(last_line_num) |
768 let last_line_num = GetLastRealCodeLNum(last_line_num - 1) | |
769 let two_ahead_indent = indent(last_line_num) | |
770 let after_previous_line = previous_line | |
771 let previous_line = getline(last_line_num) | |
409 | 772 |
773 | |
2442 | 774 if previous_line =~# s:defaultORcase.'\|{'.endline |
532 | 775 break |
776 endif | |
409 | 777 |
532 | 778 if after_previous_line=~# '^\s*'.s:blockstart.'.*)'.endline && previous_line =~# '[;}]'.endline |
779 break | |
7 | 780 endif |
409 | 781 |
856 | 782 if one_ahead_indent == two_ahead_indent || last_line_num < 1 |
1668 | 783 if previous_line =~# '\%(;\|^\s*}\)'.endline || last_line_num < 1 |
532 | 784 break |
785 endif | |
786 endif | |
787 endif | |
788 endwhile | |
789 | |
790 if indent(last_match) != ind | |
791 let ind = indent(last_match) | |
792 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting | |
793 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
794 return ind + addSpecial |
532 | 795 endif |
796 endif | |
797 | |
6421 | 798 if (last_line !~ '^\s*}\%(}}\)\@!') |
799 let plinnum = GetLastRealCodeLNum(lnum - 1) | |
800 else | |
801 let plinnum = GetLastRealCodeLNum(FindOpenBracket(lnum, 1) - 1) | |
802 endif | |
803 | |
2442 | 804 let AntepenultimateLine = getline(plinnum) |
532 | 805 |
806 let last_line = substitute(last_line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','') | |
807 | |
808 | |
809 if ind == b:PHP_default_indenting | |
6421 | 810 if last_line =~ terminated && last_line !~# s:defaultORcase |
532 | 811 let LastLineClosed = 1 |
812 endif | |
813 endif | |
814 | |
815 if !LastLineClosed | |
816 | |
2034 | 817 |
11262 | 818 if last_line =~# '[{(\[]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(\[]'.endline && BalanceDirection(last_line) > 0 |
532 | 819 |
5862 | 820 let dontIndent = 0 |
11262 | 821 if last_line =~ '\S\+\s*{'.endline && last_line !~ '^\s*[)\]]\+\s*{'.endline && last_line !~ s:structureHead |
5862 | 822 let dontIndent = 1 |
823 endif | |
824 | |
825 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
|
826 let ind = ind + s:sw() |
532 | 827 endif |
828 | |
2442 | 829 if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1 |
532 | 830 let b:PHP_CurrentIndentLevel = ind |
1668 | 831 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
832 return ind + addSpecial |
532 | 833 endif |
834 | |
11262 | 835 elseif last_line =~ '\S\+\s*),'.endline && BalanceDirection(last_line) < 0 |
532 | 836 call cursor(lnum, 1) |
11262 | 837 call search('),'.endline, 'W') " line never begins with ) so no need for 'c' flag |
532 | 838 let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()') |
839 if openedparent != lnum | |
840 let ind = indent(openedparent) | |
841 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
842 |
1668 | 843 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
|
844 let ind = ind + s:sw() |
1668 | 845 |
532 | 846 |
11262 | 847 elseif AntepenultimateLine =~ '{'.endline && AntepenultimateLine !~? '^\s*use\>' || AntepenultimateLine =~ terminated || AntepenultimateLine =~# s:defaultORcase |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
848 let ind = ind + s:sw() |
409 | 849 endif |
7 | 850 |
532 | 851 endif |
409 | 852 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
853 if cline =~ '^\s*[)\]];\=' |
7992
78106b0f2c56
commit https://github.com/vim/vim/commit/cbebd4879cc78e670d79b2c57dc33d7b911c962a
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
854 let ind = ind - s:sw() |
532 | 855 endif |
856 | |
857 let b:PHP_CurrentIndentLevel = ind | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2442
diff
changeset
|
858 return ind + addSpecial |
7 | 859 endfunction |