BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.63k stars 213 forks source link

Function arguments alignment breaks with namespace and capitals #2625

Open vsironja-enghouse opened 2 days ago

vsironja-enghouse commented 2 days ago

Hello, first things first: thanks for great work! Second, I found an alignment issue in special case when using namespaces and a function name containing only capitals:

;; good
(foo aaaaaaa
     bbbbb
     ccccccc)

;; good
(foo2/get "/status"
          (boo 1))

;; bad
(foo2/GET "/status"
  (boo 1))

We're talking about: Function Arguments Alignment

Running Windows Visual Code 1.92.2 with Calva v2.0.472

Thanks Vlado

PEZ commented 22 hours ago

Hi! Thanks for the encouragement! We love to provide! ❤️

This is not alignment breaking, it is alignment working. 😄

cljfmt (which Calva uses for formatting, and to some extent for indenting) has default indent configuration which includes Compojure symbols, like GET:

https://github.com/weavejester/cljfmt/blob/d750bc149b447f24d9cb562cfeceacfaf45b44e0/cljfmt/resources/cljfmt/indents/compojure.clj#L3

It specifies that the arguments should not “hang”. The reason the arguments to foo and get (including foo2/get) hang is that they do not have default configuration and thus use the default indent rules.

I hope that makes sense?

vsironja-enghouse commented 21 hours ago

Hello! Thanks for the clarification, I understand only some special keywords are handled differently. I don't really have opinions on formatting, yet it's always an element of surprise when sexp root get, GET and XGET align differently. Also, I wouldn't even notice, but we're maintaining code written in Emacs/Cider and IntelliJ, which of course don't have this special treatment and I always break the diffs when saving. Anyhow, thanks and keep up the excellent work and if by any chance possible, please do make it configurable. Bye! :) Vlado

PEZ commented 17 hours ago

if by any chance possible, please do make it configurable

Calva only uses cljfmt, so you can't configure to use some other formatter, really. But cljfmt is highly configurable, and Calva gives you access to this. See https://calva.io/formatting/#configuration for the Calva side of things. That page has links to the documentation for cljfmt's config.

vsironja-enghouse commented 9 hours ago

Cool, I'll look into that, thanks a lot, please close the issue. Bye