annotate runtime/indent/r.vim @ 11970:938a1e4f79d2

Added tag v8.0.0865 for changeset 5dc3730de58d3c74a5ef9ecccf744099a1429148
author Christian Brabandt <cb@256bit.org>
date Sat, 05 Aug 2017 15:15:04 +0200
parents 4aae8146c21f
children 0ecb909e3249
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: R
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
4 " Homepage: https://github.com/jalvesaq/R-Vim-runtime
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
5 " Last Change: Thu Feb 18, 2016 06:32AM
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
4159
8b86b69546a9 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3153
diff changeset
9 if exists("b:did_indent")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
10 finish
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 endif
4159
8b86b69546a9 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3153
diff changeset
12 let b:did_indent = 1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 setlocal indentkeys=0{,0},:,!^F,o,O,e
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 setlocal indentexpr=GetRIndent()
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 " Only define the function once.
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 if exists("*GetRIndent")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
19 finish
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 " Options to make the indentation more similar to Emacs/ESS:
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 if !exists("g:r_indent_align_args")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
24 let g:r_indent_align_args = 1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 if !exists("g:r_indent_ess_comments")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
27 let g:r_indent_ess_comments = 0
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 if !exists("g:r_indent_comment_column")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
30 let g:r_indent_comment_column = 40
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
32 if ! exists("g:r_indent_ess_compatible")
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
33 let g:r_indent_ess_compatible = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
34 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
35 if ! exists("g:r_indent_op_pattern")
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
36 let g:r_indent_op_pattern = '\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$'
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39 function s:RDelete_quotes(line)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
40 let i = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
41 let j = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
42 let line1 = ""
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
43 let llen = strlen(a:line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
44 while i < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
45 if a:line[i] == '"'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
46 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
47 let line1 = line1 . 's'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
48 while !(a:line[i] == '"' && ((i > 1 && a:line[i-1] == '\' && a:line[i-2] == '\') || a:line[i-1] != '\')) && i < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
49 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
50 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
51 if a:line[i] == '"'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
52 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
53 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
54 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
55 if a:line[i] == "'"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
56 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
57 let line1 = line1 . 's'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
58 while !(a:line[i] == "'" && ((i > 1 && a:line[i-1] == '\' && a:line[i-2] == '\') || a:line[i-1] != '\')) && i < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
59 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
60 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
61 if a:line[i] == "'"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
62 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
63 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
64 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
65 if a:line[i] == "`"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
66 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
67 let line1 = line1 . 's'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
68 while a:line[i] != "`" && i < llen
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 let i += 1
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
70 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
71 if a:line[i] == "`"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
72 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
73 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
75 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
76 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
77 if i == llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
78 break
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
79 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
80 let line1 = line1 . a:line[i]
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
81 let j += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
82 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
83 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
84 return line1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87 " Convert foo(bar()) int foo()
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 function s:RDelete_parens(line)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
89 if s:Get_paren_balance(a:line, "(", ")") != 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
90 return a:line
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
91 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
92 let i = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
93 let j = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
94 let line1 = ""
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
95 let llen = strlen(a:line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
96 while i < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
97 let line1 = line1 . a:line[i]
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
98 if a:line[i] == '('
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
99 let nop = 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
100 while nop > 0 && i < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
101 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
102 if a:line[i] == ')'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
103 let nop -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
104 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
105 if a:line[i] == '('
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
106 let nop += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
107 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
108 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
109 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
110 let line1 = line1 . a:line[i]
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
112 let i += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
113 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
114 return line1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 function! s:Get_paren_balance(line, o, c)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
118 let line2 = substitute(a:line, a:o, "", "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
119 let openp = strlen(a:line) - strlen(line2)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
120 let line3 = substitute(line2, a:c, "", "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
121 let closep = strlen(line2) - strlen(line3)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
122 return openp - closep
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 function! s:Get_matching_brace(linenr, o, c, delbrace)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
126 let line = SanitizeRLine(getline(a:linenr))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
127 if a:delbrace == 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
128 let line = substitute(line, '{$', "", "")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
129 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
130 let pb = s:Get_paren_balance(line, a:o, a:c)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
131 let i = a:linenr
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
132 while pb != 0 && i > 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
133 let i -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
134 let pb += s:Get_paren_balance(SanitizeRLine(getline(i)), a:o, a:c)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
135 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
136 return i
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
138
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 " This function is buggy because there 'if's without 'else'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 " It must be rewritten relying more on indentation
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 function! s:Get_matching_if(linenr, delif)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
142 let line = SanitizeRLine(getline(a:linenr))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
143 if a:delif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
144 let line = substitute(line, "if", "", "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
145 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
146 let elsenr = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
147 let i = a:linenr
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
148 let ifhere = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
149 while i > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
150 let line2 = substitute(line, '\<else\>', "xxx", "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
151 let elsenr += strlen(line) - strlen(line2)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
152 if line =~ '.*\s*if\s*()' || line =~ '.*\s*if\s*()'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
153 let elsenr -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
154 if elsenr == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
155 let ifhere = i
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
156 break
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
157 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
159 let i -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
160 let line = SanitizeRLine(getline(i))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
161 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
162 if ifhere
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
163 return ifhere
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
164 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
165 return a:linenr
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
166 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 function! s:Get_last_paren_idx(line, o, c, pb)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
170 let blc = a:pb
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
171 let line = substitute(a:line, '\t', s:curtabstop, "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
172 let theidx = -1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
173 let llen = strlen(line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
174 let idx = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
175 while idx < llen
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
176 if line[idx] == a:o
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
177 let blc -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
178 if blc == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
179 let theidx = idx
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
180 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
181 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
182 if line[idx] == a:c
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
183 let blc += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
184 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
185 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
186 let idx += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
187 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
188 return theidx + 1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
189 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
190
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191 " Get previous relevant line. Search back until getting a line that isn't
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
192 " comment or blank
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
193 function s:Get_prev_line(lineno)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
194 let lnum = a:lineno - 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
195 let data = getline( lnum )
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
196 while lnum > 0 && (data =~ '^\s*#' || data =~ '^\s*$')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
197 let lnum = lnum - 1
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
198 let data = getline( lnum )
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
199 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
200 return lnum
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
201 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
202
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
203 " This function is also used by r-plugin/common_global.vim
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
204 " Delete from '#' to the end of the line, unless the '#' is inside a string.
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
205 function SanitizeRLine(line)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
206 let newline = s:RDelete_quotes(a:line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
207 let newline = s:RDelete_parens(newline)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
208 let newline = substitute(newline, '#.*', "", "")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
209 let newline = substitute(newline, '\s*$', "", "")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
210 if &filetype == "rhelp" && newline =~ '^\\method{.*}{.*}(.*'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
211 let newline = substitute(newline, '^\\method{\(.*\)}{.*}', '\1', "")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
212 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
213 return newline
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
215
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 function GetRIndent()
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
218 let clnum = line(".") " current line
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
220 let cline = getline(clnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
221 if cline =~ '^\s*#'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
222 if g:r_indent_ess_comments == 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
223 if cline =~ '^\s*###'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
224 return 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
225 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
226 if cline !~ '^\s*##'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
227 return g:r_indent_comment_column
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
228 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
229 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
230 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
231
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
232 let cline = SanitizeRLine(cline)
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
233
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
234 if cline =~ '^\s*}' || cline =~ '^\s*}\s*)$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
235 let indline = s:Get_matching_brace(clnum, '{', '}', 1)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
236 if indline > 0 && indline != clnum
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
237 let iline = SanitizeRLine(getline(indline))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
238 if s:Get_paren_balance(iline, "(", ")") == 0 || iline =~ '(\s*{$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
239 return indent(indline)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
240 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
241 let indline = s:Get_matching_brace(indline, '(', ')', 1)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
242 return indent(indline)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
243 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
244 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
245 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
246
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
247 " Find the first non blank line above the current line
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
248 let lnum = s:Get_prev_line(clnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
249 " Hit the start of the file, use zero indent.
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
250 if lnum == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
251 return 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
252 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
253
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
254 let line = SanitizeRLine(getline(lnum))
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
255
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
256 if &filetype == "rhelp"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
257 if cline =~ '^\\dontshow{' || cline =~ '^\\dontrun{' || cline =~ '^\\donttest{' || cline =~ '^\\testonly{'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
258 return 0
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
259 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
260 if line =~ '^\\examples{' || line =~ '^\\usage{' || line =~ '^\\dontshow{' || line =~ '^\\dontrun{' || line =~ '^\\donttest{' || line =~ '^\\testonly{'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
261 return 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
262 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
263 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
264
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
265 if &filetype == "rnoweb" && line =~ "^<<.*>>="
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
266 return 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
267 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
268
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
269 if cline =~ '^\s*{' && s:Get_paren_balance(cline, '{', '}') > 0
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
270 if g:r_indent_ess_compatible && line =~ ')$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
271 let nlnum = lnum
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
272 let nline = line
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
273 while s:Get_paren_balance(nline, '(', ')') < 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
274 let nlnum = s:Get_prev_line(nlnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
275 let nline = SanitizeRLine(getline(nlnum)) . nline
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
276 endwhile
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
277 if nline =~ '^\s*function\s*(' && indent(nlnum) == shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
278 return 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
279 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
280 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
281 if s:Get_paren_balance(line, "(", ")") == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
282 return indent(lnum)
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
283 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
284 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
285
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
286 " line is an incomplete command:
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
287 if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\<else$' || line =~ '<-$' || line =~ '->$'
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
288 return indent(lnum) + shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
289 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
290
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
291 " Deal with () and []
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
292
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
293 let pb = s:Get_paren_balance(line, '(', ')')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
294
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
295 if line =~ '^\s*{$' || line =~ '(\s*{' || (pb == 0 && (line =~ '{$' || line =~ '(\s*{$'))
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
296 return indent(lnum) + shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
297 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
298
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
299 let s:curtabstop = repeat(' ', &tabstop)
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
300
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
301 if g:r_indent_align_args == 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
302 if pb > 0 && line =~ '{$'
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
303 return s:Get_last_paren_idx(line, '(', ')', pb) + shiftwidth()
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
304 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
305
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
306 let bb = s:Get_paren_balance(line, '[', ']')
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
307
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
308 if pb > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
309 if &filetype == "rhelp"
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
310 let ind = s:Get_last_paren_idx(line, '(', ')', pb)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
311 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
312 let ind = s:Get_last_paren_idx(getline(lnum), '(', ')', pb)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
313 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
314 return ind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
315 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
316
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
317 if pb < 0 && line =~ '.*[,&|\-\*+<>]$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
318 let lnum = s:Get_prev_line(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
319 while pb < 1 && lnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
320 let line = SanitizeRLine(getline(lnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
321 let line = substitute(line, '\t', s:curtabstop, "g")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
322 let ind = strlen(line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
323 while ind > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
324 if line[ind] == ')'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
325 let pb -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
326 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
327 if line[ind] == '('
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
328 let pb += 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
329 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
330 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
331 if pb == 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
332 return ind + 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
333 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
334 let ind -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
335 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
336 let lnum -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
337 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
338 return 0
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
339 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
340
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
341 if bb > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
342 let ind = s:Get_last_paren_idx(getline(lnum), '[', ']', bb)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
343 return ind
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
344 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
345 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
346
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
347 let post_block = 0
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
348 if line =~ '}$' && s:Get_paren_balance(line, '{', '}') < 0
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
349 let lnum = s:Get_matching_brace(lnum, '{', '}', 0)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
350 let line = SanitizeRLine(getline(lnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
351 if lnum > 0 && line =~ '^\s*{'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
352 let lnum = s:Get_prev_line(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
353 let line = SanitizeRLine(getline(lnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
354 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
355 let pb = s:Get_paren_balance(line, '(', ')')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
356 let post_block = 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
357 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
358
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
359 " Indent after operator pattern
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
360 let olnum = s:Get_prev_line(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
361 let oline = getline(olnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
362 if olnum > 0
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
363 if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
364 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
365 return indent(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
366 else
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
367 return indent(lnum) + shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
368 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
369 else
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
370 if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
371 return indent(lnum) - shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
372 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
373 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
374 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
375
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
376 let post_fun = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
377 if pb < 0 && line !~ ')\s*[,&|\-\*+<>]$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
378 let post_fun = 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
379 while pb < 0 && lnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
380 let lnum -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
381 let linepiece = SanitizeRLine(getline(lnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
382 let pb += s:Get_paren_balance(linepiece, "(", ")")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
383 let line = linepiece . line
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
384 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
385 if line =~ '{$' && post_block == 0
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
386 return indent(lnum) + shiftwidth()
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
387 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
388
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
389 " Now we can do some tests again
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
390 if cline =~ '^\s*{'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
391 return indent(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
392 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
393 if post_block == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
394 let newl = SanitizeRLine(line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
395 if newl =~ '\<\(if\|while\|for\|function\)\s*()$' || newl =~ '\<else$' || newl =~ '<-$'
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
396 return indent(lnum) + shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
397 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
398 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
399 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
400
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
401 if cline =~ '^\s*else'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
402 if line =~ '<-\s*if\s*()'
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
403 return indent(lnum) + shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
404 else
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
405 if line =~ '\<if\s*()'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
406 return indent(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
407 else
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
408 return indent(lnum) - shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
409 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
410 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
411 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
412
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
413 let bb = s:Get_paren_balance(line, '[', ']')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
414 if bb < 0 && line =~ '.*]'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
415 while bb < 0 && lnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
416 let lnum -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
417 let linepiece = SanitizeRLine(getline(lnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
418 let bb += s:Get_paren_balance(linepiece, "[", "]")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
419 let line = linepiece . line
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
420 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
421 let line = s:RDelete_parens(line)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
422 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
423
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
424 let plnum = s:Get_prev_line(lnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
425 let ppost_else = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
426 if plnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
427 let pline = SanitizeRLine(getline(plnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
428 let ppost_block = 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
429 if pline =~ '}$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
430 let ppost_block = 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
431 let plnum = s:Get_matching_brace(plnum, '{', '}', 0)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
432 let pline = SanitizeRLine(getline(plnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
433 if pline =~ '^\s*{$' && plnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
434 let plnum = s:Get_prev_line(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
435 let pline = SanitizeRLine(getline(plnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
436 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
437 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
438
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
439 if pline =~ 'else$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
440 let ppost_else = 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
441 let plnum = s:Get_matching_if(plnum, 0)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
442 let pline = SanitizeRLine(getline(plnum))
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
443 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
444
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
445 if pline =~ '^\s*else\s*if\s*('
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
446 let pplnum = s:Get_prev_line(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
447 let ppline = SanitizeRLine(getline(pplnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
448 while ppline =~ '^\s*else\s*if\s*(' || ppline =~ '^\s*if\s*()\s*\S$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
449 let plnum = pplnum
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
450 let pline = ppline
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
451 let pplnum = s:Get_prev_line(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
452 let ppline = SanitizeRLine(getline(pplnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
453 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
454 while ppline =~ '\<\(if\|while\|for\|function\)\s*()$' || ppline =~ '\<else$' || ppline =~ '<-$'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
455 let plnum = pplnum
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
456 let pline = ppline
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
457 let pplnum = s:Get_prev_line(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
458 let ppline = SanitizeRLine(getline(pplnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
459 endwhile
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
460 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
461
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
462 let ppb = s:Get_paren_balance(pline, '(', ')')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
463 if ppb < 0 && (pline =~ ')\s*{$' || pline =~ ')$')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
464 while ppb < 0 && plnum > 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
465 let plnum -= 1
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
466 let linepiece = SanitizeRLine(getline(plnum))
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
467 let ppb += s:Get_paren_balance(linepiece, "(", ")")
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
468 let pline = linepiece . pline
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
469 endwhile
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
470 let pline = s:RDelete_parens(pline)
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
471 endif
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
472 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
473
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
474 let ind = indent(lnum)
3153
37ecb8ff4560 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
475
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
476 if g:r_indent_align_args == 0 && pb != 0
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
477 let ind += pb * shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
478 return ind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
479 endif
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
480
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
481 if g:r_indent_align_args == 0 && bb != 0
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
482 let ind += bb * shiftwidth()
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
483 return ind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
484 endif
3153
37ecb8ff4560 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
485
8497
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
486 if plnum > 0
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
487 let pind = indent(plnum)
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
488 else
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
489 let pind = 0
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
490 endif
da01d5da2cfa commit https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151
Christian Brabandt <cb@256bit.org>
parents: 6840
diff changeset
491
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
492 if ind == pind || (ind == (pind + shiftwidth()) && pline =~ '{$' && ppost_else == 0)
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
493 return ind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
494 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
495
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
496 let pline = getline(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
497 let pbb = s:Get_paren_balance(pline, '[', ']')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
498
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
499 while pind < ind && plnum > 0 && ppb == 0 && pbb == 0
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
500 let ind = pind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
501 let plnum = s:Get_prev_line(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
502 let pline = getline(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
503 let ppb = s:Get_paren_balance(pline, '(', ')')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
504 let pbb = s:Get_paren_balance(pline, '[', ']')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
505 while pline =~ '^\s*else'
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
506 let plnum = s:Get_matching_if(plnum, 1)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
507 let pline = getline(plnum)
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
508 let ppb = s:Get_paren_balance(pline, '(', ')')
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
509 let pbb = s:Get_paren_balance(pline, '[', ']')
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
510 endwhile
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
511 let pind = indent(plnum)
11347
4aae8146c21f Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 8497
diff changeset
512 if ind == (pind + shiftwidth()) && pline =~ '{$'
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
513 return ind
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
514 endif
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
515 endwhile
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
516
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
517 return ind
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
518
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
519 endfunction
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
520
6840
37828f7503c7 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4159
diff changeset
521 " vim: sw=2