From eb0463ebfc529540485776b5480d081889b7b9ac Mon Sep 17 00:00:00 2001 From: Alex Vear Date: Thu, 27 Apr 2023 14:16:44 +0100 Subject: [PATCH] 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. --- indent/clojure.vim | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/indent/clojure.vim b/indent/clojure.vim index 0ff9031..188a955 100644 --- a/indent/clojure.vim +++ b/indent/clojure.vim @@ -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 @@ -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