Skip to content

Commit eb0463e

Browse files
committed
When clojure_align_multiline_strings is -1, no indentation
By setting the `clojure_align_multiline_strings` option to `-1` it will switch to traditional Lisp multi-line string indentation, of no indent.
1 parent c3047be commit eb0463e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

indent/clojure.vim

+15-6
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ function! s:Conf(opt, default)
4646
endfunction
4747

4848
function! s:ShouldAlignMultiLineStrings()
49-
" TODO: third option "-1" to default to "no indent", like traditional
50-
" lisps?
49+
" Possible Values: (default is 0)
50+
" -1: Indent of 0, along left edge, like traditional Lisps.
51+
" 0: Indent in alignment with string start delimiter.
52+
" 1: Indent in alignment with end of the string start delimiter.
5153
return s:Conf('clojure_align_multiline_strings', 0)
5254
endfunction
5355

@@ -118,10 +120,17 @@ function! s:GetClojureIndent()
118120
if m ==# 'i' || (m ==# 'n' && ! (v:operator ==# '=' && state() =~# 'o'))
119121
" If in insert mode, or (in normal mode and last
120122
" operator is not "=" and is not currently active.
121-
let l:indent = (s:ShouldAlignMultiLineStrings()
122-
\ ? 0
123-
\ : (formtype ==# 'reg' ? 2 : 1))
124-
return coord[1] - l:indent
123+
let rule = s:ShouldAlignMultiLineStrings()
124+
if rule == -1
125+
" No indent.
126+
return 0
127+
elseif rule == 1
128+
" Align with start of delimiter.
129+
return coord[1]
130+
else
131+
" Align with end of delimiter.
132+
return coord[1] - (formtype ==# 'reg' ? 2 : 1)
133+
endif
125134
endif
126135
endif
127136

0 commit comments

Comments
 (0)