Skip to content

Commit 72c1aeb

Browse files
authored
Add option for cljfmt-compatible indenting for some forms (#23)
Resolves: #22
1 parent fd280e3 commit 72c1aeb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: doc/clojure.txt

+8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ clojure-mode.el:
113113
baz)
114114
<
115115

116+
*g:clojure_cljfmt_compat*
117+
118+
Try to be (more) compatible with `cljfmt` Clojure code formatting tool. Turns
119+
on single space indenting for forms starting with `:keywords`, `'symbols`,
120+
`#'variables` and `@dereferences` (it affects, for instance, `(:require ...)`
121+
clause in Clojure `ns` form).
122+
123+
116124
CLOJURE *ft-clojure-syntax*
117125

118126
*g:clojure_syntax_keywords*

Diff for: indent/clojure.vim

+11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ if exists("*searchpairpos")
5151
let g:clojure_align_subforms = 0
5252
endif
5353

54+
if !exists('g:clojure_cljfmt_compat')
55+
let g:clojure_cljfmt_compat = 0
56+
endif
57+
5458
function! s:syn_id_name()
5559
return synIDattr(synID(line("."), col("."), 0), "name")
5660
endfunction
@@ -322,9 +326,16 @@ if exists("*searchpairpos")
322326
return [paren[0], paren[1] + (g:clojure_align_subforms ? 0 : &shiftwidth - 1)]
323327
elseif w[1] == '_'
324328
return paren
329+
elseif w[1] == "'" && g:clojure_cljfmt_compat
330+
return paren
325331
endif
326332
endif
327333

334+
" Paren indent for keywords, symbols and derefs
335+
if g:clojure_cljfmt_compat && w[0] =~# "[:@']"
336+
return paren
337+
endif
338+
328339
" Test words without namespace qualifiers and leading reader macro
329340
" metacharacters.
330341
"

0 commit comments

Comments
 (0)