annotate runtime/indent/r.vim @ 28938:ddbb36c1830b v8.2.4991

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