This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-04
Channels
- # announcements (30)
- # aws (7)
- # babashka (7)
- # beginners (64)
- # calva (39)
- # cherry (17)
- # cider (1)
- # clj-on-windows (6)
- # clojure (30)
- # clojure-austin (12)
- # clojure-europe (25)
- # clojure-nl (2)
- # clojure-norway (23)
- # clojure-spec (23)
- # clojure-uk (6)
- # clojurescript (20)
- # cursive (18)
- # datahike (3)
- # datalevin (12)
- # datomic (9)
- # etaoin (5)
- # graalvm (45)
- # instaparse (2)
- # interceptors (11)
- # kaocha (1)
- # lsp (102)
- # meander (6)
- # nbb (16)
- # off-topic (30)
- # pathom (83)
- # pedestal (6)
- # portal (5)
- # re-frame (12)
- # reitit (5)
- # rewrite-clj (10)
- # scittle (35)
- # shadow-cljs (49)
- # spacemacs (10)
- # vim (14)
Hi folks, this might be more of a #parinfer question but I’m looking at swapping from cursive to calva and I’ve run into some issues with the way the enter key is handled. I’m using parinfer + vim mode in both editors. In IntelliJ if I’m in this position:
I think the misindentation on enter here is due to VIM doing something after Calva has indented the line. You should be able to confirm this by trying with the VIM extension disabled.
If that is the case, I think some people have had some luck with disabling the Use new indent engine Calva setting. The old indent engine is slower so VIM does its thing first.
As for the Parinfer extension: Yes, it is much more limited than the implementation in Cursive. I think it is rather unmaintained as well.
and I press space then it breaks up the map like so (in intellij it moves the whole map to the right):
is there a way to control these kinds of behaviours or is it just a difference in how parinfer is implemented in intellij vs vscode?
the latter is rather annoying as it means I’m not able to comment out the form with a reader comment:
thanks @U0ETXRFEW, I’ll give that a go. If I do end up migrating to calva I’ll see if I can help with parinfer, I’m a big fan
Latest Calva, v2.0.317 might have fixed the issue with the cursor position fight between Calva and the VIM extension. At least in my testing Calva now wins.
I’ve never seen that behavior before. I just tried it (with the latest version and everything) and it worked exactly as one would expect. (Except if you hit space before a map, it doesn’t automatically indent the lines below, you have to move down to them and hit TAB to re-format things.) I’ve never seen Calva break up a map like that. I would guess that something is not right with your setup. Or maybe you have other stuff that is somehow competing with Calva to format your code?
You should not need to "move down" for that. Just hit space
, and then tab
to trigger format.
Auto-formatting is less aggressive "as you type" in certain cases, but you can manually trigger Format Current Form
at any time, with the default shortcut being tab
.
I have noticed there are a few cases (which I should probably pay more attention so I can report it) where I need to press Tab
twice, because the first time, it only formats the current line.
Yeah, hitting TAB doesn’t always do what I think unless I’m on the right line. In the OP example, hitting a space here: [|{
gives you [ |{
but if you hit TAB, at least for me, it doesn’t indent the rest of the dictionary on following lines, instead it removes the space I just typed.
In that case, tab
won't indent the rest of the dictionary from any other line either. The cljfmt rule :remove-surrounding-whitespace?
collapses the whitespace at the start of the containing vector, and then all the entries line up to that.
I strongly suspect you would get the behavior you describe if you configured cljfmt
to disable that rule. I guess its up to you if that would be worth it; that is why it's configurable.
@U90R0EPHA that’s not what I see. When I start with this (something similar to OP) and hit space:
[|{:a 1
:b 2}]
then I end up with this:
[ |{:a 1
:b 2}]
The space moves the first line over (of course) but the second line remains unchanged. I have to move my cursor down to that line and hit tab to get :b 2
to scoot over. Which I’m fine to do. It’s always worked that way so I never even considered it an issue.After playing around some more I can see how vim, parinfer and calva are fighting each other, if I can find some time I’ll see if there’s any changes I might be able to make that get them playing nicely 😄
I am not the only one having given it a try, but I certainly have. This is from when I thought I was still going to succeed: https://twitter.com/pappapez/status/1461018167002734592?s=46&t=nPMKbexjHRkqqiV08lShdA
After that I spent almost a month more and had to eventually give up. 😞 . Though, tbh, I think I was quite close to pulling it off, I just ran out of stamina.
Are you using Parinfer with Calva? Because they do not get along and can break in many splendiferous ways.
yes, and vim too! If I do migrate to calva I’ll see if I can help fix some of the issues
Yeh there was an attempt to get it working at last but apparently it broke and had to be reverted. It's my one complaint about it; I got spoiled by Parinfer and it's been rough to adjust without it 'cause my brain never could retain Paredit bindings.
Is it possible to evaluate some code with ctrl+enter and then have it automagically copy the result to the clipboard, ?
Is their an existing keyboard shortcut I don't know about? If not, is this something maybe joyride could help with ?
If calva or joyride don't support this, you could try nrepl middleware. Forking something like https://github.com/djblue/portal/blob/master/src/portal/nrepl.clj#L90-L109 would work. Or you could use it directly and setup a tap handler that copies the tap'd value to the clipboard.
There is some problem with this approach with copying the last evaluated results. I don't recall what it was. I ran into it some weeks ago when I didn't have time to report it, much less investigate. Then I forgot about it...
Anyway, what the command does is to evaluate *1
and copies that result to the clipboard. Maybe someone with a more rested brain than I have right now can see what the problem with this could be. 😃