vim

Chase 2024-11-07T20:59:40.448119Z

I'm throwing out my annual (quarterly?) ask if anyone has satisfactorily found a great solution to autoformatting map and let bindings so that the value sides are lined up. I'm using neovim, parinfer, conjure, and clojure-lsp (which I believe uses cljfmt for formatting) if that helps or hurts the cause.

❤️ 1
ericdallo 2024-11-07T21:02:19.292269Z

I wanna tackle this in clojure-lsp in the next months, probably having other format options besides cljfmt like zprint which should support this, so I hope next quarter you won't need to ask this question hehe

👍 1
Chase 2024-11-07T21:02:39.601639Z

Amazing!

ericdallo 2024-11-07T21:03:26.408589Z

the problem is that cljfmt has https://github.com/weavejester/cljfmt/issues/36 opened for the past 7 years

Chase 2024-11-07T21:04:28.486549Z

I wonder if: https://github.com/oakmac/standard-clojure-style-js will be a possible alternative too. That's a new player in the field (he gave a talk at the Conj this year)

2024-11-07T21:05:55.284239Z

I asked Chris about aligning map/let values at the conj, but he said he wasn't going to, as a design choice

ericdallo 2024-11-07T21:06:43.800929Z

yeah, I intend to ponder all those alternatives. Vertical alignment is really something personal, but the main issue for me is not having a way to tell clojure-lsp (and formatters) to follow standard A or B

emilaasa 2024-11-08T20:02:10.332949Z

Four years ago when you asked this, someone recommended https://github.com/junegunn/vim-easy-align and I still use that 🙂

👍 1
emilaasa 2024-11-08T20:02:40.664999Z

Maybe it's not "auto" enough

Chase 2024-11-09T00:45:24.739409Z

I do remember that @emilaasa! Do you mind sharing the specific keyboard shortcuts, if any, that you set up? Or are you using a vanilla command?

Chase 2025-02-08T15:32:58.252109Z

I realized the answer was under our noses the whole time and was hinted at in this very thread. zprint! It can already do what I've wanted this whole time. It has some opinionated defaults that I can't use (automatically sorts maps and puts commas after kv pairs, etc.) that would absolutely wreck the git diffs in my company's repos (we use cljfmt there). The level of customization seems quite thorough and intimidating (the reference page is like 175 pages) but this convo (https://github.com/kkinnear/zprint/issues/196) and my own tweaking has led to this simple .zprintrc so far:

{:width   120
 :style   :respect-nl
 :binding {:justify? true}
 :map     {:justify? true
           :comma?   false}
 :pair    {:justify? true}}
in neovim I just have this keybinding to run it on the current Clojure file:
{'n', 'f', ':!zprint -w %'}
so adjust accordingly. Hopefully as others adopt it we can help each other tweak it more. What I'm basically looking for is solely aligning up let bindings and hashmaps as my company already does this (a lot of emacs users) themselves so that shouldn't alter any files. I basically really want to make sure I'm not creating any extraneous git diffs when running this thing if anyone has further advice on how to change my config to only support this bare minimum functionality.

🙌 2
🎉 1
ericdallo 2025-02-10T12:55:34.433839Z

zprint support in clojure-lsp is something I'll look soon to support

Chase 2024-11-10T20:26:02.220769Z

This was my attempt:

nmap ea (EasyAlign)i{
nmap eA (EasyAlign)i[
but it only works in the easiest hashmap examples. The second one for let bindings doesn't work at all. The hashmap one doesn't work if the map is nested in any way

Nundrum 2025-04-14T15:42:43.381849Z

Thanks for sharing that!