annotate runtime/indent/php.vim @ 7690:0f193b74d989

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