Hello 👋:skin-tone-2: when using Calva + the vim extension (vscodevim) and trying to eval some forms, the eval doesn’t include the last )
that is under the caret. This happens when you have normal mode activated. In the insert mode you can move the caret at the end of the last )
so the eval works. I was wondering if you have come up with some Calva (or vscodevim) specific setting which could make the eval to include the last )
when using the normal mode? 🙂
Sounds like the last expression is being evaluated rather than the top level expression. VSpaceCode will do both types of evaluation commands, so maybe there is a different keybinding / command to use with the vscodevim extension. Or just move to the line after the expression and evaluate
Actually Calva doesn’t really have a concept of last sexpression. It will try to find the “current” form.
In Calva, evaluate the current form behaves like evaluate last s-expression when the cursor is after a nested expression but still within a top-level expression
For example, with the cursor on the last closing paren in this expression (- 10 (* 2 3))
, the "evaluate current form" will return 6 using "evaluate top level form" returns 4
So my suggestion to the original question is to use "Calva: Evaluate top level form". Or move to the next line and use "Calva: evaluate current form" which evaluates the top level form it finds behind the cursor.. shouldnt matter how many empty lines there are.
So unless a specific nested form should be evaluated, then use "Evaluate top level form"
Calva will evaluate (* 2 3)
if the cursor is before it as well (unless there is a previous sexpr on the same line, which will take precedence.
Good to know. I like the simplicity of current and top form evaluation. The Calva approach seems a simpler than the 8 different command available for Cider 🙂
Great tip to switch to use “Evaluate top level form” instead, thanks :thumbsup::skin-tone-2:
File a feature request about it, @janne.sauvala. Maybe there is a way we can detect the normal mode.
You can also try configuring a custom command for now. Yesterday I pushed a change that makes it easier to get keyboard shortcuts bound to those. There are quite a few predefined ones,, chords starting with ctrl+alt+space
and then things like a
-`z` and digits and some more. See https://calva.io/custom-commands/
A shortcut something like this might work:
"calva.customREPLCommandSnippets": [
{
"name": "Normal mode eval current form",
"key": "enter",
"snippet": "$current-form)"
}
]
And would then be bound to the keyboard shortcut ctrl+alt+space enter
Also try what is evaluated in normal mode if you have the cursor adjacent before the list.
Thanks, Peter. I can try that also 🙂
I tried vscodevim myself now. I had misunderstood the behaviour some, so that custom command won’t cut it. I noticed that having the cursor on the opening bracket or before it evaluated the form though.
For comparison, in VSpaceCode I use the , e f
for the top level form and , e e
for last expression, to match the bindings in Spacemacs and SpaceVim
, e e
for current expression. 😃
foo
| bar
|
denoting the cursor. bar
will be evaluated.foo | bar
foo
will be evaluatedReally useful to know about the way current expression works, I like it. Thank you.
There is kind of a disclaimer here: https://calva.io/vim/ & I don't think that's all on :calva: as I have issues with :vim: bindings with other languages on Visual Studio Code
. So, TBH if I'm feeling Vimmy I've been using https://liquidz.github.io/vim-iced/ lately & I actually have the Vim plugin disabled in VS Code 😕
I only had to remap Calva Esc
key binding to Shift-Esc
and all was fine with Calva and VSpaceCode for key bindings. I should add the submitted VSpaceCode key bindings for Calva on the page you mentioned, thank you for the reminder.
@pez As a quick workaround for Windows / Oracle 15 issues: people can set JAVA_CMD
to override the executable that is being used by tools.deps. It might not be as beginner friendly, but it offers them a way out. You could also hack this yourself: if you detect the executable is this weird Oracle "wrapper?!", then you search for the corresponding "working" java executable and set JAVA_CMD to that (for the Getting Started REPL only I'd say)
Makes sense. Maybe something like where java
and if it has Oracle
in there, tell the user to update jackInEnv
with the path to the non-“wrapped” executable….
This issue seems to hit lein
as well, btw: https://github.com/BetterThanTomorrow/calva/issues/1106
Hey y’all - I’m trying to load rebl from calva, and no matter what I do I always get
; Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
; cognitect.rebl
I’m using the leiningen instructions on the site, and am using the latest Oracle JDK. I have rebl downloaded, have run the install script, morning and am using the absolute path to the jar file. Has anybody had problems like this before?@mschmele There is an error with passing EDN arguments to latest Oracle JDK's (higher or equal to 15 roughly)
see the previous message(s)
you're better off using AdoptOpenJDK or a workaround by setting JAVA_CMD
Ah gotcha, thanks
still doesn’t seem to be working for me even after changing my java version to OpenJDK 11
I haven’t tried REBL lately, maybe something has changed…
Let’s see if we have some REBL users in this channel who can assist.
TIL: Installing the VIM extension means all VS Code windows get it enabled w/o reloading the window. But to disable VIM you’ll need to reload all those windows. In my case 12 of them… Gah!
😁 Very much in the style of the old joke about how easy it is to quit vim 😜
dumb question but how to you run the whole file? I don't want to option+enter every function every time
Load Current File and Dependencies
Can right click to do it and select from menu (or on my machine its Ctrl+Alt+C Enter)