Skip to content

Commit

Permalink
When clojure_align_multiline_strings is -1, no indentation
Browse files Browse the repository at this point in the history
By setting the `clojure_align_multiline_strings` option to `-1` it will
switch to traditional Lisp multi-line string indentation, of no indent.
  • Loading branch information
axvr committed Apr 27, 2023
1 parent c3047be commit eb0463e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions indent/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ function! s:Conf(opt, default)
endfunction

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

Expand Down Expand Up @@ -118,10 +120,17 @@ function! s:GetClojureIndent()
if m ==# 'i' || (m ==# 'n' && ! (v:operator ==# '=' && state() =~# 'o'))
" If in insert mode, or (in normal mode and last
" operator is not "=" and is not currently active.
let l:indent = (s:ShouldAlignMultiLineStrings()
\ ? 0
\ : (formtype ==# 'reg' ? 2 : 1))
return coord[1] - l:indent
let rule = s:ShouldAlignMultiLineStrings()
if rule == -1
" No indent.
return 0
elseif rule == 1
" Align with start of delimiter.
return coord[1]
else
" Align with end of delimiter.
return coord[1] - (formtype ==# 'reg' ? 2 : 1)
endif
endif
endif

Expand Down

0 comments on commit eb0463e

Please sign in to comment.