Hey team! Quick question: what plugin do ya’ll use to autoformat your code? (Playing around with conjure and neovim now!)
I'd like to know that too. Having recently used HIndent for haskell and trying prettier for js, it kinda is a dream not to have to worry about format. Let the machine do the work.
I use parinfer-rust and clojure-vim/clojure
our team is using cljfmt, through calva and vim-iced
But it is not hard to setup without a plugin:
* in vimrc nmap <leader>f :!clj -M:cljfmt %<CR>
* in deps.edn {:aliases {:cljfmt {:extra-deps {cljfmt/cljfmt {:mvn/version "0.7.0"}} :main-opts ["-m" "cljfmt.main" "fix"]}}}
turns out nrepl has format middleware that uses cljfmt, maybe it can be used in conjure https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/format.clj ?
I want to add support for the newer nREPL 0.8 operations + refactor/debug/format tools in CIDER (when they're present) but time. If anyone wants to have a go at contributing these things (wouldn't be too hard for some of them!) I'd be happy to review / guide / carry PRs across the line
There's a LOT of untapped power in CIDER right now, low hanging fruit in some cases. Although things like a stepping debugger (anything stateful) will require some UI / UX work that I'll try to handle since I have a bigger view of the system.
Formatting should be a case of
* extract form under cursor
* send off to CIDER
* replace form range with result
All of which have prior art in Conjure and Fennel modules / functions dedicated to performing this extraction / replacement in a buffer. It's how <prefix>e!
works after all.
I actually format data sometimes by just running <prefix>e!
on it since the source data gets replaced by a pretty printed version
My personal motivation for formatting is quite low since I've never relied on one for Clojure in years of professional development with it. No single formatting tool ever sat with me as "perfect", but I know for some teams it's a great thing to have as common ground. Not opposed to the idea, just not super driven to solve it right now, personally. Just some context 🙂
If there's no relevant issue on the repo, feel free to open one so we have something to track
Thanks for the deep responses team! I solved this for now, by using coc + clojure-lsp alongside conjure. Will look around gh and make an issue that notes the conversation above, as a someday/maybe.