This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-13
Channels
- # announcements (12)
- # babashka (88)
- # beginners (60)
- # biff (10)
- # calva (56)
- # clerk (9)
- # clj-kondo (5)
- # clojure (70)
- # clojure-austin (3)
- # clojure-conj (2)
- # clojure-dev (69)
- # clojure-europe (53)
- # clojure-nl (1)
- # clojure-norway (28)
- # clojure-uk (1)
- # clojurescript (27)
- # copenhagen-clojurians (3)
- # cursive (10)
- # datascript (1)
- # datomic (10)
- # fulcro (3)
- # funcool (1)
- # garden (7)
- # helix (5)
- # holy-lambda (5)
- # hyperfiddle (39)
- # introduce-yourself (6)
- # jobs-discuss (15)
- # lsp (3)
- # malli (5)
- # membrane (19)
- # missionary (1)
- # nrepl (6)
- # off-topic (44)
- # pathom (17)
- # pomegranate (3)
- # react (7)
- # releases (1)
- # shadow-cljs (39)
- # tools-deps (16)
- # xtdb (28)
OT, TIL (Because I searched for it in the Command Palette). You can compare the content of two editors in VS Code even if they are untitled (VS Code lingo for editor with no filesystem representation). Say you have two chunks of text of something and want to see the diff: 1. Open a new editor (`cmd+n`) 2. Paste chunk 1. 3. Open another new editor. 4. Paste chunk 2. 5. In the Command Palette search and select File: Compare Active File with... 6. A menu of open editors opens. Select the other chunk. 7. 🎉
Does anyone know what causes Calva and NeoVim not to play well? It seems like there’s an interference between the killing functions and whatever is killed does not get properly copied to the clipboard (even when that setting is turned off).
You’ll need to describe a bit more what you do, what you expect and what happens. Assume we know nothing about Neovim. (A correct assumption in my case.)
If simply call “Paredit: Kill Sexp Forward” from the command palette the resulting kill does not get copied to my clipboard.
I don’t think this is necessarily a problem with Calva. I was more or less looking to see if anyone has found a solution to this kind of problem.
neovim is a separate editor right? is there also a vim emulation layer in vs code named neovim?
IIRC you need to integrate the system clipboard with the Vim registers. I’ll have a look in a second (I mainly use the vim keybindings so is haven’t ran into this issue)
@U7PBP4UVA Thanks. I’ll look that up!
Yeah. I am currently in the process of writing a thin wrapper around vim-sexp
as an alternative to the built-in paredit.
I ended up writing most of paredit in lua using the treesitter extension. The cool thing is that it applies to more than just Clojure. I’ve tried it out on Lua and VimL too. https://gist.github.com/noprompt/176883f76e7051909a16438c357438dd
That’s awesome! I don’t understand why it’s necessary, but it’s way cool, and nice to have it outside Clojure. PR to Calva’s docs welcome.
@U0ETXRFEW Its necessary because Calva's paredit doesn't play well with neovim. Undo u
has issues restoring the previous structure/cursor position, and killing to pasteboard requires extra configuration. Additionally, this can use treesitter/vim for formatting.
I think investing in treesitter is a good idea and I hope VS Code adds natives support for it like Vim/Emacs. What I'm considering now is building a small rewriting language on top of treesitter and then compile that to Lua, elisp, etc. such that operations can be built symbolically and in a language agnostic way.
Does this work with the neovim plugin in insert mode? I’ve found for some reason I use paredit mainly in insert mode.
@U7PBP4UVA I don’t see why not. FYI, its still a work in progress.
There are a couple bugs, formatting is janky, and there are missing features. I’d say this needs to bake for a few months.
So i know this is an old thread. but when using neovim plugin. with calva i lost the ability to move between window splits ctrl-h
or even create them ctrl-v ctrl-s. how can i have that back?
Aha, I wondered why that other post was deleted while I was commenting. 😃 Great to hear that it works! Let’s hope it stays working.
Another question I have is about Cider :style/indent
meta: is there a way to get the Calva formatter to use it? https://docs.cider.mx/cider/indent_spec.html
Calva uses cljfmt. So it is cljfmt can support it, then I think Calva could. I remember discussions about this some years ago, but don’t know if support was ever added.
So this might be a case where I could use joyride to ditch cljfmt and do my own formatting or something, right?
I don’t think Joyride is necessary or sufficient. It’s interpreted. I think you need more performance for a task like formatting.
Hi! Is there a way to evaluate a form in the buffer and have it recursively evaluate identifiers that form refers to? (Eg. in the situation where you redefined a function and didn't evaluate it yet)
No. It's a good habit to eval top-level form every time you change code (you don't even need to save the file) so that your REPL always stays up-to-date...
I see. I was thinking this would be nice in case I forget, but I'm sure it's no problem to get in the habit of evaluating after any change. Thank you!
Calva shows a green bar in the right gutter for each top-level form you eval.
(and a green highlight over the code too)
But it doesn’t stick when you edit the file. At the time when I added those decorations I didn’t know how to make them stick reliably. But I think I do today. Not sure I would solve the need to see what has been evaluate that way, but the same strategy could be used to visualize it in others ways.
i use inf-clojure but i have a handy keybinding to require :reload
the current namespace. and then i can put forms into a key so i can easily send that form to the repl. has been a great workflow
If you edit the file, you might invalid the section that was previously eval'd so I think the current behavior is fine, TBH.
There are lots of eval options so you can pick the command most suitable to the changes you made or the behavior you need. ctrl+alt+shift+enter
is a good option to ensure everything in a namespace up to the current top-level form is eval'd / up-to-date (e.g., if you edited a function in a way that LSP decided to auto-insert some new requires for you, you might want to eval a bunch of code above the fn being edited).
I remember someone posted a snippet they use with Joyride to eval the ns
form in the current file and jump the cursor back to the current position, which is also a tempting option...
You don't need to jump away with the cursor. The Calva API docs might be a bit unclear about it, but you can give the ranges
commands an editor and a position. So this Joyride code evaluates the first form in the current document, using the current REPL connection:
(require '["$v0" :as calva])
(let [p (-> vscode/window.activeTextEditor
.-document
(.positionAt 0))
ns-form (-> (calva/ranges.currentForm vscode/window.activeTextEditor p)
second)]
(-> (calva/repl.evaluateCode (calva/repl.currentSessionKey) ns-form)
(.then #(println %))))
I ended up with this:
(ns javadoc
(:require ["$v0" :as calva]
["vscode" :as vscode]
[clojure.string :as str]
[promesa.core :as p]))
(p/let [p (-> vscode/window.activeTextEditor
.-document
(.positionAt 0))
ns-form (-> (calva/ranges.currentForm vscode/window.activeTextEditor p)
second)]
(-> (calva/repl.evaluateCode (calva/repl.currentSessionKey) ns-form)
(.then #(calva/repl.evaluateCode
"clj"
(str "(clojure.core/tap> \""
(.-ns %)
" evaluated\")")))))
When working on a new function, I often start out with
(let [foo (fn [...] ...)]
(foo ...))
so I can eval the function and a call to the function in one go. Then I move it to a defn
after it gets semi-stable.You are always welcome to post tips like that in the channel, @U90R0EPHA (and of course @U04V70XH6, and everyone!).