annotate runtime/indent/javascript.vim @ 12499:d91cf2e26ef0

Update runtime files. commit https://github.com/vim/vim/commit/37c64c78fd87e086b5a945ad7032787c274e2dcb Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 19 22:06:03 2017 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Sep 2017 22:15:06 +0200
parents 63b0b7b79b25
children a6d3e2081544
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim indent file
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
2 " Language: Javascript
9975
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
3 " Maintainer: Chris Paul ( https://github.com/bounceme )
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
4 " URL: https://github.com/pangloss/vim-javascript
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
5 " Last Change: September 18, 2017
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
6
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
8 if exists('b:did_indent')
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
9 finish
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
10 endif
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
11 let b:did_indent = 1
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
12
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
13 " indent correctly if inside <script>
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
14 " vim/vim@690afe1 for the switch from cindent
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
15 let b:html_indent_script1 = 'inc'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
16
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
17 " Now, set up our indentation expression and keys that trigger it.
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
18 setlocal indentexpr=GetJavascriptIndent()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
19 setlocal autoindent nolisp nosmartindent
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
20 setlocal indentkeys+=0],0)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
21 " Testable with something like:
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
22 " vim -eNs "+filetype plugin indent on" "+syntax on" "+set ft=javascript" \
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
23 " "+norm! gg=G" '+%print' '+:q!' testfile.js \
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
24 " | diff -uBZ testfile.js -
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
25
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
26 let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<'
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
27
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
28 " Regex of syntax group names that are or delimit string or are comments.
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
29 let b:syng_strcom = get(b:,'syng_strcom','string\|comment\|regex\|special\|doc\|template\%(braces\)\@!')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
30 let b:syng_str = get(b:,'syng_str','string\|template\|special')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
31 " template strings may want to be excluded when editing graphql:
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
32 " au! Filetype javascript let b:syng_str = '^\%(.*template\)\@!.*string\|special'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
33 " au! Filetype javascript let b:syng_strcom = '^\%(.*template\)\@!.*string\|comment\|regex\|special\|doc'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
34
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
35 " Only define the function once.
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
36 if exists('*GetJavascriptIndent')
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
37 finish
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
38 endif
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
39
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
40 let s:cpo_save = &cpo
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
41 set cpo&vim
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
42
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
43 " Get shiftwidth value
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
44 if exists('*shiftwidth')
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
45 function s:sw()
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
46 return shiftwidth()
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
47 endfunction
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
48 else
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
49 function s:sw()
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
50 return &l:shiftwidth ? &l:shiftwidth : &l:tabstop
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
51 endfunction
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
52 endif
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
53
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
54 " Performance for forwards search(): start search at pos rather than masking
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
55 " matches before pos.
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
56 let s:z = has('patch-7.4.984') ? 'z' : ''
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
57
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
58 " Expression used to check whether we should skip a match with searchpair().
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
59 let s:skip_expr = "s:SynAt(line('.'),col('.')) =~? b:syng_strcom"
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
60 let s:in_comm = s:skip_expr[:-14] . "'comment\\|doc'"
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
61
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
62 let s:rel = has('reltime')
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
63 " searchpair() wrapper
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
64 if s:rel
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
65 function s:GetPair(start,end,flags,skip)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
66 return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,s:l1,a:skip ==# 's:SkipFunc()' ? 2000 : 200)
9975
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
67 endfunction
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
68 else
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
69 function s:GetPair(start,end,flags,skip)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
70 return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,s:l1)
9975
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
71 endfunction
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
72 endif
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
73
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
74 function s:SynAt(l,c)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
75 let byte = line2byte(a:l) + a:c - 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
76 let pos = index(s:synid_cache[0], byte)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
77 if pos == -1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
78 let s:synid_cache[:] += [[byte], [synIDattr(synID(a:l, a:c, 0), 'name')]]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
79 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
80 return s:synid_cache[1][pos]
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
81 endfunction
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
82
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
83 function s:ParseCino(f)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
84 let [divider, n, cstr] = [0] + matchlist(&cino,
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
85 \ '\%(.*,\)\=\%(\%d'.char2nr(a:f).'\(-\)\=\([.s0-9]*\)\)\=')[1:2]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
86 for c in split(cstr,'\zs')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
87 if c == '.' && !divider
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
88 let divider = 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
89 elseif c ==# 's'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
90 if n !~ '\d'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
91 return n . s:sw() + 0
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
92 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
93 let n = str2nr(n) * s:sw()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
94 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
95 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
96 let [n, divider] .= [c, 0]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
97 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
98 endfor
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
99 return str2nr(n) / max([str2nr(divider),1])
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
100 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
101
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
102 " Optimized {skip} expr, only callable from the search loop which
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
103 " GetJavascriptIndent does to find the containing [[{(] (side-effects)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
104 function s:SkipFunc()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
105 if s:top_col == 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
106 throw 'out of bounds'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
107 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
108 let s:top_col = 0
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
109 if s:check_in
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
110 if eval(s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
111 return 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
112 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
113 let s:check_in = 0
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
114 elseif getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
115 if eval(s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
116 let s:looksyn = a:firstline
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
117 return 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
118 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
119 elseif search('\m`\|\${\|\*\/','nW'.s:z,s:looksyn) && eval(s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
120 let s:check_in = 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
121 return 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
122 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
123 let [s:looksyn, s:top_col] = getpos('.')[1:2]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
124 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
125
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
126 function s:AlternatePair()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
127 let [pat, l:for] = ['[][(){};]', 2]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
128 while s:SearchLoop(pat,'bW','s:SkipFunc()')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
129 if s:LookingAt() == ';'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
130 if !l:for
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
131 if s:GetPair('{','}','bW','s:SkipFunc()')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
132 return
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
133 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
134 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
135 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
136 let [pat, l:for] = ['[{}();]', l:for - 1]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
137 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
138 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
139 let idx = stridx('])}',s:LookingAt())
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
140 if idx == -1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
141 return
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
142 elseif !s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()')
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
143 break
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
144 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
145 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
146 endwhile
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
147 throw 'out of bounds'
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
148 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
149
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
150 function s:Nat(int)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
151 return a:int * (a:int > 0)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
152 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
153
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
154 function s:LookingAt()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
155 return getline('.')[col('.')-1]
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
156 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
157
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
158 function s:Token()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
159 return s:LookingAt() =~ '\k' ? expand('<cword>') : s:LookingAt()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
160 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
161
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
162 function s:PreviousToken()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
163 let l:col = col('.')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
164 if search('\m\k\{1,}\|\S','ebW')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
165 if search('\m\*\%#\/\|\/\/\%<'.a:firstline.'l','nbW',line('.')) && eval(s:in_comm)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
166 if s:SearchLoop('\S\ze\_s*\/[/*]','bW',s:in_comm)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
167 return s:Token()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
168 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
169 call cursor(a:firstline, l:col)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
170 else
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
171 return s:Token()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
172 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
173 endif
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
174 return ''
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
175 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
176
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
177 function s:Pure(f,...)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
178 return eval("[call(a:f,a:000),cursor(a:firstline,".col('.').")][0]")
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
179 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
180
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
181 function s:SearchLoop(pat,flags,expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
182 return s:GetPair(a:pat,'\_$.',a:flags,a:expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
183 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
184
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
185 function s:ExprCol()
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
186 let bal = 0
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
187 while s:SearchLoop('[{}?]\|\_[^:]\zs::\@!','bW',s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
188 if s:LookingAt() == ':'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
189 let bal -= 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
190 elseif s:LookingAt() == '?'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
191 let bal += 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
192 if bal == 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
193 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
194 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
195 elseif s:LookingAt() == '{'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
196 let bal = !s:IsBlock()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
197 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
198 elseif !s:GetPair('{','}','bW',s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
199 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
200 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
201 endwhile
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
202 return s:Nat(bal)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
203 endfunction
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
204
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
205 " configurable regexes that define continuation lines, not including (, {, or [.
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
206 let s:opfirst = '^' . get(g:,'javascript_opfirst',
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
207 \ '\C\%([<>=,.?^%|/&]\|\([-:+]\)\1\@!\|\*\+\|!=\|in\%(stanceof\)\=\>\)')
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
208 let s:continuation = get(g:,'javascript_continuation',
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
209 \ '\C\%([<=,.~!?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<\%(typeof\|new\|delete\|void\|in\|instanceof\|await\)\)') . '$'
9975
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
210
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
211 function s:Continues(ln,con)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
212 let tok = matchstr(a:con[-15:],s:continuation)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
213 if tok =~ '[a-z:]'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
214 call cursor(a:ln, len(a:con))
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
215 return tok == ':' ? s:ExprCol() : s:PreviousToken() != '.'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
216 elseif tok !~ '[/>]'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
217 return tok isnot ''
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
218 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
219 return s:SynAt(a:ln, len(a:con)) !~? (tok == '>' ? 'jsflow\|^html' : 'regex')
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
220 endfunction
1118
2b8ff9e3c520 updated for version 7.1a
vimboss
parents:
diff changeset
221
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
222 " Check if line 'lnum' has a balanced amount of parentheses.
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
223 function s:Balanced(lnum)
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
224 let [l:open, l:line] = [0, getline(a:lnum)]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
225 let pos = match(l:line, '[][(){}]')
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
226 while pos != -1
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
227 if s:SynAt(a:lnum,pos + 1) !~? b:syng_strcom
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
228 let l:open += match(' ' . l:line[pos],'[[({]')
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
229 if l:open < 0
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
230 return
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
231 endif
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
232 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
233 let pos = match(l:line, !l:open ? '[][(){}]' : '()' =~ l:line[pos] ?
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
234 \ '[()]' : '{}' =~ l:line[pos] ? '[{}]' : '[][]', pos + 1)
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
235 endwhile
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
236 return !l:open
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
237 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
238
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
239 function s:OneScope()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
240 if s:LookingAt() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
241 let tok = s:PreviousToken()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
242 return (count(split('for if let while with'),tok) ||
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
243 \ tok =~# '^await$\|^each$' && s:PreviousToken() ==# 'for') &&
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
244 \ s:Pure('s:PreviousToken') != '.' && !(tok == 'while' && s:DoWhile())
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
245 elseif s:Token() =~# '^else$\|^do$'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
246 return s:Pure('s:PreviousToken') != '.'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
247 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
248 return strpart(getline('.'),col('.')-2,2) == '=>'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
249 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
250
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
251 function s:DoWhile()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
252 let cpos = searchpos('\m\<','cbW')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
253 if s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
254 if s:{s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) ?
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
255 \ 'Previous' : ''}Token() ==# 'do' && s:IsBlock()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
256 return 1
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
257 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
258 call call('cursor',cpos)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
259 endif
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
260 endfunction
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
261
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
262 " returns total offset from braceless contexts. 'num' is the lineNr which
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
263 " encloses the entire context, 'cont' if whether a:firstline is a continued
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
264 " expression, which could have started in a braceless context
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
265 function s:IsContOne(num,cont)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
266 let [l:num, b_l] = [a:num + !a:num, 0]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
267 let pind = a:num ? indent(a:num) + s:sw() : 0
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
268 let ind = indent('.') + !a:cont
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
269 while line('.') > l:num && ind > pind || line('.') == l:num
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
270 if indent('.') < ind && s:OneScope()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
271 let b_l += 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
272 elseif !a:cont || b_l || ind < indent(a:firstline)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
273 break
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
274 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
275 call cursor(0,1)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
276 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
277 let ind = min([ind, indent('.')])
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
278 if s:PreviousToken() is ''
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
279 break
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
280 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
281 endwhile
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
282 return b_l
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
283 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
284
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
285 function s:Class()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
286 return (s:Token() ==# 'class' || s:PreviousToken() =~# '^class$\|^extends$') &&
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
287 \ s:PreviousToken() != '.'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
288 endfunction
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
289
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
290 function s:IsSwitch()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
291 return s:PreviousToken() !~ '[.*]' &&
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
292 \ (!s:GetPair('{','}','cbW',s:skip_expr) || s:IsBlock() && !s:Class())
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
293 endfunction
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
294
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
295 " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
296 function s:IsBlock()
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
297 let tok = s:PreviousToken()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
298 if join(s:stack) =~? 'xml\|jsx' && s:SynAt(line('.'),col('.')-1) =~? 'xml\|jsx'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
299 return tok != '{'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
300 elseif tok =~ '\k'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
301 if tok ==# 'type'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
302 return s:Pure('eval',"s:PreviousToken() !~# '^\\%(im\\|ex\\)port$' || s:PreviousToken() == '.'")
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
303 elseif tok ==# 'of'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
304 return s:Pure('eval',"!s:GetPair('[[({]','[])}]','bW',s:skip_expr) || s:LookingAt() != '(' ||"
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
305 \ ."s:{s:PreviousToken() ==# 'await' ? 'Previous' : ''}Token() !=# 'for' || s:PreviousToken() == '.'")
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
306 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
307 return index(split('return const let import export extends yield default delete var await void typeof throw case new in instanceof')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
308 \ ,tok) < (line('.') != a:firstline) || s:Pure('s:PreviousToken') == '.'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
309 elseif tok == '>'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
310 return getline('.')[col('.')-2] == '=' || s:SynAt(line('.'),col('.')) =~? 'jsflow\|^html'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
311 elseif tok == '*'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
312 return s:Pure('s:PreviousToken') == ':'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
313 elseif tok == ':'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
314 return s:Pure('eval',"s:PreviousToken() =~ '^\\K\\k*$' && !s:ExprCol()")
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
315 elseif tok == '/'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
316 return s:SynAt(line('.'),col('.')) =~? 'regex'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
317 elseif tok !~ '[=~!<,.?^%|&([]'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
318 return tok !~ '[-+]' || line('.') != a:firstline && getline('.')[col('.')-2] == tok
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
319 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
320 endfunction
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
321
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
322 function GetJavascriptIndent()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
323 let b:js_cache = get(b:,'js_cache',[0,0,0])
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
324 let s:synid_cache = [[],[]]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
325 let l:line = getline(v:lnum)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
326 " use synstack as it validates syn state and works in an empty line
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
327 let s:stack = [''] + map(synstack(v:lnum,1),"synIDattr(v:val,'name')")
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
328
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
329 " start with strings,comments,etc.
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
330 if s:stack[-1] =~? 'comment\|doc'
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
331 if l:line =~ '^\s*\*'
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
332 return cindent(v:lnum)
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
333 elseif l:line !~ '^\s*\/[/*]'
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
334 return -1
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
335 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
336 elseif s:stack[-1] =~? b:syng_str
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
337 if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1)
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
338 let b:js_cache[0] = v:lnum
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
339 endif
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
340 return -1
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
341 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
342
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
343 let s:l1 = max([0,prevnonblank(v:lnum) - (s:rel ? 2000 : 1000),
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
344 \ get(get(b:,'hi_indent',{}),'blocklnr')])
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
345 call cursor(v:lnum,1)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
346 if s:PreviousToken() is ''
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
347 return
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
348 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
349 let [l:lnum, pline] = [line('.'), getline('.')[:col('.')-1]]
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
350
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
351 let l:line = substitute(l:line,'^\s*','','')
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
352 let l:line_raw = l:line
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
353 if l:line[:1] == '/*'
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
354 let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','')
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
355 endif
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
356 if l:line =~ '^\/[/*]'
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
357 let l:line = ''
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
358 endif
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
359
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
360 " the containing paren, bracket, or curly. Many hacks for performance
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
361 call cursor(v:lnum,1)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
362 let idx = index([']',')','}'],l:line[0])
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
363 if b:js_cache[0] > l:lnum && b:js_cache[0] < v:lnum ||
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
364 \ b:js_cache[0] == l:lnum && s:Balanced(l:lnum)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
365 call call('cursor',b:js_cache[1:])
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
366 else
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
367 let [s:looksyn, s:top_col, s:check_in, s:l1] = [v:lnum - 1,0,0,
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
368 \ max([s:l1, &smc ? search('\m^.\{'.&smc.',}','nbW',s:l1 + 1) + 1 : 0])]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
369 try
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
370 if idx != -1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
371 call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:SkipFunc()')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
372 elseif getline(v:lnum) !~ '^\S' && s:stack[-1] =~? 'block\|^jsobject$'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
373 call s:GetPair('{','}','bW','s:SkipFunc()')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
374 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
375 call s:AlternatePair()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
376 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
377 catch /^\Cout of bounds$/
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
378 call cursor(v:lnum,1)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
379 endtry
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
380 let b:js_cache[1:] = line('.') == v:lnum ? [0,0] : getpos('.')[1:2]
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
381 endif
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
382
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
383 let [b:js_cache[0], num] = [v:lnum, b:js_cache[1]]
9975
03fa8a51e9dc commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Christian Brabandt <cb@256bit.org>
parents: 9860
diff changeset
384
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
385 let [num_ind, is_op, b_l, l:switch_offset] = [s:Nat(indent(num)),0,0,0]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
386 if !num || s:LookingAt() == '{' && s:IsBlock()
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents: 10548
diff changeset
387 let ilnum = line('.')
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
388 if num && s:LookingAt() == ')' && s:GetPair('(',')','bW',s:skip_expr)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
389 if ilnum == num
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
390 let [num, num_ind] = [line('.'), indent('.')]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
391 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
392 if idx == -1 && s:PreviousToken() ==# 'switch' && s:IsSwitch()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
393 let l:switch_offset = &cino !~ ':' ? s:sw() : s:ParseCino(':')
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
394 if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>'
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
395 return s:Nat(num_ind + l:switch_offset)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
396 elseif &cino =~ '='
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
397 let l:case_offset = s:ParseCino('=')
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
398 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
399 endif
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
400 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
401 if idx == -1 && pline[-1:] !~ '[{;]'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
402 let sol = matchstr(l:line,s:opfirst)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
403 if sol is '' || sol == '/' && s:SynAt(v:lnum,
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
404 \ 1 + len(getline(v:lnum)) - len(l:line)) =~? 'regex'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
405 if s:Continues(l:lnum,pline)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
406 let is_op = s:sw()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
407 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
408 elseif num && sol =~# '^\%(in\%(stanceof\)\=\|\*\)$'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
409 call call('cursor',b:js_cache[1:])
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
410 if s:PreviousToken() =~ '\k' && s:Class()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
411 return num_ind + s:sw()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
412 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
413 let is_op = s:sw()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
414 else
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
415 let is_op = s:sw()
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
416 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
417 call cursor(l:lnum, len(pline))
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
418 let b_l = s:Nat(s:IsContOne(b:js_cache[1],is_op) - (!is_op && l:line =~ '^{')) * s:sw()
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
419 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
420 elseif idx.s:LookingAt().&cino =~ '^-1(.*(' && (search('\m\S','nbW',num) || s:ParseCino('U'))
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
421 let pval = s:ParseCino('(')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
422 if !pval
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
423 let [Wval, vcol] = [s:ParseCino('W'), virtcol('.')]
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
424 if search('\m\S','W',num)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
425 return s:ParseCino('w') ? vcol : virtcol('.')-1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
426 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
427 return Wval ? s:Nat(num_ind + Wval) : vcol
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
428 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
429 return s:Nat(num_ind + pval + searchpair('\m(','','\m)','nbrmW',s:skip_expr,num) * s:sw())
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
430 endif
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
431
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
432 " main return
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
433 if l:line =~ '^[])}]\|^|}'
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
434 if l:line_raw[0] == ')' && getline(num)[b:js_cache[2]-1] == '('
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
435 if s:ParseCino('M')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
436 return indent(l:lnum)
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
437 elseif &cino =~# 'm' && !s:ParseCino('m')
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
438 return virtcol('.') - 1
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
439 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
440 endif
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
441 return num_ind
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
442 elseif num
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
443 return s:Nat(num_ind + get(l:,'case_offset',s:sw()) + l:switch_offset + b_l + is_op)
10548
74effdaa369e Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 9975
diff changeset
444 endif
12499
d91cf2e26ef0 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
445 return b_l + is_op
9860
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
446 endfunction
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
447
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
448 let &cpo = s:cpo_save
9eaf8ef656e9 commit https://github.com/vim/vim/commit/0952131376a517fc12dc5ae908a97018b4ee23f0
Christian Brabandt <cb@256bit.org>
parents: 6823
diff changeset
449 unlet s:cpo_save