Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.49 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.49 KB

This plugin provides a GetCljfmtIndent global function that can be used in an indentexpr to help keep things indented according to your cljfmt rules as you work.

It's intended to be 'as good as possible,' but won't be perfect. Use it along-side clojure-lsp's formatting, with the latter having the final say.

Setup

Put this in your Lazy dependency map (or the equivalent for other package managers).

{'raystubbs/nvim-cljfmt-indents',
 config = function()
   require('nvim-cljfmt-indents').setup()
 end
}

Do something like this, to enable it in Clojure buffers.

vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, {
  pattern = { "*.clj", "*.cljs", "*.cljc", "*.edn" },
  callback = function(args)
    vim.o.indentexpr = "GetCljfmtIndent()"
  end 
})

Warning

Relies on the clojure tree-sitter grammer, so make sure that's installed.

Config

By default the plugin will look in the cwd and parent directories for either a .lsp/config.edn with cljfmt config, or a cljfmt.edn, or a .cljfmt.edn file.

The cljfmt config can also be given explicitly as a table or path to the config file, by setting the cljfmt option:

require('nvim-cljfmt-indents').setup {
  cljfmt = "./cljfmt.edn"
}

require('nvim-cljfmt-indents').setup {
  cljfmt = {
   [":indents"] = {
     "foo" = {{':inner' 0}}
   }
  }
}

Warning

Haven't tested this very thoroughly at all yet. There are bound to be many bugs. But so far works pretty well. Use at your own risk.