Mercurial > vim
annotate runtime/indent/ruby.vim @ 10048:43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 30 23:26:57 2016 +0200
Updated runtime files. Remove version checks for Vim older than 6.0.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 30 Aug 2016 23:30:09 +0200 |
parents | a5352e73dc00 |
children | 57b2b8268d3a |
rev | line source |
---|---|
7 | 1 " Vim indent file |
843 | 2 " Language: Ruby |
3 " Maintainer: Nikolai Weibull <now at bitwi.se> | |
4869 | 4 " URL: https://github.com/vim-ruby/vim-ruby |
843 | 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
530 | 6 |
7 " 0. Initialization {{{1 | |
8 " ================= | |
7 | 9 |
10 " Only load this indent file when no other was loaded. | |
11 if exists("b:did_indent") | |
12 finish | |
13 endif | |
14 let b:did_indent = 1 | |
15 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
16 if !exists('g:ruby_indent_access_modifier_style') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
17 " Possible values: "normal", "indent", "outdent" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
18 let g:ruby_indent_access_modifier_style = 'normal' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
19 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
20 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
21 if !exists('g:ruby_indent_block_style') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
22 " Possible values: "expression", "do" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
23 let g:ruby_indent_block_style = 'expression' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
24 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
25 |
843 | 26 setlocal nosmartindent |
27 | |
530 | 28 " Now, set up our indentation expression and keys that trigger it. |
4869 | 29 setlocal indentexpr=GetRubyIndent(v:lnum) |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
30 setlocal indentkeys=0{,0},0),0],!^F,o,O,e,:,. |
4869 | 31 setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
32 setlocal indentkeys+==private,=protected,=public |
7 | 33 |
34 " Only define the function once. | |
35 if exists("*GetRubyIndent") | |
36 finish | |
37 endif | |
38 | |
530 | 39 let s:cpo_save = &cpo |
40 set cpo&vim | |
41 | |
42 " 1. Variables {{{1 | |
43 " ============ | |
44 | |
4869 | 45 " Regex of syntax group names that are or delimit strings/symbols or are comments. |
46 let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' . | |
47 \ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' . | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
48 \ '\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>' |
530 | 49 |
50 " Regex of syntax group names that are strings. | |
51 let s:syng_string = | |
1668 | 52 \ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>' |
530 | 53 |
54 " Regex of syntax group names that are strings or documentation. | |
55 let s:syng_stringdoc = | |
4869 | 56 \'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>' |
530 | 57 |
58 " Expression used to check whether we should skip a match with searchpair(). | |
59 let s:skip_expr = | |
1668 | 60 \ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" |
530 | 61 |
62 " Regex used for words that, at the start of a line, add a level of indent. | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
63 let s:ruby_indent_keywords = |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
64 \ '^\s*\zs\<\%(module\|class\|if\|for' . |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
65 \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue' . |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
66 \ '\|\%(public\|protected\|private\)\=\s*def\):\@!\>' . |
4869 | 67 \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . |
68 \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' | |
530 | 69 |
70 " Regex used for words that, at the start of a line, remove a level of indent. | |
71 let s:ruby_deindent_keywords = | |
4869 | 72 \ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>' |
530 | 73 |
74 " Regex that defines the start-match for the 'end' keyword. | |
75 "let s:end_start_regex = '\%(^\|[^.]\)\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\|do\)\>' | |
76 " TODO: the do here should be restricted somewhat (only at end of line)? | |
4869 | 77 let s:end_start_regex = |
78 \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
79 \ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' . |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
80 \ '\|\%(public\|protected\|private\)\=\s*def\):\@!\>' . |
4869 | 81 \ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>' |
530 | 82 |
83 " Regex that defines the middle-match for the 'end' keyword. | |
4869 | 84 let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>' |
530 | 85 |
86 " Regex that defines the end-match for the 'end' keyword. | |
4869 | 87 let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>' |
530 | 88 |
89 " Expression used for searchpair() call for finding match for 'end' keyword. | |
90 let s:end_skip_expr = s:skip_expr . | |
91 \ ' || (expand("<cword>") == "do"' . | |
4869 | 92 \ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")' |
530 | 93 |
94 " Regex that defines continuation lines, not including (, {, or [. | |
4869 | 95 let s:non_bracket_continuation_regex = '\%([\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' |
530 | 96 |
97 " Regex that defines continuation lines. | |
4869 | 98 let s:continuation_regex = |
99 \ '\%(%\@<![({[\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' | |
100 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
101 " Regex that defines continuable keywords |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
102 let s:continuable_regex = |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
103 \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
104 \ '\<\%(if\|for\|while\|until\|unless\):\@!\>' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
105 |
4869 | 106 " Regex that defines bracket continuations |
107 let s:bracket_continuation_regex = '%\@<!\%([({[]\)\s*\%(#.*\)\=$' | |
108 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
109 " Regex that defines dot continuations |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
110 let s:dot_continuation_regex = '%\@<!\.\s*\%(#.*\)\=$' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
111 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
112 " Regex that defines backslash continuations |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
113 let s:backslash_continuation_regex = '%\@<!\\\s*$' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
114 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
115 " Regex that defines end of bracket continuation followed by another continuation |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
116 let s:bracket_switch_continuation_regex = '^\([^(]\+\zs).\+\)\+'.s:continuation_regex |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
117 |
4869 | 118 " Regex that defines the first part of a splat pattern |
119 let s:splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$' | |
530 | 120 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
121 " Regex that describes all indent access modifiers |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
122 let s:access_modifier_regex = '\C^\s*\%(public\|protected\|private\)\s*\%(#.*\)\=$' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
123 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
124 " Regex that describes the indent access modifiers (excludes public) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
125 let s:indent_access_modifier_regex = '\C^\s*\%(protected\|private\)\s*\%(#.*\)\=$' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
126 |
530 | 127 " Regex that defines blocks. |
4869 | 128 " |
129 " Note that there's a slight problem with this regex and s:continuation_regex. | |
130 " Code like this will be matched by both: | |
131 " | |
132 " method_call do |(a, b)| | |
133 " | |
134 " The reason is that the pipe matches a hanging "|" operator. | |
135 " | |
530 | 136 let s:block_regex = |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
137 \ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|[^|]*|\)\=\s*\%(#.*\)\=$' |
4869 | 138 |
139 let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex | |
530 | 140 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
141 " Regex that describes a leading operator (only a method call's dot for now) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
142 let s:leading_operator_regex = '^\s*[.]' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
143 |
530 | 144 " 2. Auxiliary Functions {{{1 |
145 " ====================== | |
146 | |
147 " Check if the character at lnum:col is inside a string, comment, or is ascii. | |
148 function s:IsInStringOrComment(lnum, col) | |
1668 | 149 return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom |
530 | 150 endfunction |
151 | |
152 " Check if the character at lnum:col is inside a string. | |
153 function s:IsInString(lnum, col) | |
1668 | 154 return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string |
530 | 155 endfunction |
156 | |
157 " Check if the character at lnum:col is inside a string or documentation. | |
158 function s:IsInStringOrDocumentation(lnum, col) | |
1668 | 159 return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc |
530 | 160 endfunction |
161 | |
4869 | 162 " Check if the character at lnum:col is inside a string delimiter |
163 function s:IsInStringDelimiter(lnum, col) | |
164 return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'rubyStringDelimiter' | |
165 endfunction | |
166 | |
530 | 167 " Find line above 'lnum' that isn't empty, in a comment, or in a string. |
168 function s:PrevNonBlankNonString(lnum) | |
169 let in_block = 0 | |
170 let lnum = prevnonblank(a:lnum) | |
171 while lnum > 0 | |
172 " Go in and out of blocks comments as necessary. | |
173 " If the line isn't empty (with opt. comment) or in a string, end search. | |
174 let line = getline(lnum) | |
4869 | 175 if line =~ '^=begin' |
530 | 176 if in_block |
4869 | 177 let in_block = 0 |
530 | 178 else |
4869 | 179 break |
530 | 180 endif |
4869 | 181 elseif !in_block && line =~ '^=end' |
530 | 182 let in_block = 1 |
183 elseif !in_block && line !~ '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1) | |
4869 | 184 \ && s:IsInStringOrComment(lnum, strlen(line))) |
530 | 185 break |
186 endif | |
187 let lnum = prevnonblank(lnum - 1) | |
188 endwhile | |
189 return lnum | |
190 endfunction | |
191 | |
192 " Find line above 'lnum' that started the continuation 'lnum' may be part of. | |
193 function s:GetMSL(lnum) | |
194 " Start on the line we're at and use its indent. | |
195 let msl = a:lnum | |
4869 | 196 let msl_body = getline(msl) |
530 | 197 let lnum = s:PrevNonBlankNonString(a:lnum - 1) |
198 while lnum > 0 | |
199 " If we have a continuation line, or we're in a string, use line as MSL. | |
200 " Otherwise, terminate search as we have found our MSL already. | |
201 let line = getline(lnum) | |
4869 | 202 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
203 if !s:Match(msl, s:backslash_continuation_regex) && |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
204 \ s:Match(lnum, s:backslash_continuation_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
205 " If the current line doesn't end in a backslash, but the previous one |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
206 " does, look for that line's msl |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
207 " |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
208 " Example: |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
209 " foo = "bar" \ |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
210 " "baz" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
211 " |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
212 let msl = lnum |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
213 elseif s:Match(msl, s:leading_operator_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
214 " If the current line starts with a leading operator, keep its indent |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
215 " and keep looking for an MSL. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
216 let msl = lnum |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
217 elseif s:Match(lnum, s:splat_regex) |
4869 | 218 " If the above line looks like the "*" of a splat, use the current one's |
219 " indentation. | |
220 " | |
221 " Example: | |
222 " Hash[* | |
223 " method_call do | |
224 " something | |
225 " | |
226 return msl | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
227 elseif s:Match(lnum, s:non_bracket_continuation_regex) && |
4869 | 228 \ s:Match(msl, s:non_bracket_continuation_regex) |
229 " If the current line is a non-bracket continuation and so is the | |
230 " previous one, keep its indent and continue looking for an MSL. | |
231 " | |
232 " Example: | |
233 " method_call one, | |
234 " two, | |
235 " three | |
236 " | |
530 | 237 let msl = lnum |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
238 elseif s:Match(lnum, s:dot_continuation_regex) && |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
239 \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
240 " If the current line is a bracket continuation or a block-starter, but |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
241 " the previous is a dot, keep going to see if the previous line is the |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
242 " start of another continuation. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
243 " |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
244 " Example: |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
245 " parent. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
246 " method_call { |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
247 " three |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
248 " |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
249 let msl = lnum |
4869 | 250 elseif s:Match(lnum, s:non_bracket_continuation_regex) && |
251 \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) | |
252 " If the current line is a bracket continuation or a block-starter, but | |
253 " the previous is a non-bracket one, respect the previous' indentation, | |
254 " and stop here. | |
255 " | |
256 " Example: | |
257 " method_call one, | |
258 " two { | |
259 " three | |
260 " | |
261 return lnum | |
262 elseif s:Match(lnum, s:bracket_continuation_regex) && | |
263 \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) | |
264 " If both lines are bracket continuations (the current may also be a | |
265 " block-starter), use the current one's and stop here | |
266 " | |
267 " Example: | |
268 " method_call( | |
269 " other_method_call( | |
270 " foo | |
271 return msl | |
272 elseif s:Match(lnum, s:block_regex) && | |
273 \ !s:Match(msl, s:continuation_regex) && | |
274 \ !s:Match(msl, s:block_continuation_regex) | |
275 " If the previous line is a block-starter and the current one is | |
276 " mostly ordinary, use the current one as the MSL. | |
277 " | |
278 " Example: | |
279 " method_call do | |
280 " something | |
281 " something_else | |
282 return msl | |
530 | 283 else |
4869 | 284 let col = match(line, s:continuation_regex) + 1 |
285 if (col > 0 && !s:IsInStringOrComment(lnum, col)) | |
286 \ || s:IsInString(lnum, strlen(line)) | |
287 let msl = lnum | |
288 else | |
289 break | |
290 endif | |
530 | 291 endif |
4869 | 292 |
293 let msl_body = getline(msl) | |
530 | 294 let lnum = s:PrevNonBlankNonString(lnum - 1) |
295 endwhile | |
296 return msl | |
297 endfunction | |
298 | |
299 " Check if line 'lnum' has more opening brackets than closing ones. | |
4869 | 300 function s:ExtraBrackets(lnum) |
301 let opening = {'parentheses': [], 'braces': [], 'brackets': []} | |
302 let closing = {'parentheses': [], 'braces': [], 'brackets': []} | |
303 | |
530 | 304 let line = getline(a:lnum) |
4869 | 305 let pos = match(line, '[][(){}]', 0) |
306 | |
307 " Save any encountered opening brackets, and remove them once a matching | |
308 " closing one has been found. If a closing bracket shows up that doesn't | |
309 " close anything, save it for later. | |
530 | 310 while pos != -1 |
311 if !s:IsInStringOrComment(a:lnum, pos + 1) | |
4869 | 312 if line[pos] == '(' |
313 call add(opening.parentheses, {'type': '(', 'pos': pos}) | |
314 elseif line[pos] == ')' | |
315 if empty(opening.parentheses) | |
316 call add(closing.parentheses, {'type': ')', 'pos': pos}) | |
317 else | |
318 let opening.parentheses = opening.parentheses[0:-2] | |
319 endif | |
320 elseif line[pos] == '{' | |
321 call add(opening.braces, {'type': '{', 'pos': pos}) | |
322 elseif line[pos] == '}' | |
323 if empty(opening.braces) | |
324 call add(closing.braces, {'type': '}', 'pos': pos}) | |
325 else | |
326 let opening.braces = opening.braces[0:-2] | |
327 endif | |
328 elseif line[pos] == '[' | |
329 call add(opening.brackets, {'type': '[', 'pos': pos}) | |
330 elseif line[pos] == ']' | |
331 if empty(opening.brackets) | |
332 call add(closing.brackets, {'type': ']', 'pos': pos}) | |
333 else | |
334 let opening.brackets = opening.brackets[0:-2] | |
335 endif | |
530 | 336 endif |
337 endif | |
4869 | 338 |
530 | 339 let pos = match(line, '[][(){}]', pos + 1) |
340 endwhile | |
4869 | 341 |
342 " Find the rightmost brackets, since they're the ones that are important in | |
343 " both opening and closing cases | |
344 let rightmost_opening = {'type': '(', 'pos': -1} | |
345 let rightmost_closing = {'type': ')', 'pos': -1} | |
346 | |
347 for opening in opening.parentheses + opening.braces + opening.brackets | |
348 if opening.pos > rightmost_opening.pos | |
349 let rightmost_opening = opening | |
350 endif | |
351 endfor | |
352 | |
353 for closing in closing.parentheses + closing.braces + closing.brackets | |
354 if closing.pos > rightmost_closing.pos | |
355 let rightmost_closing = closing | |
356 endif | |
357 endfor | |
358 | |
359 return [rightmost_opening, rightmost_closing] | |
530 | 360 endfunction |
361 | |
362 function s:Match(lnum, regex) | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
363 let line = getline(a:lnum) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
364 let offset = match(line, '\C'.a:regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
365 let col = offset + 1 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
366 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
367 while offset > -1 && s:IsInStringOrComment(a:lnum, col) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
368 let offset = match(line, '\C'.a:regex, offset + 1) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
369 let col = offset + 1 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
370 endwhile |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
371 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
372 if offset > -1 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
373 return col |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
374 else |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
375 return 0 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
376 endif |
530 | 377 endfunction |
378 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
379 " Locates the containing class/module's definition line, ignoring nested classes |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
380 " along the way. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
381 " |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
382 function! s:FindContainingClass() |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
383 let saved_position = getpos('.') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
384 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
385 while searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW', |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
386 \ s:end_skip_expr) > 0 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
387 if expand('<cword>') =~# '\<class\|module\>' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
388 let found_lnum = line('.') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
389 call setpos('.', saved_position) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
390 return found_lnum |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
391 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
392 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
393 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
394 call setpos('.', saved_position) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
395 return 0 |
530 | 396 endfunction |
397 | |
398 " 3. GetRubyIndent Function {{{1 | |
399 " ========================= | |
400 | |
4869 | 401 function GetRubyIndent(...) |
530 | 402 " 3.1. Setup {{{2 |
403 " ---------- | |
404 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
405 " The value of a single shift-width |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
406 if exists('*shiftwidth') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
407 let sw = shiftwidth() |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
408 else |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
409 let sw = &sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
410 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
411 |
4869 | 412 " For the current line, use the first argument if given, else v:lnum |
413 let clnum = a:0 ? a:1 : v:lnum | |
414 | |
415 " Set up variables for restoring position in file. Could use clnum here. | |
530 | 416 let vcol = col('.') |
417 | |
418 " 3.2. Work on the current line {{{2 | |
419 " ----------------------------- | |
420 | |
421 " Get the current line. | |
4869 | 422 let line = getline(clnum) |
530 | 423 let ind = -1 |
424 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
425 " If this line is an access modifier keyword, align according to the closest |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
426 " class declaration. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
427 if g:ruby_indent_access_modifier_style == 'indent' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
428 if s:Match(clnum, s:access_modifier_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
429 let class_line = s:FindContainingClass() |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
430 if class_line > 0 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
431 return indent(class_line) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
432 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
433 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
434 elseif g:ruby_indent_access_modifier_style == 'outdent' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
435 if s:Match(clnum, s:access_modifier_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
436 let class_line = s:FindContainingClass() |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
437 if class_line > 0 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
438 return indent(class_line) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
439 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
440 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
441 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
442 |
530 | 443 " If we got a closing bracket on an empty line, find its match and indent |
444 " according to it. For parentheses we indent to its column - 1, for the | |
445 " others we indent to the containing line's MSL's level. Return -1 if fail. | |
446 let col = matchend(line, '^\s*[]})]') | |
4869 | 447 if col > 0 && !s:IsInStringOrComment(clnum, col) |
448 call cursor(clnum, col) | |
530 | 449 let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) |
450 if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 | |
1121 | 451 if line[col-1]==')' && col('.') != col('$') - 1 |
4869 | 452 let ind = virtcol('.') - 1 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
453 elseif g:ruby_indent_block_style == 'do' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
454 let ind = indent(line('.')) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
455 else " g:ruby_indent_block_style == 'expression' |
4869 | 456 let ind = indent(s:GetMSL(line('.'))) |
1121 | 457 endif |
530 | 458 endif |
459 return ind | |
460 endif | |
461 | |
462 " If we have a =begin or =end set indent to first column. | |
463 if match(line, '^\s*\%(=begin\|=end\)$') != -1 | |
464 return 0 | |
465 endif | |
466 | |
467 " If we have a deindenting keyword, find its match and indent to its level. | |
468 " TODO: this is messy | |
4869 | 469 if s:Match(clnum, s:ruby_deindent_keywords) |
470 call cursor(clnum, 1) | |
530 | 471 if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW', |
4869 | 472 \ s:end_skip_expr) > 0 |
473 let msl = s:GetMSL(line('.')) | |
474 let line = getline(line('.')) | |
475 | |
532 | 476 if strpart(line, 0, col('.') - 1) =~ '=\s*$' && |
4869 | 477 \ strpart(line, col('.') - 1, 2) !~ 'do' |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
478 " assignment to case/begin/etc, on the same line, hanging indent |
4869 | 479 let ind = virtcol('.') - 1 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
480 elseif g:ruby_indent_block_style == 'do' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
481 " align to line of the "do", not to the MSL |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
482 let ind = indent(line('.')) |
4869 | 483 elseif getline(msl) =~ '=\s*\(#.*\)\=$' |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
484 " in the case of assignment to the MSL, align to the starting line, |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
485 " not to the MSL |
4869 | 486 let ind = indent(line('.')) |
530 | 487 else |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
488 " align to the MSL |
4869 | 489 let ind = indent(msl) |
530 | 490 endif |
491 endif | |
492 return ind | |
493 endif | |
494 | |
495 " If we are in a multi-line string or line-comment, don't do anything to it. | |
4869 | 496 if s:IsInStringOrDocumentation(clnum, matchend(line, '^\s*') + 1) |
530 | 497 return indent('.') |
498 endif | |
499 | |
4869 | 500 " If we are at the closing delimiter of a "<<" heredoc-style string, set the |
501 " indent to 0. | |
502 if line =~ '^\k\+\s*$' | |
503 \ && s:IsInStringDelimiter(clnum, 1) | |
504 \ && search('\V<<'.line, 'nbW') > 0 | |
505 return 0 | |
506 endif | |
507 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
508 " If the current line starts with a leading operator, add a level of indent. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
509 if s:Match(clnum, s:leading_operator_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
510 return indent(s:GetMSL(clnum)) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
511 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
512 |
530 | 513 " 3.3. Work on the previous line. {{{2 |
514 " ------------------------------- | |
515 | |
516 " Find a non-blank, non-multi-line string line above the current line. | |
4869 | 517 let lnum = s:PrevNonBlankNonString(clnum - 1) |
7 | 518 |
1668 | 519 " If the line is empty and inside a string, use the previous line. |
4869 | 520 if line =~ '^\s*$' && lnum != prevnonblank(clnum - 1) |
521 return indent(prevnonblank(clnum)) | |
1668 | 522 endif |
523 | |
7 | 524 " At the start of the file use zero indent. |
525 if lnum == 0 | |
526 return 0 | |
527 endif | |
528 | |
4869 | 529 " Set up variables for the previous line. |
530 | 530 let line = getline(lnum) |
531 let ind = indent(lnum) | |
532 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
533 if g:ruby_indent_access_modifier_style == 'indent' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
534 " If the previous line was a private/protected keyword, add a |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
535 " level of indent. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
536 if s:Match(lnum, s:indent_access_modifier_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
537 return indent(lnum) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
538 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
539 elseif g:ruby_indent_access_modifier_style == 'outdent' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
540 " If the previous line was a private/protected/public keyword, add |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
541 " a level of indent, since the keyword has been out-dented. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
542 if s:Match(lnum, s:access_modifier_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
543 return indent(lnum) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
544 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
545 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
546 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
547 if s:Match(lnum, s:continuable_regex) && s:Match(lnum, s:continuation_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
548 return indent(s:GetMSL(lnum)) + sw + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
549 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
550 |
530 | 551 " If the previous line ended with a block opening, add a level of indent. |
552 if s:Match(lnum, s:block_regex) | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
553 let msl = s:GetMSL(lnum) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
554 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
555 if g:ruby_indent_block_style == 'do' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
556 " don't align to the msl, align to the "do" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
557 let ind = indent(lnum) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
558 elseif getline(msl) =~ '=\s*\(#.*\)\=$' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
559 " in the case of assignment to the msl, align to the starting line, |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
560 " not to the msl |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
561 let ind = indent(lnum) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
562 else |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
563 let ind = indent(msl) + sw |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
564 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
565 return ind |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
566 endif |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
567 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
568 " If the previous line started with a leading operator, use its MSL's level |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
569 " of indent |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
570 if s:Match(lnum, s:leading_operator_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
571 return indent(s:GetMSL(lnum)) |
530 | 572 endif |
573 | |
4869 | 574 " If the previous line ended with the "*" of a splat, add a level of indent |
575 if line =~ s:splat_regex | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
576 return indent(lnum) + sw |
4869 | 577 endif |
578 | |
579 " If the previous line contained unclosed opening brackets and we are still | |
580 " in them, find the rightmost one and add indent depending on the bracket | |
581 " type. | |
582 " | |
583 " If it contained hanging closing brackets, find the rightmost one, find its | |
584 " match and indent according to that. | |
585 if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$' | |
586 let [opening, closing] = s:ExtraBrackets(lnum) | |
587 | |
588 if opening.pos != -1 | |
589 if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 | |
590 if col('.') + 1 == col('$') | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
591 return ind + sw |
4869 | 592 else |
593 return virtcol('.') | |
594 endif | |
1121 | 595 else |
4869 | 596 let nonspace = matchend(line, '\S', opening.pos + 1) - 1 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
597 return nonspace > 0 ? nonspace : ind + sw |
1121 | 598 endif |
4869 | 599 elseif closing.pos != -1 |
600 call cursor(lnum, closing.pos + 1) | |
601 normal! % | |
602 | |
603 if s:Match(line('.'), s:ruby_indent_keywords) | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
604 return indent('.') + sw |
4869 | 605 else |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
606 return indent(s:GetMSL(line('.'))) |
4869 | 607 endif |
530 | 608 else |
4869 | 609 call cursor(clnum, vcol) |
530 | 610 end |
7 | 611 endif |
612 | |
530 | 613 " If the previous line ended with an "end", match that "end"s beginning's |
614 " indent. | |
1212 | 615 let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$') |
530 | 616 if col > 0 |
617 call cursor(lnum, col) | |
618 if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW', | |
4869 | 619 \ s:end_skip_expr) > 0 |
530 | 620 let n = line('.') |
621 let ind = indent('.') | |
622 let msl = s:GetMSL(n) | |
623 if msl != n | |
4869 | 624 let ind = indent(msl) |
530 | 625 end |
626 return ind | |
627 endif | |
628 end | |
629 | |
630 let col = s:Match(lnum, s:ruby_indent_keywords) | |
631 if col > 0 | |
632 call cursor(lnum, col) | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
633 let ind = virtcol('.') - 1 + sw |
530 | 634 " TODO: make this better (we need to count them) (or, if a searchpair |
635 " fails, we know that something is lacking an end and thus we indent a | |
636 " level | |
637 if s:Match(lnum, s:end_end_regex) | |
638 let ind = indent('.') | |
639 endif | |
640 return ind | |
7 | 641 endif |
642 | |
530 | 643 " 3.4. Work on the MSL line. {{{2 |
644 " -------------------------- | |
645 | |
646 " Set up variables to use and search for MSL to the previous line. | |
647 let p_lnum = lnum | |
648 let lnum = s:GetMSL(lnum) | |
649 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
650 " If the previous line wasn't a MSL. |
530 | 651 if p_lnum != lnum |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
652 " If previous line ends bracket and begins non-bracket continuation decrease indent by 1. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
653 if s:Match(p_lnum, s:bracket_switch_continuation_regex) |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
654 return ind - 1 |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
655 " If previous line is a continuation return its indent. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
656 " TODO: the || s:IsInString() thing worries me a bit. |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
657 elseif s:Match(p_lnum, s:non_bracket_continuation_regex) || s:IsInString(p_lnum,strlen(line)) |
530 | 658 return ind |
659 endif | |
7 | 660 endif |
661 | |
530 | 662 " Set up more variables, now that we know we wasn't continuation bound. |
663 let line = getline(lnum) | |
664 let msl_ind = indent(lnum) | |
665 | |
666 " If the MSL line had an indenting keyword in it, add a level of indent. | |
667 " TODO: this does not take into account contrived things such as | |
668 " module Foo; class Bar; end | |
669 if s:Match(lnum, s:ruby_indent_keywords) | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
670 let ind = msl_ind + sw |
530 | 671 if s:Match(lnum, s:end_end_regex) |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
672 let ind = ind - sw |
530 | 673 endif |
674 return ind | |
7 | 675 endif |
676 | |
4869 | 677 " If the previous line ended with [*+/.,-=], but wasn't a block ending or a |
678 " closing bracket, indent one extra level. | |
679 if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)') | |
530 | 680 if lnum == p_lnum |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4869
diff
changeset
|
681 let ind = msl_ind + sw |
530 | 682 else |
683 let ind = msl_ind | |
684 endif | |
4869 | 685 return ind |
530 | 686 endif |
687 | |
688 " }}}2 | |
689 | |
7 | 690 return ind |
691 endfunction | |
692 | |
530 | 693 " }}}1 |
694 | |
695 let &cpo = s:cpo_save | |
696 unlet s:cpo_save | |
1121 | 697 |
4869 | 698 " vim:set sw=2 sts=2 ts=8 et: |