@@ -16,10 +16,9 @@ let b:did_indent = 1
1616let s: save_cpo = &cpoptions
1717set cpoptions &vim
1818
19- let b: undo_indent = ' setlocal autoindent< smartindent< expandtab< softtabstop< shiftwidth< indentexpr< indentkeys< lisp<'
20-
2119setlocal noautoindent nosmartindent nolisp indentkeys = ! ,o ,O
2220setlocal softtabstop = 2 shiftwidth = 2 expandtab
21+ let b: undo_indent = ' setlocal autoindent< smartindent< expandtab< softtabstop< shiftwidth< indentexpr< indentkeys< lisp<'
2322
2423" Set a new configuration option with a default value. Assigns a script-local
2524" version too, to be used as a default fallback if the global was "unlet".
@@ -76,8 +75,7 @@ call s:SConf('clojure_indent_rules', {
7675" Returns "1" if position "i_char" in "line_str" is preceded by an odd number
7776" of backslash characters (i.e. escaped).
7877function ! s: IsEscaped (line_str, i_char)
79- let ln = a:line_str[: a:i_char - 1]
80- return ! strlen (trim (ln , '\', 2)) % 2
78+ return ! strlen (trim (a: line_str [: a: i_char - 1 ], ' \' , 2 )) % 2
8179endfunction
8280
8381" Used during list function indentation. Returns the position of the first
@@ -100,8 +98,7 @@ endfunction
10098" Converts a cursor position into a characterwise cursor column position (to
10199" handle multibyte characters).
102100function ! s: PosToCharCol (pos)
103- call cursor (a: pos )
104- return getcursorcharpos ()[2 ]
101+ call cursor (a: pos ) | return getcursorcharpos ()[2 ]
105102endfunction
106103
107104" Repeatedly search for indentation significant Clojure tokens on a given line
@@ -190,17 +187,15 @@ function! s:InsideForm(lnum)
190187 endfor
191188
192189 if ! empty (tokens) && has_key (s: pairs , tokens[0 ][0 ]) && ! in_string
193- " Match found!
194- return tokens[0 ]
190+ return tokens[0 ] " Match found!
195191 endif
196192
197193 let lnum -= 1
198194 endwhile
199195
200196 " TODO: can this conditional be simplified?
201197 if (in_string && first_string_pos != []) || (! empty (tokens) && tokens[0 ][0 ] == # ' "' )
202- " Must have been in a multi-line string or regular expression
203- " as the string was never closed.
198+ " String was not closed, must have been in a multi-line string or regex.
204199 return first_string_pos
205200 endif
206201
@@ -209,8 +204,7 @@ endfunction
209204
210205" Returns "1" when the "=" operator is currently active, else "0".
211206function ! s: EqualsOperatorInEffect ()
212- return exists (' *state' )
213- \ ? v: operator == # ' =' && state (' o' ) == # ' o' : 0
207+ return exists (' *state' ) ? v: operator == # ' =' && state (' o' ) == # ' o' : 0
214208endfunction
215209
216210function ! s: StringIndent (delim_pos)
@@ -249,8 +243,7 @@ function! s:ListIndent(delim_pos)
249243 " - Check against pattern rules and apply indent on match.
250244 " - Look up in rules table and apply indent on match.
251245 " else: not found, go to 2.
252-
253- " TODO: handle complex indentation (e.g. letfn). Skip if "traditional" style was chosen?
246+ " TODO: handle complex indentation (e.g. letfn). Skip if "traditional" style was chosen?
254247
255248 " TODO: simplify this.
256249 let syms = split (ln_content, ' [[:space:],;()\[\]{}@\\"^~`]' , 1 )
@@ -259,7 +252,6 @@ function! s:ListIndent(delim_pos)
259252 if ! empty (syms)
260253 let sym = syms[0 ]
261254 if sym = ~# ' \v^%([a-zA-Z!$&*_+=|<>?-]|[^\x00-\x7F])'
262-
263255 " TODO: handle namespaced and non-namespaced variants.
264256 if sym = ~# ' \m./.'
265257 let [_namespace, name] = split (sym, ' \m/' )
0 commit comments