@@ -18,9 +18,8 @@ set cpoptions&vim
18
18
19
19
let b: undo_indent = ' setlocal autoindent< smartindent< expandtab< softtabstop< shiftwidth< indentexpr< indentkeys< lisp<'
20
20
21
- setlocal noautoindent nosmartindent nolisp
21
+ setlocal noautoindent nosmartindent nolisp indentkeys = ! , o ,O
22
22
setlocal softtabstop = 2 shiftwidth = 2 expandtab
23
- setlocal indentkeys = ! ,o ,O
24
23
25
24
" Set a new configuration option with a default value. Assigns a script-local
26
25
" version too, to be used as a default fallback if the global was "unlet".
@@ -60,9 +59,8 @@ call s:SConf('clojure_indent_rules', {
60
59
\ ' delay' : 0 , ' future' : 0 , ' locking' : 1 , ' try' : 0 , ' catch' : 2 , ' finally' : 0 ,
61
60
\ ' reify' : 1 , ' proxy' : 2 , ' defrecord' : 2 , ' defprotocol' : 1 , ' definterface' : 1 ,
62
61
\ ' extend' : 1 , ' extend-protocol' : 1 , ' extend-type' : 1 ,
63
- " \ (letfn) (1 ((:defn)) nil)
64
- " \ (deftype defrecord proxy) (2 nil nil (:defn))
65
- " \ (defprotocol definterface extend-protocol extend-type) (1 (:defn))
62
+ " \ [letfn] [1 [[:defn]] nil] [deftype defrecord proxy] [2 nil nil [:defn]]
63
+ " \ [defprotocol definterface extend-protocol extend-type] [1 [:defn]]
66
64
" \ ClojureScript
67
65
\ ' this-as' : 1 , ' specify' : 1 , ' specify!' : 1 ,
68
66
" \ clojure.test
@@ -159,9 +157,7 @@ function! s:InsideForm(lnum)
159
157
let [line_tokens, possible_comment] = s: TokeniseLine (lnum)
160
158
161
159
" In case of comments, copy "tokens" so we can undo alterations.
162
- if possible_comment
163
- let prev_tokens = copy (tokens)
164
- endif
160
+ if possible_comment | let prev_tokens = copy (tokens) | endif
165
161
166
162
" Reduce tokens from line "lnum" into "tokens".
167
163
for tk in line_tokens
@@ -180,11 +176,9 @@ function! s:InsideForm(lnum)
180
176
let first_string_pos = tk
181
177
endif
182
178
endif
183
- elseif in_string
184
- " In string: ignore other tokens.
179
+ elseif in_string " In string: ignore other tokens.
185
180
elseif possible_comment && tk[0 ] == # ' ;'
186
- " Comment: undo previous token applications on
187
- " this line.
181
+ " Comment: undo previous token applications on this line.
188
182
let tokens = copy (prev_tokens)
189
183
elseif ! empty (tokens) && get (s: pairs , tk[0 ], ' ' ) == # tokens[-1 ][0 ]
190
184
" Matching pair: drop the last item in tokens.
@@ -232,8 +226,7 @@ function! s:StringIndent(delim_pos)
232
226
let is_regex = col > 1 && getline (a: delim_pos [0 ])[col - 2 ] == # ' #'
233
227
return s: PosToCharCol (a: delim_pos ) - (is_regex ? 2 : 1 )
234
228
endif
235
- else
236
- return -1 " Keep existing indent.
229
+ else | return -1 " Keep existing indent.
237
230
endif
238
231
endfunction
239
232
@@ -250,21 +243,18 @@ function! s:ListIndent(delim_pos)
250
243
let ln = getline(a:delim_pos[0])
251
244
let ln_content = ln [a:delim_pos[1]:]
252
245
253
- let sym_match = -1
254
-
255
246
" 1. Macro/rule indentation
256
247
" if starts with a symbol, extract it.
257
248
" - Split namespace off symbol and #'/' syntax.
258
249
" - Check against pattern rules and apply indent on match.
259
250
" - Look up in rules table and apply indent on match.
260
- " else, not found, go to 2.
251
+ " else: not found, go to 2.
261
252
262
- " TODO: handle complex indentation (e.g. letfn) and introduce
263
- " indentation config similar to Emacs' clojure-mode and cljfmt.
264
- " Skip if "traditional" style was chosen.
253
+ " TODO: handle complex indentation (e.g. letfn). Skip if "traditional" style was chosen?
265
254
266
255
" TODO: simplify this.
267
256
let syms = split (ln_content, ' [[:space:],;()\[\]{}@\\"^~`]' , 1 )
257
+ let sym_match = -1
268
258
269
259
if ! empty (syms)
270
260
let sym = syms[0 ]
@@ -290,8 +280,7 @@ function! s:ListIndent(delim_pos)
290
280
" 2. Function indentation
291
281
" if first operand is on the same line?
292
282
" - Indent subsequent lines to align with first operand.
293
- " else
294
- " - Indent 1 or 2 spaces.
283
+ " else: indent 1 or 2 spaces.
295
284
let pos = s: FirstFnArgPos (a: delim_pos )
296
285
if pos != [0 , 0 ] | return s: PosToCharCol (pos) - 1 | endif
297
286
0 commit comments