Skip to content

raystubbs/nvim-cljfmt-indents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

Cljfmt based indentation function for NeoVim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages