Clojure & LazyVim - formatting
Recently tried to shift my main code editor from Emacs Prelude to LazyVim. And the vote is still out.
Of course it takes a while to get used to the keybindings. I expected that. But what I didn't expect was the huge difference in Clojure development experience, moving from the excellent CIDER (by Github user bbatsov) which does more or less everything you need, to a lot of disparate plugins that has to be configured manually.
I couldn't find out how to make formatting work as with other languages. When conform.nvim is enabled for a language, it usually auto-formats when saving, or you can trigger it explicitly by cf.
First of all, as a (Lazy)Vim noob, it's a bit hard to found out how to enable conform for Clojure. I found the general trick described in the LazyVim book, here: https://lazyvim-ambitious-devs.phillips.codes/course/chapter-10/#_formatting
But then I found out that prettier - one of the mostly used formatters for NeoVim (it seems), doesn't support Clojure.
For the fun of it I tried to simply install the command line tool cljfmt, on (Om)Arch(y) via the package cljfmt-bin, and asked conform.nvim to use cljfmt. And BOOM, it worked!
Here's my plugin, which I called formatters.lua:
return { "stevearc/conform.nvim", opts = { formatters_by_ft = { ["markdown"] = { "prettier" }, ["clojure"] = { "cljfmt" }, ["json"] = { "prettier" }, ["javascript"] = { "prettier" }, ["css"] = { "prettier" }, }, }, }