Fork me on GitHub
#calva
<
2022-11-04
>
Tom H.12:11:22

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:

🧵 1
pez15:11:04

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.

pez15:11:22

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.

pez15:11:21

As for the Parinfer extension: Yes, it is much more limited than the implementation in Cursive. I think it is rather unmaintained as well.

Tom H.02:11:03

(moved into thread from main channel) … and I press enter, I end up like this:

Tom H.02:11:31

while in vscode I’ll end up like this:

Tom H.02:11:50

another difference is if I’m in this position in vscode:

Tom H.02:11:13

and I press space then it breaks up the map like so (in intellij it moves the whole map to the right):

Tom H.02:11:29

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?

Tom H.02:11:42

the latter is rather annoying as it means I’m not able to comment out the form with a reader comment:

Tom H.02:11:10

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

pez13:11:26

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.

❤️ 1
Tom H.12:11:02

(moved images into thread above)

🙏 1
wevrem13:11:51

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?

🧵 2
skylize15:11:43

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.

skylize15:11:43

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.

wevrem15:11:27

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.

skylize16:11:58

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.

pez16:11:37

The VIM extension is known to compete with Calva about indentation.

wevrem16:11:22

@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.

Tom H.02:11:11

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 😄

pez08:11:24

Parinfer is very hard to get to work properly in VS Code.

Tom H.09:11:23

Ahh that's a shame. I'll definitely take your word for it 😄

pez10:11:57

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&amp;t=nPMKbexjHRkqqiV08lShdA

❤️ 1
Tom H.11:11:35

Oh wow I remember that thread from last year!

pez11:11:09

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.

Tom H.11:11:02

Oh damn 😵

Annaia Danvers14:11:01

Are you using Parinfer with Calva? Because they do not get along and can break in many splendiferous ways.

🧵 1
Tom H.02:11:14

yes, and vim too! If I do migrate to calva I’ll see if I can help fix some of the issues

Annaia Danvers16:11:56

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.

Stuart17:11:43

Is it possible to evaluate some code with ctrl+enter and then have it automagically copy the result to the clipboard, ?

Stuart17:11:32

Is their an existing keyboard shortcut I don't know about? If not, is this something maybe joyride could help with ?

djblue17:11:02

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.

skylize19:11:49

Chord Ctrl-Alt-C Ctrl-C will Calva: Copy Last Evaluation Result to Clipboard

Stuart19:11:43

Thank you!

pez23:11:03

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. 😃

Stuart00:11:55

just in case anyone else see's this. The actual chord is CTRL-ALT-C CTRL-C , at least on my machine, so maybe others too.

skylize00:11:03

Whoops. You're right. Edited the original to avoid any additional confusion. (Part of why I make sure to always give the command name instead of just telling someone a shortcut, and hoping it works for them.)