This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-25
Channels
- # announcements (8)
- # babashka (58)
- # beginners (59)
- # biff (4)
- # calva (39)
- # cider (2)
- # clj-kondo (8)
- # clj-together (4)
- # cljdoc (5)
- # cljsrn (1)
- # clojure (60)
- # clojure-australia (2)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojurescript (13)
- # conjure (10)
- # cursive (9)
- # datomic (5)
- # dev-tooling (1)
- # emacs (6)
- # events (1)
- # graalvm (38)
- # graphql (5)
- # joyride (1)
- # kaocha (3)
- # lsp (23)
- # malli (2)
- # mount (2)
- # off-topic (31)
- # other-languages (13)
- # pathom (3)
- # polylith (12)
- # portal (4)
- # practicalli (22)
- # re-frame (6)
- # reagent (3)
- # releases (3)
- # sql (4)
- # squint (3)
- # tools-build (10)
- # tools-deps (10)
- # xtdb (4)
Weird formatting behavior with defprotocol
when docstrings are on a separate line from method name. I don't know whether it's worth worrying about. But it feels janky (and unpredictable until putting a lot of thought into understanding it). 🧵
• While typing, the docstring aligns with the parameters.
• If the cursor is anywhere within the parentheses that wrap the method definition, then calva-fmt.formatCurrentForm
follows the same rule, and aligns the docsctring to the params.
• This only applies to the method expression the cursor is inside of. Move the cursor inside a different method expression, and run calva-fmt.formatCurrentForm
to also format that form as described above, not effecting alignment of any other method.
• Move the cursor to where it is outside of any method expression and run calva-fmt.formatCurrentForm
and a different rule takes over. All the docstrings align to the second character of the respective method name.
• Same with other format-triggering events (such as paredit.dragSexpForward
). So long as the cursor is not within an expression defining a method, all the docstrings align to a +2 character indentation.
; | for cursor
(defprotocol Foo
(method [_] |"docstring"))
; <Enter>
(defprotocol Foo
(method [_]
|"docstring"))
; <calva-fmt.formatCurrentForm>
(defprotocol Foo
(method [_]
|"docstring"))
; <move cursor>
(defprotocol Foo
|(method [_]
"docstring"))
; <calva-fmt.formatCurrentForm>
(defprotocol Foo
|(method [_]
"docstring"))
; <move cursor>
(defprotocol Foo
(|method [_]
"docstring"))
; <calva-fmt.formatCurrentForm>
(defprotocol Foo
(|method [_]
"docstring"))
I wonder if maybe formatCurrentForm doesn’t have knowledge that the “current form” is inside a defprotocol
form when the cursor is inside the method form…
An issue is welcome. @U0ETXRFEW might have an idea what’s going on.
With calva, I have something like
[:div {:style {:color "red"}} [:span ;; resumes below
And I want to make it so it's
[:div {:style {:color "red"}}
[:span ;; resumes below
When I just hit enter, I get
[:div {:style {:color "red"}}]
[:span ;; resumes below
Which seriously screws up the rest of the brackets down the line and does crazy things. how do I get the result I want?What happens if you press tab? You might need to go to a level above but it usually fixes all indentation issues.
It already changes the brackets so that it becomes a top level form, TAB doesn't fix it
Never seen this. Which versions of VS Code and Calva are you using, @U24MDANHY? Can you reproduce it in all files, or is it only in some?
It happened to me every single time for every clojure file I ever cared to open/edit
vscode 1.73.1 on ubuntu Not sure how to see the calva version (thanks vscode) - but it's supposedly the latest in the vscode store or whatever, I haven't held it back or anything, and it doesn't tell me to update it
disabled, but it does tell me it's (Modified elsewhere)
and when I hover it tells me that Clojure has different defaults
Calva reports it version in the Output pane Calva says. Also Clicking the Calva entry in the Extensions pane should show it.
Calva version used: v2.0.320
clojure-lsp version used: 2022.11.03-00.14.57
clj-kondo version used: 2022.11.02
Enabled, still not working
Hold on, posting a screencast
Well, Peek segfaults so no screencast for us 😞
I don't, but I do use a nontrivial amount of extension, it's not impossible that there's a collision of some sort
Prettier is disabled on cljs files
Please file an issue using VS Code's Help-menu item for it. It will attach some system information and such.
> It already changes the brackets so that it becomes a top level form, TAB doesn't fix it This is a clue I think. I have never seen Calva do this, and am thinking it could be some other extension at work. Could of course also be a Calva bug.
It should be noted that I have "Parinfer </> Smart" mode enabled, it might have something to do with it
Yeah, in paren mode it works
So it's an issue with that extension. There's a #C0F2A0MJN channel where you can ask about it.
I should really get more into paredit and put parinfer behind 😢 - but it's too different from what I know and it's a lot of things to learn at once 😅
The issue is very unlikely to be fixed anytime soon. No-one knows how to implement Parinfer smartmode on VS Code. I have been the closest, I think, but had some other problems with that so had to pause that work.
:saluting_face: Thank you for your work, just being able to properly edit clojure in vscode makes it so much more accessible ❤️
You are welcome, @U24MDANHY! ❤️
Here's another event that might interest Calva friends: https://www.meetup.com/london-clojurians/events/286030325/
