diff --git a/doc/clojure.txt b/doc/clojure.txt index eb3566a..1bd6018 100644 --- a/doc/clojure.txt +++ b/doc/clojure.txt @@ -113,6 +113,14 @@ clojure-mode.el: baz) < + *g:clojure_cljfmt_compat* + +Try to be (more) compatible with `cljfmt` Clojure code formatting tool. Turns +on single space indenting for forms starting with `:keywords`, `'symbols`, +`#'variables` and `@dereferences` (it affects, for instance, `(:require ...)` +clause in Clojure `ns` form). + + CLOJURE *ft-clojure-syntax* *g:clojure_syntax_keywords* diff --git a/indent/clojure.vim b/indent/clojure.vim index efe4e4d..dcbef55 100644 --- a/indent/clojure.vim +++ b/indent/clojure.vim @@ -51,6 +51,10 @@ if exists("*searchpairpos") let g:clojure_align_subforms = 0 endif + if !exists('g:clojure_cljfmt_compat') + let g:clojure_cljfmt_compat = 0 + endif + function! s:syn_id_name() return synIDattr(synID(line("."), col("."), 0), "name") endfunction @@ -322,9 +326,16 @@ if exists("*searchpairpos") return [paren[0], paren[1] + (g:clojure_align_subforms ? 0 : &shiftwidth - 1)] elseif w[1] == '_' return paren + elseif w[1] == "'" && g:clojure_cljfmt_compat + return paren endif endif + " Paren indent for keywords, symbols and derefs + if g:clojure_cljfmt_compat && w[0] =~# "[:@']" + return paren + endif + " Test words without namespace qualifiers and leading reader macro " metacharacters. "