annotate runtime/indent/php.vim @ 3764:c2c3577021ed v7.3.640

updated for version 7.3.640 Problem: It's not easy to build Vim on Windows with XPM support. Solution: Binary files for 7.3.639. (Sergey Khorev)
author Bram Moolenaar <bram@vim.org>
date Wed, 29 Aug 2012 14:26:27 +0200
parents 14f01499dd16
children 605c9ce57ec3
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
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
5 " Last Change: 2010 Jully 26th
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
6 " Newsletter: http://www.2072productions.com/?to=php-indent-for-vim-newsletter.php
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
7 " Version: 1.33
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 "
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
10 " If you find a bug, please report it on GitHub:
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
11 " http://github.com/2072/PHP-Indenting-for-VIm/issues
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
12 " with an example of code that breaks the algorithm.
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 "
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
15 " Thanks a lot for using this script.
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
16 "
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
17 "
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
18 " NOTE: This script must be used with PHP syntax ON and with the php syntax
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
19 " script by Lutz Eymers (http://www.ipdienste.net/data/php.vim ) or with the
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
20 " 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
21 " the later is bunbdled by default with Vim 7.
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
22 "
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
23 "
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
24 " 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
25 " 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
26 " script will automatically put HereDoc end identifiers at col 1 if
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
27 " they are followed by a ';').
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
28 "
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
29 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
30 " 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
31 " 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
32 " 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
33 " '\s*$' correctly.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
34 " 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
35 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
36 " :%s /\r$//g
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
38 " 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
39 " silently remove them when VIM load this script (at each bufread).
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
40 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
41 " Options: See :help php-indent for available options.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
42
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
43
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 if exists("b:did_indent")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
45 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
49
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
50 let php_sync_method = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
51
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
52
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
53 if exists("PHP_default_indenting")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
54 let b:PHP_default_indenting = PHP_default_indenting * &sw
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
55 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
56 let b:PHP_default_indenting = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
57 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
58
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
59 if exists("PHP_BracesAtCodeLevel")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
60 let b:PHP_BracesAtCodeLevel = PHP_BracesAtCodeLevel
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
61 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
62 let b:PHP_BracesAtCodeLevel = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
63 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
64
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
65
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
66 if exists("PHP_autoformatcomment")
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
67 let b:PHP_autoformatcomment = PHP_autoformatcomment
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
68 else
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
69 let b:PHP_autoformatcomment = 1
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
70 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
72 if exists("PHP_outdentphpescape")
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
73 let b:PHP_outdentphpescape = PHP_outdentphpescape
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
74 else
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
75 let b:PHP_outdentphpescape = 1
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
76 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
77
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
78
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
79 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
80 let b:PHP_vintage_case_default_indent = 1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
81 else
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
82 let b:PHP_vintage_case_default_indent = 0
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
83 endif
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
84
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
85
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
86
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
87 let b:PHP_lastindented = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
88 let b:PHP_indentbeforelast = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
89 let b:PHP_indentinghuge = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
90 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
91 let b:PHP_LastIndentedWasComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
92 let b:PHP_InsideMultilineComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
93 let b:InPHPcode = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
94 let b:InPHPcode_checked = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
95 let b:InPHPcode_and_script = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
96 let b:InPHPcode_tofind = ""
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
97 let b:PHP_oldchangetick = b:changedtick
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
98 let b:UserIsTypingComment = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
99 let b:optionsset = 0
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
100
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
101 setlocal nosmartindent
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
102 setlocal noautoindent
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
103 setlocal nocindent
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
104 setlocal nolisp
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
105
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
106 setlocal indentexpr=GetPhpIndent()
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
107 setlocal indentkeys=0{,0},0),:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
108
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
109
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
110
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
111 let s:searchpairflags = 'bWr'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
112
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
113 if &fileformat == "unix" && exists("PHP_removeCRwhenUnix") && PHP_removeCRwhenUnix
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
114 silent! %s/\r$//g
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
115 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
116
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 if exists("*GetPhpIndent")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
118 call ResetPhpOptions()
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
119 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
122 let s:endline= '\s*\%(//.*\|#.*\|/\*.*\*/\s*\)\=$'
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
123 let s:PHP_startindenttag = '<?\%(.*?>\)\@!\|<script[^>]*>\%(.*<\/script>\)\@!'
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
124
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
125
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
126 function! GetLastRealCodeLNum(startline) " {{{
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
127
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
128 let lnum = a:startline
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
129
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
130 if b:GetLastRealCodeLNum_ADD && b:GetLastRealCodeLNum_ADD == lnum + 1
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
131 let lnum = b:GetLastRealCodeLNum_ADD
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
132 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
133
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
134 let old_lnum = lnum
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
135
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
136 while lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
137 let lnum = prevnonblank(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
138 let lastline = getline(lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
139
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
140 if b:InPHPcode_and_script && lastline =~ '?>\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
141 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
142 elseif lastline =~ '^\s*?>.*<?\%(php\)\=\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
143 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
144 elseif lastline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
145 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
146 elseif lastline =~ '\*/\s*$'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
147 call cursor(lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
148 if lastline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
149 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
150 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
151 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
152
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
153 let lastline = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
154 if lastline =~ '^\s*/\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
155 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
156 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
157 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
158 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
159
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
160
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
161 elseif lastline =~? '\%(//\s*\|?>.*\)\@<!<?\%(php\)\=\s*$\|^\s*<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
162
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
163 while lastline !~ '\(<?.*\)\@<!?>' && lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
164 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
165 let lastline = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
166 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
167 if lastline =~ '^\s*?>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
168 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
169 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
170 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
171 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
172
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
173
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
174 elseif lastline =~? '^\a\w*;\=$' && lastline !~? s:notPhpHereDoc
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
175 let tofind=substitute( lastline, '\(\a\w*\);\=', '<<<''\\=\1''\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
176 while getline(lnum) !~? tofind && lnum > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
177 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
178 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
179 else
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
180 break
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
181 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
182 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
183
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
184 if lnum==1 && getline(lnum) !~ '<?'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
185 let lnum=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
186 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
187
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
188 if b:InPHPcode_and_script && !b:InPHPcode
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
189 let b:InPHPcode_and_script = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
190 endif
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
191
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
192
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
193
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
194 return lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
195 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
196
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
197 function! Skippmatch2()
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
198
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
199 let line = getline(".")
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
200
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
201 if line =~ '\%(".*\)\@<=/\*\%(.*"\)\@=' || line =~ '\%(\%(//\|#\).*\)\@<=/\*'
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
202 return 1
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
203 else
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
204 return 0
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
205 endif
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
206 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
207
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
208 function! Skippmatch() " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
209 let synname = synIDattr(synID(line("."), col("."), 0), "name")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
210 if synname == "Delimiter" || synname == "phpRegionDelimiter" || synname =~# "^phpParent" || synname == "phpArrayParens" || synname =~# '^php\%(Block\|Brace\)' || synname == "javaScriptBraces" || synname =~# "^phpComment" && b:UserIsTypingComment
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
211 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
212 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
213 return 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
214 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
215 endfun " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
216
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
217 function! FindOpenBracket(lnum) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
218 call cursor(a:lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
219 return searchpair('{', '', '}', 'bW', 'Skippmatch()')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
220 endfun " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
221
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
222 function! FindTheIfOfAnElse (lnum, StopAfterFirstPrevElse) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
223
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
224 if getline(a:lnum) =~# '^\s*}\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
225 let beforeelse = a:lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
226 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
227 let beforeelse = GetLastRealCodeLNum(a:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
228 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
229
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
230 if !s:level
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
231 let s:iftoskip = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
232 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
233
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
234 if getline(beforeelse) =~# '^\s*\%(}\s*\)\=else\%(\s*if\)\@!\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
235 let s:iftoskip = s:iftoskip + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
236 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
237
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
238 if getline(beforeelse) =~ '^\s*}'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
239 let beforeelse = FindOpenBracket(beforeelse)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
240
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
241 if getline(beforeelse) =~ '^\s*{'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
242 let beforeelse = GetLastRealCodeLNum(beforeelse - 1)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
243 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
244 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
245
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
246
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
247 if !s:iftoskip && a:StopAfterFirstPrevElse && getline(beforeelse) =~# '^\s*\%([}]\s*\)\=else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
248 return beforeelse
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
249 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
250
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
251 if getline(beforeelse) !~# '^\s*if\>' && beforeelse>1 || s:iftoskip && beforeelse>1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
252
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
253 if s:iftoskip && getline(beforeelse) =~# '^\s*if\>'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
254 let s:iftoskip = s:iftoskip - 1
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
255 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
256
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
257 let s:level = s:level + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
258 let beforeelse = FindTheIfOfAnElse(beforeelse, a:StopAfterFirstPrevElse)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
259 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
260
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
261 return beforeelse
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
262
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
263 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
264
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
265 let s:defaultORcase = '^\s*\%(default\|case\).*:'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
266
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
267 function! FindTheSwitchIndent (lnum) " {{{
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
268
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
269
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
270 let test = GetLastRealCodeLNum(a:lnum - 1)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
271
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
272 if test <= 1
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
273 return indent(1) - &sw * b:PHP_vintage_case_default_indent
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
274 end
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
275
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
276 if getline(test) =~ '^\s*}'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
277 let test = FindOpenBracket(test)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
278
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
279 if getline(test) =~ '^\s*{'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
280 let test = GetLastRealCodeLNum(GetLastRealCodeLNum(test - 1) - 1)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
281 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
282 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
283
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
284 if getline(test) =~# '^\s*switch\>'
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
285 return indent(test)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
286 elseif getline(test) =~# s:defaultORcase
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
287 return indent(test) - &sw * b:PHP_vintage_case_default_indent
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
288 else
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
289 return FindTheSwitchIndent(test)
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
290 endif
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
291
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
292 endfunction "}}}
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
293
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
294
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
295 function! IslinePHP (lnum, tofind) " {{{
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
296 let cline = getline(a:lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
297
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
298 if a:tofind==""
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
299 let tofind = "^\\s*[\"']*\\s*\\zs\\S"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
300 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
301 let tofind = a:tofind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
302 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
303
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
304 let tofind = tofind . '\c'
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 let coltotest = match (cline, tofind) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
307
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
308 let synname = synIDattr(synID(a:lnum, coltotest, 0), "name")
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
309
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
310 if synname =~ '^php' || synname=="Delimiter" || synname =~? '^javaScript'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
311 return synname
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
312 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
313 return ""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
314 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
315 endfunction " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
316
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
317 let s:notPhpHereDoc = '\%(break\|return\|continue\|exit\|else\)'
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
318 let s:blockstart = '\%(\%(\%(}\s*\)\=else\%(\s\+\)\=\)\=if\>\|else\>\|while\>\|switch\>\|case\>\|default\>\|for\%(each\)\=\>\|declare\>\|class\>\|interface\>\|abstract\>\|try\>\|catch\>\)'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
319
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
320 let s:autoresetoptions = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
321 if ! s:autoresetoptions
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
322 let s:autoresetoptions = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
325 function! ResetPhpOptions()
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
326 if ! b:optionsset && &filetype == "php"
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
327 if b:PHP_autoformatcomment
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
328
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
329 setlocal comments=s1:/*,mb:*,ex:*/,://,:#
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
330
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
331 setlocal formatoptions-=t
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
332 setlocal formatoptions+=q
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
333 setlocal formatoptions+=r
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
334 setlocal formatoptions+=o
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
335 setlocal formatoptions+=w
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
336 setlocal formatoptions+=c
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
337 setlocal formatoptions+=b
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
338 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
339 let b:optionsset = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
340 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
341 endfunc
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
342
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
343 call ResetPhpOptions()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
344
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
345 function! GetPhpIndent()
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
346
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
347 let b:GetLastRealCodeLNum_ADD = 0
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
348
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
349 let UserIsEditing=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
350 if b:PHP_oldchangetick != b:changedtick
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
351 let b:PHP_oldchangetick = b:changedtick
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
352 let UserIsEditing=1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
353 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
354
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
355 if b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
356 let b:PHP_default_indenting = g:PHP_default_indenting * &sw
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
357 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
358
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
359 let cline = getline(v:lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
360
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
361 if !b:PHP_indentinghuge && b:PHP_lastindented > b:PHP_indentbeforelast
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
362 if b:PHP_indentbeforelast
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
363 let b:PHP_indentinghuge = 1
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
364 echom 'Large indenting detected, speed optimizations engaged (v1.33)'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
365 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
366 let b:PHP_indentbeforelast = b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
367 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
368
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
369 if b:InPHPcode_checked && prevnonblank(v:lnum - 1) != b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
370 if b:PHP_indentinghuge
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
371 echom 'Large indenting deactivated'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
372 let b:PHP_indentinghuge = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
373 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
374 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
375 let b:PHP_lastindented = v:lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
376 let b:PHP_LastIndentedWasComment=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
377 let b:PHP_InsideMultilineComment=0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
378 let b:PHP_indentbeforelast = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
379
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
380 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
381 let b:InPHPcode_checked = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
382 let b:InPHPcode_and_script = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
383 let b:InPHPcode_tofind = ""
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
384
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
385 elseif v:lnum > b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
386 let real_PHP_lastindented = b:PHP_lastindented
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
387 let b:PHP_lastindented = v:lnum
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
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
390
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
391 if !b:InPHPcode_checked " {{{ One time check
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
392 let b:InPHPcode_checked = 1
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
393
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
394 let synname = ""
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
395 if cline !~ '<?.*?>'
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
396 let synname = IslinePHP (prevnonblank(v:lnum), "")
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
397 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
398
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
399 if synname!=""
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
400 if synname != "phpHereDoc" && synname != "phpHereDocDelimiter"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
401 let b:InPHPcode = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
402 let b:InPHPcode_tofind = ""
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
403
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
404 if synname =~# "^phpComment"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
405 let b:UserIsTypingComment = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
406 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
407 let b:UserIsTypingComment = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
408 endif
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
409
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
410 if synname =~? '^javaScript'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
411 let b:InPHPcode_and_script = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
412 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
413
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
414 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
415 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
416 let b:UserIsTypingComment = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
417
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
418 let lnum = v:lnum - 1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
419 while getline(lnum) !~? '<<<''\=\a\w*''\=$' && lnum > 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
420 let lnum = lnum - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
421 endwhile
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
422
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
423 let b:InPHPcode_tofind = substitute( getline(lnum), '^.*<<<''\=\(\a\w*\)''\=$', '^\\s*\1;\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
424 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
425 else
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:UserIsTypingComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
428 let b:InPHPcode_tofind = '<?\%(.*?>\)\@!\|<script.*>'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
429 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
430 endif "!b:InPHPcode_checked }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
431
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
432
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
433 " Test if we are indenting PHP code {{{
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
434 let lnum = prevnonblank(v:lnum - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
435 let last_line = getline(lnum)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
436
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
437 if b:InPHPcode_tofind!=""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
438 if cline =~? b:InPHPcode_tofind
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
439 let b:InPHPcode = 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
440 let b:InPHPcode_tofind = ""
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
441 let b:UserIsTypingComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
442 if cline =~ '\*/'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
443 call cursor(v:lnum, 1)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
444 if cline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
445 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
446 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
447 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
448
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
449 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
450
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
451 let b:PHP_LastIndentedWasComment = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
452
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
453 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
454 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
455 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
456 return indent(lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
458
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
459 elseif cline =~? '<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
460 let b:InPHPcode_and_script = 1
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
461 let b:GetLastRealCodeLNum_ADD = v:lnum
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
462 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
464 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
465
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
466 if b:InPHPcode
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
467
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
468 if !b:InPHPcode_and_script && last_line =~ '\%(<?.*\)\@<!?>\%(.*<?\)\@!' && IslinePHP(lnum, '?>')=~"Delimiter"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
469 if cline !~? s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
470 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
471 let b:InPHPcode_tofind = s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
472 elseif cline =~? '<script\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
473 let b:InPHPcode_and_script = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
474 endif
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 elseif last_line =~? '<<<''\=\a\w*''\=$'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
477 let b:InPHPcode = 0
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
478 let b:InPHPcode_tofind = substitute( last_line, '^.*<<<''\=\(\a\w*\)''\=$', '^\\s*\1;\\=$', '')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
479
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
480 elseif !UserIsEditing && cline =~ '^\s*/\*\%(.*\*/\)\@!' && getline(v:lnum + 1) !~ '^\s*\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
481 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
482 let b:InPHPcode_tofind = '\*/'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
483
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
484 elseif cline =~? '^\s*</script>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
485 let b:InPHPcode = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
486 let b:InPHPcode_tofind = s:PHP_startindenttag
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
487 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
488 endif " }}}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
489
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
490
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
491 if !b:InPHPcode && !b:InPHPcode_and_script
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
492 return -1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
493 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
494
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
495 " Indent successive // or # comment the same way the first is {{{
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
496 if cline =~ '^\s*\%(//\|#\|/\*.*\*/\s*$\)'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
497 if b:PHP_LastIndentedWasComment == 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
498 return indent(real_PHP_lastindented)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
499 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
500 let b:PHP_LastIndentedWasComment = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
501 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
502 let b:PHP_LastIndentedWasComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
503 endif " }}}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
504
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
505 " Indent multiline /* comments correctly {{{
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
506
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
507 if b:PHP_InsideMultilineComment || b:UserIsTypingComment
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
508 if cline =~ '^\s*\*\%(\/\)\@!'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
509 if last_line =~ '^\s*/\*'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
510 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
511 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
512 return indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
513 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
514 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
515 let b:PHP_InsideMultilineComment = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
516 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
517 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
518
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
519 if !b:PHP_InsideMultilineComment && cline =~ '^\s*/\*' && cline !~ '\*/\s*$'
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
520 if getline(v:lnum + 1) !~ '^\s*\*'
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
521 return -1
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
522 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
523 let b:PHP_InsideMultilineComment = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
524 endif " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
525
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
526
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
527 " 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
528 if cline =~# '^\s*<?' && cline !~ '?>' && b:PHP_outdentphpescape
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
529 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
530 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
531
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
532 if cline =~ '^\s*?>' && cline !~# '<?' && b:PHP_outdentphpescape
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
533 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
534 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
535
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
536 if cline =~? '^\s*\a\w*;$\|^\a\w*$' && cline !~? s:notPhpHereDoc
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
537 return 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
538 endif " }}}
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
539
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
540 let s:level = 0
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
541
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
542 let lnum = GetLastRealCodeLNum(v:lnum - 1)
631
68a196b7504d updated for version 7.0182
vimboss
parents: 557
diff changeset
543
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
544 let last_line = getline(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
545 let ind = indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
546 let endline= s:endline
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 if ind==0 && b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
549 let ind = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
550 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
551
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
552 if lnum == 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
553 return b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
554 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
555
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
556
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
557 if cline =~ '^\s*}\%(}}\)\@!'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
558 let ind = indent(FindOpenBracket(v:lnum))
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
559 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
560 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
561 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
562
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
563 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
564 call cursor(v:lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
565 if cline !~ '^\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
566 call search('\*/', 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
567 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 532
diff changeset
568 let lnum = searchpair('/\*', '', '\*/', s:searchpairflags, 'Skippmatch2()')
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
569
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
570 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
571
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
572 if cline =~ '^\s*\*/'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
573 return indent(lnum) + 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
574 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
575 return indent(lnum)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
576 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
577 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
578
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
579
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
580 if last_line =~ '[;}]'.endline && last_line !~ '^)' && last_line !~# s:defaultORcase
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
581 if ind==b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
582 return b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
583 elseif b:PHP_indentinghuge && ind==b:PHP_CurrentIndentLevel && cline !~# '^\s*\%(else\|\%(case\|default\).*:\|[})];\=\)' && last_line !~# '^\s*\%(\%(}\s*\)\=else\)' && getline(GetLastRealCodeLNum(lnum - 1))=~';'.endline
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
584 return b:PHP_CurrentIndentLevel
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
585 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
586 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
587
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
588 let LastLineClosed = 0
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
589
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
590 let terminated = '\%(;\%(\s*?>\)\=\|<<<''\=\a\w*''\=$\|^\s*}\)'.endline
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
591
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
592 let unstated = '\%(^\s*'.s:blockstart.'.*)\|\%(//.*\)\@<!\<e'.'lse\>\)'.endline
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
593
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
594 if ind != b:PHP_default_indenting && cline =~# '^\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
595 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
596 return indent(FindTheIfOfAnElse(v:lnum, 1))
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
597 elseif cline =~# s:defaultORcase
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
598 return FindTheSwitchIndent(v:lnum) + &sw * b:PHP_vintage_case_default_indent
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
599 elseif cline =~ '^\s*)\=\s*{'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
600 let previous_line = last_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
601 let last_line_num = lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
602
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
603 while last_line_num > 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
604
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
605 if previous_line =~ '^\s*\%(' . s:blockstart . '\|\%([a-zA-Z]\s*\)*function\)'
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
606
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
607 let ind = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
608
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
609 if b:PHP_BracesAtCodeLevel
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
610 let ind = ind + &sw
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
611 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
612
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
613 return ind
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
614 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
615
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
616 let last_line_num = last_line_num - 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
617 let previous_line = getline(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
618 endwhile
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
619
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
620 elseif last_line =~# unstated && cline !~ '^\s*);\='.endline
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
621 let ind = ind + &sw
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
622 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
623
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
624 elseif (ind != b:PHP_default_indenting || last_line =~ '^)' ) && last_line =~ terminated
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
625 let previous_line = last_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
626 let last_line_num = lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
627 let LastLineClosed = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
628
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
629 while 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
630 if previous_line =~ '^\s*}'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
631 let last_line_num = FindOpenBracket(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
632
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
633 if getline(last_line_num) =~ '^\s*{'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
634 let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
635 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
636
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
637 let previous_line = getline(last_line_num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
639 continue
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
640 else
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
641
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
642 if getline(last_line_num) =~# '^\s*else\%(if\)\=\>'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
643 let last_line_num = FindTheIfOfAnElse(last_line_num, 0)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
644 continue
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
645 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
646
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
647
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
648 let last_match = last_line_num
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
649
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
650 let one_ahead_indent = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
651 let last_line_num = GetLastRealCodeLNum(last_line_num - 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
652 let two_ahead_indent = indent(last_line_num)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
653 let after_previous_line = previous_line
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
654 let previous_line = getline(last_line_num)
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
655
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
656
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
657 if previous_line =~# s:defaultORcase.'\|{'.endline
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
658 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
659 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
660
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
661 if after_previous_line=~# '^\s*'.s:blockstart.'.*)'.endline && previous_line =~# '[;}]'.endline
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
662 break
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
664
856
8cd729851562 updated for version 7.0g
vimboss
parents: 631
diff changeset
665 if one_ahead_indent == two_ahead_indent || last_line_num < 1
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
666 if previous_line =~# '\%(;\|^\s*}\)'.endline || last_line_num < 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
667 break
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
668 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
669 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
670 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
671 endwhile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
672
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
673 if indent(last_match) != ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
674 let ind = indent(last_match)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
675 let b:PHP_CurrentIndentLevel = b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
676
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
677 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
678 endif
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
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
681 let plinnum = GetLastRealCodeLNum(lnum - 1)
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
682 let AntepenultimateLine = getline(plinnum)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
683
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
684 let last_line = substitute(last_line,"\\(//\\|#\\)\\(\\(\\([^\"']*\\([\"']\\)[^\"']*\\5\\)\\+[^\"']*$\\)\\|\\([^\"']*$\\)\\)",'','')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
685
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
686
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
687 if ind == b:PHP_default_indenting
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
688 if last_line =~ terminated
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
689 let LastLineClosed = 1
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
690 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
691 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
692
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
693 if !LastLineClosed
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
694
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
695
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
696 if last_line =~# '[{(]'.endline || last_line =~? '\h\w*\s*(.*,$' && AntepenultimateLine !~ '[,(]'.endline
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
697
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
698 if !b:PHP_BracesAtCodeLevel || last_line !~# '^\s*{'
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
699 let ind = ind + &sw
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
700 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
701
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
702 if b:PHP_BracesAtCodeLevel || b:PHP_vintage_case_default_indent == 1
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
703 let b:PHP_CurrentIndentLevel = ind
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
704
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
705 return ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
706 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
707
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
708 elseif last_line =~ '\S\+\s*),'.endline
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
709 call cursor(lnum, 1)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
710 call search('),'.endline, 'W')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
711 let openedparent = searchpair('(', '', ')', 'bW', 'Skippmatch()')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
712 if openedparent != lnum
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
713 let ind = indent(openedparent)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
714 endif
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
715
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
716 elseif last_line =~ '^\s*'.s:blockstart
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
717 let ind = ind + &sw
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1619
diff changeset
718
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
719
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
720
2442
14f01499dd16 More updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
721 elseif AntepenultimateLine =~ '\%(;\%(\s*?>\)\=\|<<<''\=\a\w*''\=$\|^\s*}\|{\)'.endline . '\|' . s:defaultORcase
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
722 let ind = ind + &sw
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
723 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
725 endif
409
e6fd82f42ba0 updated for version 7.0107
vimboss
parents: 227
diff changeset
726
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
727 if cline =~ '^\s*);\='
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
728 let ind = ind - &sw
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
729 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
730
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
731 let b:PHP_CurrentIndentLevel = ind
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 481
diff changeset
732 return ind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 endfunction