Fork me on GitHub
#calva
<
2020-08-12
>
brandon.ringe00:08:35

Hey Calva friends. I've (re)implemented repl command history for the new output/repl window. It works the same as with the old repl window. alt+up to go previous history, alt+down to go next history. These shortcuts are only overidden in the repl window (in normal editors they map to move line up/down). Please give this vsix a spin and let us know if you see any issues. It contains 1 or 2 other changes on dev as well, including @cb.lists's fix for not overriding the default binding for esc. https://7490-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.120-fix-740-allow-default-esc-keybind-feature-add-repl-history-021e2239.vsix

pez11:08:08

Nice! Two things I notice: 1. When I send a form to the repl from another file, it seems to kill the history. 2. alt+up/down completely replaces the move line up down built-in command. I know structural autists frown on me using that a lot, but I do. I think it is cool that we use such an accessible shortcut, but also that it should only work as the history shortcut when the cursor is behind the last form in the file (or the last prompt, if no form has been entered).

brandon.ringe17:08:29

Thanks, I'll look into the history killing issue. Yeah I was considering this with the shortcut, but I thought I remembered discussing before that if this is only the case in the output window then it's not a big deal. I'll see about detecting the position of the cursor when the command is issued, and deferring to the move line commands if not after the last prompt

brandon.ringe17:08:56

Also going to put a note in the output greeting about the history commands

pez19:08:59

I think we can detect cursor position and update a when context in a selectionChanged observer/watcher.

me167613:08:29

Just switched to latest Calva with the new REPL window and itโ€™s quite nice :+1: Had to change some habits, but after a few hours productivity is up again. Thank you @pez!

pez13:08:07

Sounds a bit like a habit you could challenge is using the repl prompt. ๐Ÿ˜ƒ

me167613:08:47

Iโ€™m a bit uncertain what you mean by REPL prompt ๐Ÿ™‚

me167613:08:57

You mean in the old REPL window?

pez13:08:50

The new repl window also has a prompt, right? What I am driving at is Rich comments: https://betweentwoparens.com/rich-comment-blocks#rich-comment

me167613:08:27

Ah yes, it has a prompt. In the old REPL window it behaved more like a prompt because of the arrow keys navigation. The new one behaves more like a file which I like

me167613:08:45

I really like that the REPL window behaves more like a normal file editor now. I can place a cursor at any previous expression and eval it many times in a row. Previously Iโ€™d have to use the arrow keys to go previous expressions, which could be tedious if you want to go even 3 steps back

brandon.ringe17:08:22

Nice to hear people are seeing the benefits! I'm working on adding the history navigation at the prompt back, just as an added feature to what you mention above, because some users really wanted it ๐Ÿ˜„

borkdude14:08:37

How "open source" is VSCode?

agold14:08:02

My understanding is that the editor itself is open source but extensions for remote editing, WSL, Docker, etc., are proprietary.

borkdude14:08:02

Why would they make the remote editing plugin closed source?

borkdude14:08:23

Does clj::proj.core mean: clojure, proj.core namespace? In CLJS you would get cljs::proj.core?

pez14:08:09

the prefix just says which repl you are connected to. In Calva there is only one or two replโ€™s per workspace/window. So in a clj+cljs project you are either connected to the clj repl or to the cljs repl.

borkdude14:08:52

Ajajaj... you can't connect to more REPLs?

borkdude14:08:15

At work I have a multi-repo where I need to be connected to two Clojure REPLs sometimes

borkdude14:08:21

I guess in that I'd just open two Windows?

pez14:08:03

โ€œAjajajโ€ sounds oddly Swedish. Dutch? ๐Ÿ˜ƒ Anyway, yes, there is https://github.com/BetterThanTomorrow/calva/issues/76

borkdude14:08:26

We also say it in Dutch ;)

pez14:08:09

Yeah, two windows. This is written by someone who doesnโ€™t really understand the multirepo concept, but anyway: https://calva.io/workspace-layouts/

pez14:08:16

For me the most pressing need for one more REPL connection is that I want a babashka REPL always handy. ๐Ÿ˜ƒ

brandon.ringe17:08:47

My goal in my application for clojurists together this quarter is to add multi-project/repl support to Calva ๐Ÿ˜„ . Want to add this anyway but the funding will help speed things up.

borkdude14:08:35

Can you change the keybinding of forward slurp? I'd like to keep my mission control keybindings

borkdude14:08:15

Oh I see, that's a VSCode thing, not Calva per se.. duh. Sorry, new to this :)

borkdude14:08:14

