Fork me on GitHub
#vim
<
2020-06-29
>
bendy08:06:21

Hey all - I was working on my dev env with vim-iced and tmux. When I was working on it, I would fire up vim in one tmux pane, and open the repl with iced repl in another tmux pane. Evaluating the buffer (`\eb`) or any code would cause it to evaluate in the repl session in the right hand side, which is the behavoir I want. Now when I open the same setup, code within vim is executed but it does not effect the state of the repl in the second tmux pane. Is this intended/how the nREPL connections should work? Is there a way around this that anyone knows?

sogaiu09:06:53

@U0M0R1LUC i don't know the answer to your question, but @UBL24PLE6 might

dominicm12:06:04

@U0M0R1LUC it depends if you've started another JVM or not.

dominicm12:06:28

I'm not sure exactly what your setup is

bendy13:06:35

So after a lot of tinkering I've found that if I connect via vim-iced prior to connecting to a repl with iced repl, then the context is shared between the two sessions. For now it's working though, although if anyone has some documentation/references about how nRPEL contexts work, I'd be very intruiged

noisesmith14:06:20

I'm not sure what you're uncertain about here. To be clear (and risking telling you things you already know): • a single jvm clojure only has one global state for namespaces • a single namespace has one global state for vars if your changes in one repl aren't reflected in the other, this is because the repls are talking to two different vms

noisesmith15:06:24

nREPL contexts are instances of nrepl client objects, each one is dedicated to a specific remote vm

noisesmith15:06:26

if you want an editor and terminal repl to be connected to the same vm, the simplest thing is to start the repl (with server) in the terminal, and connect (and not start a new vm) with the client

bendy07:07:32

@U051SS2EU that actually clears things up a lot, thanks. I wasn't aware that there was a single global state for namespaces, but that makes it much easier to ration about. I'm not sure how my repls were connecting but clearly the order of operations was spinning up multiple vms

noisesmith15:07:25

one more thing: if you are using neovim/nvim the neoterm package lets you define a shortcut to send a region to a terminal in the editor https://github.com/kassio/neoterm - I use this to send parts of a file over to a repl client (just make sure the namespaces match)

noisesmith15:07:44

but maybe the tmux integration is the same / better