Fork me on GitHub
#vim
<
2023-01-25
>
peterh12:01:09

I try to evaluate the following form from Neovim in an nREPL session with vim-iced: (require '[criterium.core :as crt]) It requires the namespace, but the alias does not work when I try to evaluate (crt/quick-bench (+ 1 2)). The alias works if I evaluate the form from the command line in the same nREPL session. Does anyone have an idea why it would not work from the editor? Maybe it has something to do with the :IcedEval command, so I wonder if it works with other tools like Conjure, with which I have no experience.

Martynas Maciulevičius12:01:45

I don't use vim-iced but can you try to wrap both of those in a (do )? What happens if you do criterium.core/... without alias?

peterh13:01:34

Okay, this doesn’t make sense to me: I just tried it with (do ) and it worked, but now it also works without do (which failed in my last attempts) after I restarted the nREPL session and evaluated both forms in the editor. But somehow when I enter it as a command :IcedEval (require '[criterium.core :as crt]) I can only evaluate (crt/quick-bench (+ 1 2)) with another call to IcedEval but not with the editor shortcut ee which also seems to call IcedEval. Sorry for the confusion – what I actually want to do is to execute IcedEval (require '[criterium.core :as crt]) from my own shortcut that I defined in my Neovim config and have the alias available in the editor so that I don’t need to require the library in the source file directly, which doesn’t work right now because of this behaviour.

Martynas Maciulevičius13:01:19

What happens when you do IcedEval *ns*? Maybe it generates a random namespace each time...? Or maybe it cleans up the namespace somehow. I think this is the limit of what I can help :thinking_face:

peterh14:01:35

Good guess, the namespace is indeed different when I use IcedEval. It is now “user” (same as in the REPL, where it actually finds the alias) but of course when I evaluate the form in the source file it is in a different namespace, which won’t have the alias in it. Not sure how I would get it into the namespace of the source file or how to evaluate vars from the user namespace from there…

Martynas Maciulevičius14:01:02

Oh... so you wanted to import it in user but use it in other ones? No can do 😄

peterh14:01:05

Somehow I was expecting it to evaluate in the source namespace since I’m so used to evaluating forms directly there, but it makes sense that it would be the user one like in the REPL. 😅