Awesome, I now set it to what I'm used to in emacs :) ctrl-)

borkdude14:08:30

Now I hope the SSH remote plugin will be free and around forever (open source fears)

pez14:08:00

There is also Theia, which I think might help in keeping MS taking the right decisions. ๐Ÿ˜ƒ

borkdude15:08:54

Calva doesn't have sort namespaces (like Emacs clojure-mode: clojure-sort-ns)?

pez15:08:45

No. That would be nice. I think @slack1038 had it a branch there a long while ago...

borkdude17:08:18

> ctrl+shift+alt+up Select Backward Down Sexp > ctrl+shift+alt+down Select Forward Up Sexp makes sense right?

borkdude17:08:40

Is it possible to make paredit also work in strings?

borkdude17:08:04

The use case:

(deftest datafy-test
  (prn (tu/bb nil "(require '[clojure.datafy :as d]) (:flags (d/datafy Exception))")))
I'm editing the code inside the string. In emacs forward slurp etc. work.

borkdude18:08:01

Does Calva have completions when connected to an nREPL server? It seems that it doesn't work?

brandon.ringe18:08:28

It should if cider-nrepl is loaded as a dep in that repl

borkdude18:08:55

That might be the problem, I connected to my own REPL. Thanks

borkdude19:08:38

I think I have screwed up a couple of default keybindings. Is there a way to restore them? ;)

pez19:08:13

Doesn't the VS Code GUI for shortcuts have a button for resetting to defaults?

borkdude19:08:30

I haven't noticed it

borkdude19:08:04

Oh I guess when you right click

borkdude19:08:26

I'm such a VSCode n00b ;)

borkdude19:08:07

But guess what. I helped out someone at an online meetup tonight what was trying to evaluate something in the Calva output window.

borkdude19:08:31

I told him: do it from the buffer, ctrl+enter. And it worked. Haha.

pez19:08:03

So awesome!

pez19:08:30

The output window should work the same, though. alt+enter and ctrl+enter. If it didn't, then there is a bug somewhere.

borkdude19:08:51

I think he wasn't used to a recent change or something

borkdude19:08:28

Getting the hang of it. So far my missing features are: undo-tree (which isn't on Calva, but VSCode in general) and structural editing in strings.

borkdude19:08:34

And clojure-sort-ns

pez19:08:59

The new repl was surprisingly disruptive for many.

pez19:08:31

What do you miss about structural editing in strings?

borkdude19:08:57

I tend to edit code samples in strings for sci/babashka tests

borkdude19:08:09

Also the indentation is way off in code that's in strings

pez19:08:39

I see. Calva is deliberately not treating the contents of strings as clojure code.

borkdude19:08:41

Consider this one:

(deftest datafy-test
  (testing "default implementation of datafy works"
    (is (= #{:public} (bb "(require '[clojure.datafy :as d]) (:flags (d/datafy Exception))"))))
  (testing "custom implementation of datafy works"
    (is (= {:number 1} (bb "
(require '[clojure.datafy :as d]
         '[clojure.core.protocols :as p])

(extend-type Number
  p/Datafiable
  (datafy [x]
    {:number x}))

(d/datafy 1)
"))))
  (testing "default implementation of nav works"
    (is (= #{:public} (bb "(require '[clojure.datafy :as d]) (:flags (d/datafy Exception))")))))

borkdude19:08:05

It's not a major issue, just something that happens to work in emacs

pez19:08:18

It could be made something that can be toggled. I really want it to behave like it does. But if I do have a case where I want help with lisp editing inside a string, that would be nice to toggle on.

borkdude19:08:05

Surprisingly when I edit a file in emacs tramp via ssh, it's picked up in the Remote SSH plugin immediately, so missing features I can do in emacs, although it would be nice to have them all in one editor

borkdude19:08:33

> But if I do have a case where I want help with lisp editing inside a string Well, I do that all the time in the tests for babashka and sci.

pez19:08:34

That's pretty awesome.

pez19:08:33

(The emacs thing, not that you don't get help from Calva with your usecase ๐Ÿ˜„)

borkdude19:08:45

Every time I press enter, the indentation is fucked.

borkdude19:08:16

I see, it wants to indent the entire string according to the first quote's indentation. This is not what emacs does, so now I'm stuck between two different modes ;)

pez19:08:34

Could it be something that cljfmt can be configured to do differently?

pez19:08:19

It looks super funky in your gif there. Might be a bug in Calva as well.

borkdude20:08:31

Overall, so far so good! Thanks for the amazing Calva.

glebovmaksim07:08:01

Works nice for me :+1: