@@ -56,16 +56,13 @@ function! s:GetStringIndent(delim_pos, regex)
56
56
let m = mode ()
57
57
if m == # ' i' || (m == # ' n' && ! s: EqualsOperatorInEffect ())
58
58
" If in insert mode, or normal mode but "=" is not in effect.
59
- let rule = s: Conf (' clojure_align_multiline_strings' , 0 )
60
- if rule == -1
61
- " Indent along left edge, like traditional Lisps.
62
- return 0
63
- elseif rule == 1
64
- " Indent in alignment with end of the string start delimiter.
65
- return a: delim_pos [1 ]
66
- else
67
- " Indent in alignment with string start delimiter.
68
- return a: delim_pos [1 ] - (a: regex ? 2 : 1 )
59
+ let alignment = s: Conf (' clojure_align_multiline_strings' , 0 )
60
+ " -1: Indent along left edge, like traditional Lisps.
61
+ " 0: Indent in alignment with end of the string start delimiter.
62
+ " 1: Indent in alignment with string start delimiter.
63
+ if alignment == -1 | return 0
64
+ elseif alignment == 1 | return a: delim_pos [1 ]
65
+ else | return a: delim_pos [1 ] - (a: regex ? 2 : 1 )
69
66
endif
70
67
else
71
68
return -1 " Keep existing indent.
@@ -131,10 +128,10 @@ function! s:GetClojureIndent()
131
128
if synname = ~? ' string'
132
129
" We already checked this above, so pass through this block.
133
130
elseif synname = ~? ' regex'
134
- call s: CheckPair (' reg ' , ' #\zs"' , ' "' , function (' <SID>NotRegexpDelimiter' ))
131
+ call s: CheckPair (' rex ' , ' #\zs"' , ' "' , function (' <SID>NotRegexpDelimiter' ))
135
132
else
136
133
let IgnoredRegionFn = function (' <SID>IgnoredRegion' )
137
- if bufname () == ? ' \.edn$'
134
+ if bufname () = ~ ? ' \.edn$'
138
135
" If EDN file, check list pair last.
139
136
call s: CheckPair (' map' , ' {' , ' }' , IgnoredRegionFn)
140
137
call s: CheckPair (' vec' , ' \[' , ' \]' , IgnoredRegionFn)
@@ -147,27 +144,15 @@ function! s:GetClojureIndent()
147
144
endif
148
145
endif
149
146
150
- " Find closest matching higher form.
147
+ " Calculate and return indent to use based on the matching form.
151
148
let [formtype, coord] = s: best_match
152
-
153
- if formtype == # ' top'
154
- " At the top level, no indent.
155
- return 0
156
- elseif formtype == # ' lst'
157
- " Inside a list.
158
- return s: GetListIndent (coord)
159
- elseif formtype == # ' vec' || formtype == # ' map'
160
- " Inside a vector, map or set.
161
- return coord[1 ]
162
- elseif formtype == # ' str'
163
- " Inside a string.
164
- return s: GetStringIndent (coord, 0 )
165
- elseif formtype == # ' reg'
166
- " Inside a regular expression.
167
- return s: GetStringIndent (coord, 1 )
168
- else
169
- " Keep existing indent.
170
- return -1
149
+ if formtype == # ' top' | return 0 " At top level, no indent.
150
+ elseif formtype == # ' lst' | return s: GetListIndent (coord)
151
+ elseif formtype == # ' vec' | return coord[1 ] " Vector
152
+ elseif formtype == # ' map' | return coord[1 ] " Map/set
153
+ elseif formtype == # ' str' | return s: GetStringIndent (coord, 0 )
154
+ elseif formtype == # ' rex' | return s: GetStringIndent (coord, 1 )
155
+ else | return -1 " Keep existing indent.
171
156
endif
172
157
endfunction
173
158
0 commit comments