vim

peterh 2023-01-25T12:45:09.354499Z

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čius 2023-01-25T12:59:45.065319Z

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?

peterh 2023-01-25T13:29:34.093599Z

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čius 2023-01-25T13:32:19.123949Z

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 🤔

peterh 2023-01-25T14:02:35.290979Z

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čius 2023-01-25T14:04:02.720899Z

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

peterh 2023-01-25T14:23:05.108409Z

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. 😅

fuad 2023-01-25T22:23:44.705299Z

Maybe https://clojuredocs.org/clojure.core/in-ns could help?