Skip to content

cljfmt-compatible indenting for some forms #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/clojure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
11 changes: 11 additions & 0 deletions indent/clojure.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
"
Expand Down