blob: 3b3f3a104d524276390a10426f3548418b925d8f [file] [log] [blame]
Bram Moolenaardd2a3cd2007-05-05 17:10:09 +00001" Vim indent file
Bram Moolenaar09521312016-08-12 22:54:35 +02002" Language: Javascript
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +02003" Maintainer: Chris Paul ( https://github.com/bounceme )
Bram Moolenaar09521312016-08-12 22:54:35 +02004" URL: https://github.com/pangloss/vim-javascript
Bram Moolenaar3c2881d2017-03-21 19:18:29 +01005" Last Change: March 21, 2017
Bram Moolenaardd2a3cd2007-05-05 17:10:09 +00006
7" Only load this indent file when no other was loaded.
Bram Moolenaar09521312016-08-12 22:54:35 +02008if exists('b:did_indent')
9 finish
Bram Moolenaardd2a3cd2007-05-05 17:10:09 +000010endif
11let b:did_indent = 1
12
Bram Moolenaar09521312016-08-12 22:54:35 +020013" Now, set up our indentation expression and keys that trigger it.
14setlocal indentexpr=GetJavascriptIndent()
Bram Moolenaar68563932017-01-10 13:31:15 +010015setlocal autoindent nolisp nosmartindent
16setlocal indentkeys+=0],0)
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010017" Testable with something like:
18" vim -eNs "+filetype plugin indent on" "+syntax on" "+set ft=javascript" \
19" "+norm! gg=G" '+%print' '+:q!' testfile.js \
20" | diff -uBZ testfile.js -
Bram Moolenaardd2a3cd2007-05-05 17:10:09 +000021
Bram Moolenaar68563932017-01-10 13:31:15 +010022let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<'
Bram Moolenaar09521312016-08-12 22:54:35 +020023
24" Only define the function once.
25if exists('*GetJavascriptIndent')
26 finish
27endif
28
29let s:cpo_save = &cpo
30set cpo&vim
31
32" Get shiftwidth value
33if exists('*shiftwidth')
34 function s:sw()
35 return shiftwidth()
36 endfunction
37else
38 function s:sw()
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010039 return &l:shiftwidth == 0 ? &l:tabstop : &l:shiftwidth
Bram Moolenaar09521312016-08-12 22:54:35 +020040 endfunction
41endif
42
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010043" Performance for forwards search(): start search at pos rather than masking
44" matches before pos.
45let s:z = has('patch-7.4.984') ? 'z' : ''
46
Bram Moolenaar68563932017-01-10 13:31:15 +010047" searchpair() wrapper
48if has('reltime')
49 function s:GetPair(start,end,flags,skip,time,...)
50 return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time)
51 endfunction
52else
53 function s:GetPair(start,end,flags,skip,...)
54 return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)]))
55 endfunction
56endif
57
Bram Moolenaar09521312016-08-12 22:54:35 +020058" Regex of syntax group names that are or delimit string or are comments.
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010059let s:syng_strcom = 'string\|comment\|regex\|special\|doc\|template\%(braces\)\@!'
60let s:syng_str = 'string\|template\|special'
Bram Moolenaar68563932017-01-10 13:31:15 +010061let s:syng_com = 'comment\|doc'
Bram Moolenaar09521312016-08-12 22:54:35 +020062" Expression used to check whether we should skip a match with searchpair().
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +020063let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'"
Bram Moolenaar09521312016-08-12 22:54:35 +020064
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010065function s:parse_cino(f) abort
66 return float2nr(eval(substitute(substitute(join(split(
67 \ matchstr(&cino,'.*'.a:f.'\zs[^,]*'), 's',1), '*'.s:W)
68 \ , '^-\=\zs\*','',''), '^-\=\zs\.','0.','')))
69endfunction
70
Bram Moolenaar68563932017-01-10 13:31:15 +010071function s:skip_func()
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010072 if getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$'
73 return eval(s:skip_expr)
74 elseif s:checkIn || search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn)
75 let s:checkIn = eval(s:skip_expr)
Bram Moolenaar68563932017-01-10 13:31:15 +010076 endif
77 let s:looksyn = line('.')
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010078 return s:checkIn
Bram Moolenaar68563932017-01-10 13:31:15 +010079endfunction
Bram Moolenaar09521312016-08-12 22:54:35 +020080
Bram Moolenaar68563932017-01-10 13:31:15 +010081function s:alternatePair(stop)
82 let pos = getpos('.')[1:2]
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010083 let pat = '[][(){};]'
84 while search('\m'.pat,'bW',a:stop)
85 if s:skip_func() | continue | endif
86 let idx = stridx('])};',s:looking_at())
87 if idx is 3 | let pat = '[{}()]' | continue | endif
88 if idx + 1
89 if s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func()',2000,a:stop) <= 0
90 break
Bram Moolenaar68563932017-01-10 13:31:15 +010091 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +010092 else
93 return
Bram Moolenaar68563932017-01-10 13:31:15 +010094 endif
95 endwhile
96 call call('cursor',pos)
97endfunction
98
99function s:save_pos(f,...)
100 let l:pos = getpos('.')[1:2]
101 let ret = call(a:f,a:000)
102 call call('cursor',l:pos)
103 return ret
104endfunction
105
106function s:syn_at(l,c)
107 return synIDattr(synID(a:l,a:c,0),'name')
108endfunction
109
110function s:looking_at()
111 return getline('.')[col('.')-1]
112endfunction
113
114function s:token()
115 return s:looking_at() =~ '\k' ? expand('<cword>') : s:looking_at()
116endfunction
117
Bram Moolenaar68563932017-01-10 13:31:15 +0100118function s:previous_token()
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100119 let l:pos = getpos('.')[1:2]
120 if search('\m\k\{1,}\zs\k\|\S','bW')
121 if (getline('.')[col('.')-2:col('.')-1] == '*/' || line('.') != l:pos[0] &&
122 \ getline('.') =~ '\%<'.col('.').'c\/\/') && s:syn_at(line('.'),col('.')) =~? s:syng_com
123 while search('\m\S\ze\_s*\/[/*]','bW')
124 if s:syn_at(line('.'),col('.')) !~? s:syng_com
125 return s:token()
126 endif
127 endwhile
Bram Moolenaar68563932017-01-10 13:31:15 +0100128 else
129 return s:token()
130 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100131 endif
132 call call('cursor',l:pos)
Bram Moolenaar68563932017-01-10 13:31:15 +0100133 return ''
134endfunction
135
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100136function s:expr_col()
137 if getline('.')[col('.')-2] == ':'
138 return 1
Bram Moolenaar68563932017-01-10 13:31:15 +0100139 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100140 let bal = 0
141 while search('\m[{}?:;]','bW')
142 if eval(s:skip_expr) | continue | endif
143 " switch (looking_at())
144 exe { '}': "if s:GetPair('{','}','bW',s:skip_expr,200) <= 0 | return | endif",
145 \ ';': "return",
146 \ '{': "return getpos('.')[1:2] != b:js_cache[1:] && !s:IsBlock()",
147 \ ':': "let bal -= getline('.')[max([col('.')-2,0]):col('.')] !~ '::'",
148 \ '?': "let bal += 1 | if bal > 0 | return 1 | endif" }[s:looking_at()]
149 endwhile
Bram Moolenaar68563932017-01-10 13:31:15 +0100150endfunction
Bram Moolenaar09521312016-08-12 22:54:35 +0200151
152" configurable regexes that define continuation lines, not including (, {, or [.
Bram Moolenaar68563932017-01-10 13:31:15 +0100153let s:opfirst = '^' . get(g:,'javascript_opfirst',
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100154 \ '\C\%([<>=,?^%|*/&]\|\([-.:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)')
Bram Moolenaar68563932017-01-10 13:31:15 +0100155let s:continuation = get(g:,'javascript_continuation',
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100156 \ '\C\%([-+<>=,.~!?/*^%|&:]\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200157
Bram Moolenaar68563932017-01-10 13:31:15 +0100158function s:continues(ln,con)
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100159 if !cursor(a:ln, match(' '.a:con,s:continuation))
160 let teol = s:looking_at()
161 if teol == '/'
162 return s:syn_at(line('.'),col('.')) !~? 'regex'
163 elseif teol =~ '[-+>]'
164 return getline('.')[col('.')-2] != tr(teol,'>','=')
165 elseif teol =~ '\l'
166 return s:previous_token() != '.'
167 elseif teol == ':'
168 return s:expr_col()
169 endif
170 return 1
171 endif
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200172endfunction
173
Bram Moolenaar68563932017-01-10 13:31:15 +0100174" get the line of code stripped of comments and move cursor to the last
175" non-comment char.
176function s:Trim(ln)
177 let pline = substitute(getline(a:ln),'\s*$','','')
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100178 let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
179 while l:max != -1 && s:syn_at(a:ln, strlen(pline)) =~? s:syng_com
180 let pline = pline[: l:max]
181 let l:max = max([strridx(pline,'//'), strridx(pline,'/*')])
182 let pline = substitute(pline[:-2],'\s*$','','')
Bram Moolenaar68563932017-01-10 13:31:15 +0100183 endwhile
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100184 return pline is '' || cursor(a:ln,strlen(pline)) ? pline : pline
Bram Moolenaar09521312016-08-12 22:54:35 +0200185endfunction
186
Bram Moolenaar68563932017-01-10 13:31:15 +0100187" Find line above 'lnum' that isn't empty or in a comment
Bram Moolenaar09521312016-08-12 22:54:35 +0200188function s:PrevCodeLine(lnum)
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100189 let [l:pos, l:n] = [getpos('.')[1:2], prevnonblank(a:lnum)]
Bram Moolenaar68563932017-01-10 13:31:15 +0100190 while l:n
191 if getline(l:n) =~ '^\s*\/[/*]'
Bram Moolenaar68563932017-01-10 13:31:15 +0100192 let l:n = prevnonblank(l:n-1)
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100193 elseif stridx(getline(l:n), '*/') + 1 && s:syn_at(l:n,1) =~? s:syng_com
194 call cursor(l:n,1)
195 keepjumps norm! [*
196 let l:n = search('\m\S','nbW')
Bram Moolenaar68563932017-01-10 13:31:15 +0100197 else
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100198 break
Bram Moolenaar09521312016-08-12 22:54:35 +0200199 endif
Bram Moolenaar09521312016-08-12 22:54:35 +0200200 endwhile
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100201 call call('cursor',l:pos)
202 return l:n
Bram Moolenaar09521312016-08-12 22:54:35 +0200203endfunction
204
205" Check if line 'lnum' has a balanced amount of parentheses.
206function s:Balanced(lnum)
Bram Moolenaar68563932017-01-10 13:31:15 +0100207 let l:open = 0
Bram Moolenaar09521312016-08-12 22:54:35 +0200208 let l:line = getline(a:lnum)
209 let pos = match(l:line, '[][(){}]', 0)
210 while pos != -1
Bram Moolenaar68563932017-01-10 13:31:15 +0100211 if s:syn_at(a:lnum,pos + 1) !~? s:syng_strcom
212 let l:open += match(' ' . l:line[pos],'[[({]')
213 if l:open < 0
214 return
Bram Moolenaar09521312016-08-12 22:54:35 +0200215 endif
216 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100217 let pos = match(l:line, (l:open ?
218 \ '['.escape(tr(l:line[pos],'({[]})',')}][{(').l:line[pos],']').']' :
219 \ '[][(){}]'), pos + 1)
Bram Moolenaar09521312016-08-12 22:54:35 +0200220 endwhile
Bram Moolenaar68563932017-01-10 13:31:15 +0100221 return !l:open
Bram Moolenaar09521312016-08-12 22:54:35 +0200222endfunction
Bram Moolenaar68563932017-01-10 13:31:15 +0100223
224function s:OneScope(lnum)
225 let pline = s:Trim(a:lnum)
226 let kw = 'else do'
227 if pline[-1:] == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100228 if s:previous_token() =~# '^\%(await\|each\)$'
Bram Moolenaar68563932017-01-10 13:31:15 +0100229 call s:previous_token()
230 let kw = 'for'
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100231 else
232 let kw = 'for if let while with'
Bram Moolenaar68563932017-01-10 13:31:15 +0100233 endif
234 endif
235 return pline[-2:] == '=>' || index(split(kw),s:token()) + 1 &&
236 \ s:save_pos('s:previous_token') != '.'
237endfunction
238
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200239" returns braceless levels started by 'i' and above lines * shiftwidth().
240" 'num' is the lineNr which encloses the entire context, 'cont' if whether
241" line 'i' + 1 is a continued expression, which could have started in a
242" braceless context
Bram Moolenaar68563932017-01-10 13:31:15 +0100243function s:iscontOne(i,num,cont)
244 let [l:i, l:num, bL] = [a:i, a:num + !a:num, 0]
245 let pind = a:num ? indent(l:num) + s:W : 0
246 let ind = indent(l:i) + (a:cont ? 0 : s:W)
247 while l:i >= l:num && (ind > pind || l:i == l:num)
248 if indent(l:i) < ind && s:OneScope(l:i)
249 let bL += s:W
250 let l:i = line('.')
251 elseif !a:cont || bL || ind < indent(a:i)
252 break
253 endif
254 let ind = min([ind, indent(l:i)])
255 let l:i = s:PrevCodeLine(l:i - 1)
256 endwhile
257 return bL
258endfunction
259
260" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
261function s:IsBlock()
262 if s:looking_at() == '{'
263 let l:n = line('.')
264 let char = s:previous_token()
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100265 if match(s:stack,'\cxml\|jsx') + 1 && s:syn_at(line('.'),col('.')-1) =~? 'xml\|jsx'
Bram Moolenaar68563932017-01-10 13:31:15 +0100266 return char != '{'
267 elseif char =~ '\k'
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100268 if char ==# 'type'
269 return s:previous_token() !~# '^\%(im\|ex\)port$'
270 endif
271 return index(split('return const let import export extends yield default delete var await void typeof throw case new of in instanceof')
272 \ ,char) < (line('.') != l:n) || s:save_pos('s:previous_token') == '.'
Bram Moolenaar68563932017-01-10 13:31:15 +0100273 elseif char == '>'
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100274 return getline('.')[col('.')-2] == '=' || s:syn_at(line('.'),col('.')) =~? '^jsflow'
Bram Moolenaar68563932017-01-10 13:31:15 +0100275 elseif char == ':'
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100276 return !s:save_pos('s:expr_col')
277 elseif char == '/'
278 return s:syn_at(line('.'),col('.')) =~? 'regex'
Bram Moolenaar68563932017-01-10 13:31:15 +0100279 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100280 return char !~ '[=~!<*,?^%|&([]' &&
281 \ (char !~ '[-+]' || l:n != line('.') && getline('.')[col('.')-2] == char)
Bram Moolenaar68563932017-01-10 13:31:15 +0100282 endif
283endfunction
Bram Moolenaar09521312016-08-12 22:54:35 +0200284
285function GetJavascriptIndent()
Bram Moolenaar68563932017-01-10 13:31:15 +0100286 let b:js_cache = get(b:,'js_cache',[0,0,0])
Bram Moolenaar09521312016-08-12 22:54:35 +0200287 " Get the current line.
Bram Moolenaar68563932017-01-10 13:31:15 +0100288 call cursor(v:lnum,1)
289 let l:line = getline('.')
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100290 " use synstack as it validates syn state and works in an empty line
291 let s:stack = map(synstack(v:lnum,1),"synIDattr(v:val,'name')")
292 let syns = get(s:stack,-1,'')
Bram Moolenaar09521312016-08-12 22:54:35 +0200293
Bram Moolenaar68563932017-01-10 13:31:15 +0100294 " start with strings,comments,etc.
295 if syns =~? s:syng_com
296 if l:line =~ '^\s*\*'
297 return cindent(v:lnum)
298 elseif l:line !~ '^\s*\/[/*]'
299 return -1
300 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100301 elseif syns =~? s:syng_str
Bram Moolenaar68563932017-01-10 13:31:15 +0100302 if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1)
303 let b:js_cache[0] = v:lnum
304 endif
Bram Moolenaar09521312016-08-12 22:54:35 +0200305 return -1
306 endif
Bram Moolenaar09521312016-08-12 22:54:35 +0200307 let l:lnum = s:PrevCodeLine(v:lnum - 1)
Bram Moolenaar68563932017-01-10 13:31:15 +0100308 if !l:lnum
309 return
Bram Moolenaar09521312016-08-12 22:54:35 +0200310 endif
311
Bram Moolenaar68563932017-01-10 13:31:15 +0100312 let l:line = substitute(l:line,'^\s*','','')
313 if l:line[:1] == '/*'
314 let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
Bram Moolenaar09521312016-08-12 22:54:35 +0200315 endif
Bram Moolenaar68563932017-01-10 13:31:15 +0100316 if l:line =~ '^\/[/*]'
317 let l:line = ''
318 endif
Bram Moolenaar09521312016-08-12 22:54:35 +0200319
Bram Moolenaar68563932017-01-10 13:31:15 +0100320 " the containing paren, bracket, or curly. Many hacks for performance
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100321 let idx = index([']',')','}'],l:line[0])
Bram Moolenaar68563932017-01-10 13:31:15 +0100322 if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
323 \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum))
324 call call('cursor',b:js_cache[1:])
Bram Moolenaar09521312016-08-12 22:54:35 +0200325 else
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100326 let [s:looksyn, s:checkIn, top] = [v:lnum - 1, 0, (!indent(l:lnum) &&
Bram Moolenaar68563932017-01-10 13:31:15 +0100327 \ s:syn_at(l:lnum,1) !~? s:syng_str) * l:lnum]
328 if idx + 1
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100329 call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:skip_func()',2000,top)
330 elseif getline(v:lnum) !~ '^\S' && syns =~? 'block'
Bram Moolenaar68563932017-01-10 13:31:15 +0100331 call s:GetPair('{','}','bW','s:skip_func()',2000,top)
332 else
333 call s:alternatePair(top)
334 endif
Bram Moolenaar09521312016-08-12 22:54:35 +0200335 endif
336
Bram Moolenaar68563932017-01-10 13:31:15 +0100337 let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [0,0] : getpos('.')[1:2])
338 let num = b:js_cache[1]
339
340 let [s:W, isOp, bL, switch_offset] = [s:sw(),0,0,0]
341 if !num || s:IsBlock()
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100342 let ilnum = line('.')
Bram Moolenaar68563932017-01-10 13:31:15 +0100343 let pline = s:save_pos('s:Trim',l:lnum)
344 if num && s:looking_at() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100345 let num = ilnum == num ? line('.') : num
346 if idx < 0 && s:previous_token() ==# 'switch' && s:previous_token() != '.'
347 if &cino !~ ':'
Bram Moolenaar68563932017-01-10 13:31:15 +0100348 let switch_offset = s:W
349 else
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100350 let switch_offset = max([-indent(num),s:parse_cino(':')])
Bram Moolenaar68563932017-01-10 13:31:15 +0100351 endif
352 if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>'
353 return indent(num) + switch_offset
354 endif
355 endif
356 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100357 if idx < 0 && pline[-1:] !~ '[{;]'
358 let isOp = (l:line =~# s:opfirst || s:continues(l:lnum,pline)) * s:W
359 let bL = s:iscontOne(l:lnum,b:js_cache[1],isOp)
Bram Moolenaar68563932017-01-10 13:31:15 +0100360 let bL -= (bL && l:line[0] == '{') * s:W
361 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100362 elseif idx < 0 && getline(b:js_cache[1])[b:js_cache[2]-1] == '(' && &cino =~ '('
363 let pval = s:parse_cino('(')
364 return !pval ? (s:parse_cino('w') ? 0 : -(!!search('\m\S','W'.s:z,num))) + virtcol('.') :
365 \ max([indent('.') + pval + (s:GetPair('(',')','nbrmW',s:skip_expr,100,num) * s:W),0])
Bram Moolenaar68563932017-01-10 13:31:15 +0100366 endif
367
368 " main return
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100369 if l:line =~ '^\%([])}]\||}\)'
370 return max([indent(num),0])
Bram Moolenaar68563932017-01-10 13:31:15 +0100371 elseif num
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100372 return indent(num) + s:W + switch_offset + bL + isOp
Bram Moolenaar68563932017-01-10 13:31:15 +0100373 endif
Bram Moolenaar3c2881d2017-03-21 19:18:29 +0100374 return bL + isOp
Bram Moolenaar09521312016-08-12 22:54:35 +0200375endfunction
376
Bram Moolenaar09521312016-08-12 22:54:35 +0200377let &cpo = s:cpo_save
378unlet s:cpo_save