Fork me on GitHub
#calva
<
2021-01-02
>
slipset13:01:53

In Cider I can press C-c C-z (I believe) to jump between the repl and the current source file. Any such thing in Calva?

pez13:01:46

Currently only in one direction (from editor file to repl) , but I added something yesterday that should make the other direction easy to fix. I believe there is an old issue about this on Github, but if not, I’d welcome you to add one. I’ll add it in my last winter-leave Calva time. It is long overdue.

pez18:01:02

Here’s a VSIX build where there is a command for opening a file for the current active repl window namespace. Default binding is ctrl+alt+c o, same as for revealing the output/repl window/file. https://9671-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.145-920-switch-to-editor-for-ns-7996cfb3.vsix

ajoberstar21:01:21

Is there a Calva command for newline inside current form? I'm trying to get something that feels equivalent to the normal Ctrl+Enter behavior of VS Code (add a newline after the current line). For the purposes of Clojure code it would be nice to stay in the current form. So would be something like this:

(let [k1 |v2])
;; Ctrl+Enter at the |
(let [k1 v2
      |])
;; cursor is at pipe

pez21:01:59

Not sure I follow. What should happen?

ajoberstar21:01:46

Right now, it does something like:

(let [k1 |v2])
;; Ctrl+Enter when cursor is at |
(let [k1 v2])
|
;; Cursor goes to start of a newline

ajoberstar21:01:28

Basically, I'm still trying to get the hang of Paredit and was hoping to find some key bindings that can feel more like the commands that are native in VS Code.

ajoberstar21:01:06

I think in Parinfer, I get the behavior I showed in the first snippet, but I've been running into bugs with it, so I was going to give up and try Paredit again.

pez21:01:59

I think I need to first figure out if that first snippet is a before or after picture. 😀 Jokes aside, I need to see what it looks like before and what it looks like after the command is issued.

ajoberstar21:01:07

Sorry, now I see where the confusion is. The first snippet is a before and after. I'll try to break it apart more: Before: (cursor position at |)

(let [k1 |v1])
After: (Ctrl+Enter)
(let [k1 v1
      |])
Cursor is now at |, which is on a new line, but still enclosed in the same form as before.

pez21:01:16

Interesting. I have so many questions. But also an answer, this command does not exist yet. But I think it would be fun to add it. If you want to do it, I’d be happy to assist.

🙏 3
ajoberstar21:01:14

OK, that's good to know. I'll play around more before deciding if I really want something like that or not.

ajoberstar21:01:08

Main issue for me is being used to non-structural editing (and in Clojure using Parinfer before). I'm more used to VS Code's traditional navigation and editing bindings. Default behavior of Calva has thrown me for a loop. But I think it's just something I need to practice more.

ajoberstar22:01:22

So appears the correct sequence to do this OOB is paredit.forwardUpSexp (Ctrl+Alt+Down) then Enter

pez22:01:03

That would result in

(let [k1 v1]
 |)
… I think.Forward to List End/Close (`ctrlt+end`), then enter.

ajoberstar22:01:20

Ah, yes good catch. Thanks again!

pez22:01:49

I think there might be some extension that lets you compose commands and bind to shortcuts.

pez22:01:32

I’m still a bit confused about the “normal” behaviour of ctrl+enter. On my machine that isn’t bound to anything in the editor.

ajoberstar22:01:57

I'm on Windows, which could be the difference

ajoberstar22:01:44

"Insert Line Below" is the command it's bound to

pez22:01:19

Ah, yes, that’s cmd+enter on mac. Never used it, even though o is in my synapses when using Vim. I think your mapping of that to structural is nice. If it wasn’t that we want the evaluation commands to be super accessible, I think it would make total sense to bind like you are thinking there.

ajoberstar22:01:40

Maybe platform differences are part of my troubles. At least from the standpoint of a Windows VS Code user, a lot of the default bindings have surprising behavior to me. e.g. Ctrl+Left/Ctrl+Right are by default move forward/backward by word. Whereas in Calva they default to paredit.barfForward and paredit.slurpForward. I expected navigation rather than editing commands for those shortcuts.

pez22:01:28

Yes, we have been optimising for using the same shortcuts cross-platform, but have started to regret that a bit. And ctrl+left/rightisn’t even very available on Mac… https://calva.io/quirks/#macos-and-the-slurp-and-barf-keyboard-shortcuts

ajoberstar22:01:59

I'm sure bindings are something where you'll never please anyone too. I'm going to keep trying to familiarize myself with the commands and see if I end up finding some bindings that feel more natural for me.

ajoberstar22:01:18

I appreciate the help!

pez22:01:27

I appreciate the feedback and reminder to revisit the current setup for this. VS Code (probably guided by prior art) has decided to differentiate, and I think Calva should probably follow in those steps.

👍 3