annotate runtime/indent/julia.vim @ 34786:e27831e54542 v9.1.0267

patch 9.1.0267: File name entered in GUI dialog is ignored Commit: https://github.com/vim/vim/commit/c20bdf1107d48a1c14713709d12d429e761132af Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Apr 5 20:02:55 2024 +0200 patch 9.1.0267: File name entered in GUI dialog is ignored Problem: File name entered in GUI dialog is ignored (after v9.1.0265) Solution: Only set file name to "Untitled" if GUI dialog didn't set it. (zeertzjq) closes: #14417 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Apr 2024 20:15:03 +0200
parents d6dde6229b36
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim indent file
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: Julia
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " Maintainer: Carlo Baldassi <carlobaldassi@gmail.com>
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " Homepage: https://github.com/JuliaEditorSupport/julia-vim
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
5 " Last Change: 2022 Jun 14
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 29193
diff changeset
6 " 2023 Aug 28 by Vim Project (undo_indent)
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 29193
diff changeset
7 " Notes: originally based on Bram Moolenaar's indent file for vim
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
29193
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
9 " Only load this indent file when no other was loaded.
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
10 if exists("b:did_indent")
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
11 finish
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
12 endif
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
13 let b:did_indent = 1
1e9e9d89f0ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25619
diff changeset
14
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 setlocal autoindent
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 setlocal indentexpr=GetJuliaIndent()
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 setlocal indentkeys+==end,=else,=catch,=finally,),],}
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 setlocal indentkeys-=0#
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 setlocal indentkeys-=:
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 setlocal indentkeys-=0{
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 setlocal indentkeys-=0}
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 setlocal nosmartindent
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 29193
diff changeset
25 let b:undo_indent = "setl ai< inde< indk< si<"
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 29193
diff changeset
26
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 " Only define the function once.
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 if exists("*GetJuliaIndent")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 finish
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 let s:skipPatternsBasic = '\<julia\%(Comment\%([LM]\|Delim\)\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 let s:skipPatterns = '\<julia\%(Comprehension\%(For\|If\)\|RangeKeyword\|Comment\%([LM]\|Delim\)\|\%([bs]\|Shell\|Printf\|Doc\)\?String\|StringPrefixed\|DocStringM\(Raw\)\?\|RegEx\|SymbolS\?\|Macro\|Dotted\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 function JuliaMatch(lnum, str, regex, st, ...)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 let s = a:st
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 let e = a:0 > 0 ? a:1 : -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 let basic_skip = a:0 > 1 ? a:2 : 'all'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 let skip = basic_skip ==# 'basic' ? s:skipPatternsBasic : s:skipPatterns
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 while 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 let f = match(a:str, '\C' . a:regex, s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 if e >= 0 && f >= e
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 return -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 if f >= 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 let attr = synIDattr(synID(a:lnum,f+1,1),"name")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 let attrT = synIDattr(synID(a:lnum,f+1,0),"name")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 if attr =~# skip || attrT =~# skip
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 let s = f+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 return f
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 function GetJuliaNestingStruct(lnum, ...)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 " Auxiliary function to inspect the block structure of a line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 let line = getline(a:lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 let s = a:0 > 0 ? a:1 : 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 let e = a:0 > 1 ? a:2 : -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 let blocks_stack = []
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 let num_closed_blocks = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 while 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 let fb = JuliaMatch(a:lnum, line, '\<\%(if\|else\%(if\)\?\|while\|for\|try\|catch\|finally\|\%(staged\)\?function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|\%(bare\)\?module\|quote\|do\)\>', s, e)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let fe = JuliaMatch(a:lnum, line, '\<end\>', s, e)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 if fb < 0 && fe < 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 " No blocks found
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 end
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 if fb >= 0 && (fb < fe || fe < 0)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 " The first occurrence is an opening block keyword
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 " Note: some keywords (elseif,else,catch,finally) are both
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 " closing blocks and opening new ones
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 let i = JuliaMatch(a:lnum, line, '\<if\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 call add(blocks_stack, 'if')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 let i = JuliaMatch(a:lnum, line, '\<elseif\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 if len(blocks_stack) > 0 && blocks_stack[-1] == 'if'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 let blocks_stack[-1] = 'elseif'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 elseif (len(blocks_stack) > 0 && blocks_stack[-1] != 'elseif') || len(blocks_stack) == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 call add(blocks_stack, 'elseif')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 let num_closed_blocks += 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 let i = JuliaMatch(a:lnum, line, '\<else\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 if len(blocks_stack) > 0 && blocks_stack[-1] =~# '\<\%(else\)\=if\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 let blocks_stack[-1] = 'else'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 call add(blocks_stack, 'else')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 let num_closed_blocks += 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 let i = JuliaMatch(a:lnum, line, '\<try\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 call add(blocks_stack, 'try')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 let i = JuliaMatch(a:lnum, line, '\<catch\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 if len(blocks_stack) > 0 && blocks_stack[-1] == 'try'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 let blocks_stack[-1] = 'catch'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 call add(blocks_stack, 'catch')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 let num_closed_blocks += 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 let i = JuliaMatch(a:lnum, line, '\<finally\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 if len(blocks_stack) > 0 && (blocks_stack[-1] == 'try' || blocks_stack[-1] == 'catch')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 let blocks_stack[-1] = 'finally'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 call add(blocks_stack, 'finally')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 let num_closed_blocks += 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 let i = JuliaMatch(a:lnum, line, '\<\%(bare\)\?module\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 if i == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 call add(blocks_stack, 'col1module')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 call add(blocks_stack, 'other')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 let i = JuliaMatch(a:lnum, line, '\<\%(while\|for\|function\|macro\|begin\|\%(mutable\s\+\)\?struct\|\%(abstract\|primitive\)\s\+type\|let\|quote\|do\)\>', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 if match(line, '\C\<\%(mutable\|abstract\|primitive\)', i) != -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 let s = i+11
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 call add(blocks_stack, 'other')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 " Note: it should be impossible to get here
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 " The first occurrence is an 'end'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 let s = fe+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 if len(blocks_stack) == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 let num_closed_blocks += 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 call remove(blocks_stack, -1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 " Note: it should be impossible to get here
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 let num_open_blocks = len(blocks_stack) - count(blocks_stack, 'col1module')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 return [num_open_blocks, num_closed_blocks]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 function GetJuliaNestingBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 " Auxiliary function to inspect the brackets structure of a line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 let line = getline(a:lnum)[0 : (a:c - 1)]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 let s = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 let brackets_stack = []
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 let last_closed_bracket = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 while 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 let fb = JuliaMatch(a:lnum, line, '[([{]', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 let fe = JuliaMatch(a:lnum, line, '[])}]', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 if fb < 0 && fe < 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 " No brackets found
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 end
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 if fb >= 0 && (fb < fe || fe < 0)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 " The first occurrence is an opening bracket
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 let i = JuliaMatch(a:lnum, line, '(', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 call add(brackets_stack, ['par',i])
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 let i = JuliaMatch(a:lnum, line, '\[', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 call add(brackets_stack, ['sqbra',i])
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 let i = JuliaMatch(a:lnum, line, '{', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 if i >= 0 && i == fb
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 call add(brackets_stack, ['curbra',i])
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 " Note: it should be impossible to get here
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 " The first occurrence is a closing bracket
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 let i = JuliaMatch(a:lnum, line, ')', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 if i >= 0 && i == fe
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'par'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 call remove(brackets_stack, -1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 let last_closed_bracket = i + 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 let i = JuliaMatch(a:lnum, line, ']', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 if i >= 0 && i == fe
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'sqbra'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 call remove(brackets_stack, -1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 let last_closed_bracket = i + 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 let i = JuliaMatch(a:lnum, line, '}', s)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 if i >= 0 && i == fe
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 let s = i+1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 if len(brackets_stack) > 0 && brackets_stack[-1][0] == 'curbra'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 call remove(brackets_stack, -1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 let last_closed_bracket = i + 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 " Note: it should be impossible to get here
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 " Note: it should be impossible to get here
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 let first_open_bracket = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 let last_open_bracket = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 let infuncargs = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 if len(brackets_stack) > 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 let first_open_bracket = brackets_stack[0][1]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 let last_open_bracket = brackets_stack[-1][1]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 if brackets_stack[-1][0] == 'par' && IsFunctionArgPar(a:lnum, last_open_bracket+1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 let infuncargs = 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 return [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 let s:bracketBlocks = '\<julia\%(\%(\%(Printf\)\?Par\|SqBra\%(Idx\)\?\|CurBra\)Block\|ParBlockInRange\|StringVars\%(Par\|SqBra\|CurBra\)\|Dollar\%(Par\|SqBra\)\|QuotedParBlockS\?\)\>'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 function IsInBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 let stack = map(synstack(a:lnum, a:c), 'synIDattr(v:val, "name")')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 call filter(stack, 'v:val =~# s:bracketBlocks')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 return len(stack) > 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 function IsInDocString(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 call filter(stack, 'v:val =~# "\\<juliaDocString\\(Delim\\|M\\\(Raw\\)\\?\\)\\?\\>"')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 return len(stack) > 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 function IsInContinuationImportLine(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 let stack = map(synstack(a:lnum, 1), 'synIDattr(v:val, "name")')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 call filter(stack, 'v:val =~# "\\<juliaImportLine\\>"')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 if len(stack) == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 return 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 return JuliaMatch(a:lnum, getline(a:lnum), '\<\%(import\|using\|export\)\>', indent(a:lnum)) == -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 function IsFunctionArgPar(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 if a:c == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 return 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 let stack = map(synstack(a:lnum, a:c-1), 'synIDattr(v:val, "name")')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 return len(stack) >= 2 && stack[-2] ==# 'juliaFunctionDef'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 function JumpToMatch(lnum, last_closed_bracket)
33577
d6dde6229b36 runtime: Fix more typos (#13354)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
313 " we use the % command to skip back (tries to use matchit if possible,
25619
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 " otherwise resorts to vim's default, which is buggy but better than
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 " nothing)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 call cursor(a:lnum, a:last_closed_bracket)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 let percmap = maparg("%", "n")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 if exists("g:loaded_matchit") && percmap =~# 'Match\%(it\|_wrapper\)'
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 normal %
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 normal! %
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 end
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 " Auxiliary function to find a line which does not start in the middle of a
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 " multiline bracketed expression, to be used as reference for block
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 " indentation.
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 function LastBlockIndent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 let lnum = a:lnum
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 let ind = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 while lnum > 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 let ind = indent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 if ind == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 return [lnum, 0]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 if !IsInBrackets(lnum, 1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 let lnum = prevnonblank(lnum - 1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 return [max([lnum,1]), ind]
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 endfunction
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 function GetJuliaIndent()
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 " Do not alter doctrings indentation
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 if IsInDocString(v:lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 return -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 " Find a non-blank line above the current line.
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 let lnum = prevnonblank(v:lnum - 1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 " At the start of the file use zero indent.
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 if lnum == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 return 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 let ind = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 let st = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 let lim = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 " Multiline bracketed expressions take precedence
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 let align_brackets = get(g:, "julia_indent_align_brackets", 1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 let align_funcargs = get(g:, "julia_indent_align_funcargs", 0)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 let c = len(getline(lnum)) + 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 while IsInBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 let [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs] = GetJuliaNestingBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 " First scenario: the previous line has a hanging open bracket:
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 " set the indentation to match the opening bracket (plus an extra space)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 " unless we're in a function arguments list or alignment is disabled, in
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 " which case we just add an extra indent
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 if last_open_bracket != -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 if (!infuncargs && align_brackets) || (infuncargs && align_funcargs)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 let st = last_open_bracket
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 let ind = virtcol([lnum, st + 1])
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 let ind = indent(lnum) + shiftwidth()
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 " Second scenario: some multiline bracketed expression was closed in the
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 " previous line. But since we know we are still in a bracketed expression,
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 " we need to find the line where the bracket was opened
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 elseif last_closed_bracket != -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 call JumpToMatch(lnum, last_closed_bracket)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 if line(".") == lnum
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 " something wrong here, give up
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 let ind = indent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 let lnum = line(".")
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 let c = col(".") - 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 if c == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 " uhm, give up
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 let ind = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 " we skipped a bracket set, keep searching for an opening bracket
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 let lim = c
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 continue
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 " Third scenario: nothing special: keep the indentation
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 let ind = indent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 " Does the current line start with a closing bracket? Then depending on
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 " the situation we align it with the opening one, or we let the rest of
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 " the code figure it out (the case in which we're closing a function
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 " argument list is special-cased)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 if JuliaMatch(v:lnum, getline(v:lnum), '[])}]', indent(v:lnum)) == indent(v:lnum) && ind > 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 if !align_brackets && !align_funcargs
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 call JumpToMatch(v:lnum, indent(v:lnum))
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 return indent(line("."))
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 elseif (align_brackets && getline(v:lnum)[indent(v:lnum)] != ')') || align_funcargs
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 return ind - 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 else " must be a ')' and align_brackets==1 and align_funcargs==0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 call JumpToMatch(v:lnum, indent(v:lnum))
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 if IsFunctionArgPar(line("."), col("."))
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 let ind = -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 return ind - 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 endwhile
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 if ind == -1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 " We are not in a multiline bracketed expression. Thus we look for a
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 " previous line to use as a reference
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 let [lnum,ind] = LastBlockIndent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 let c = len(getline(lnum)) + 1
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 if IsInBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 let [first_open_bracket, last_open_bracket, last_closed_bracket, infuncargs] = GetJuliaNestingBrackets(lnum, c)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 let lim = first_open_bracket
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 end
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 " Analyse the reference line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(lnum, st, lim)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 " Increase indentation for each newly opened block in the reference line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 let ind += shiftwidth() * num_open_blocks
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 " Analyse the current line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 let [num_open_blocks, num_closed_blocks] = GetJuliaNestingStruct(v:lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 " Decrease indentation for each closed block in the current line
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 let ind -= shiftwidth() * num_closed_blocks
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 " Additional special case: multiline import/using/export statements
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 let prevline = getline(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 " Are we in a multiline import/using/export statement, right below the
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 " opening line?
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 if IsInContinuationImportLine(v:lnum) && !IsInContinuationImportLine(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 if get(g:, 'julia_indent_align_import', 1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 " if the opening line has a colon followed by non-comments, use it as
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 " reference point
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 let cind = JuliaMatch(lnum, prevline, ':', indent(lnum), lim)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 if cind >= 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 let nonwhiteind = JuliaMatch(lnum, prevline, '\S', cind+1, -1, 'basic')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 if nonwhiteind >= 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 " return match(prevline, '\S', cind+1) " a bit overkill...
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 return cind + 2
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 else
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 " if the opening line is not a naked import/using/export statement, use
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 " it as reference
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 let iind = JuliaMatch(lnum, prevline, '\<import\|using\|export\>', indent(lnum), lim)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 if iind >= 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 " assuming whitespace after using... so no `using(XYZ)` please!
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 let nonwhiteind = JuliaMatch(lnum, prevline, '\S', iind+6, -1, 'basic')
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 if nonwhiteind >= 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 return match(prevline, '\S', iind+6)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 let ind += shiftwidth()
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 " Or did we just close a multiline import/using/export statement?
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 elseif !IsInContinuationImportLine(v:lnum) && IsInContinuationImportLine(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 " find the starting line of the statement
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 let ilnum = 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 for iln in range(lnum-1, 1, -1)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 if !IsInContinuationImportLine(iln)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 let ilnum = iln
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 break
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 endfor
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 if ilnum == 0
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 " something went horribly wrong, give up
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 let ind = indent(lnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 let ind = indent(ilnum)
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 endif
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 return ind
29ec2c198c8d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 endfunction