Question

I have a vim function set up where I can highlight a line of text and execute in clojure. Here's the function:

 function! Clojure_execline()
     let cl = (getline(line(".")))
     // ...
     exec 'clojure -e "' . cl . '"'
 endfunction

The problem with this is that it's slow to start and because it spawns a new clojure session every time I run it, I can't call a function I ran previously. Ideally, I'd like for a hidden repl to be running where I could send input from vim and retrieve the output from as well. I learned about gnu screen and thought it could help me, but I don't know how to send input from one screen window to another.

To clarify my problem, take this line of clojure:

(defn add2 [x y] (+ x y))

I'd like to be able to highlight this line in vim and execute in a running repl. I want to be able to call the line below and have it execute in the same repl:

(add2 4 5)

Afterwards, I'd like to be able to get the output of the function.

So, basically, my question is, how do I send input from one screen window to another?

Was it helpful?

Solution 3

Found what I was looking for. You can execute this from a terminal to send a string directly to the stdin of a screen window:

$ screen -X stuff "ls -l\015" # \015 sends a carrige return.

OTHER TIPS

Jake McCrary's suggestion is a good one. There are also a couple other scripts available, probably based on same idea:

VimClojure, which says it does "repl in a vim buffer"

and

slimv, specifically supports Clojure

and

Gorilla, I think VimClojure, above, is based on Gorilla

I don't know whether VimClojure actually does what you want, sending result back from Screen to buffer in Vim. One way to do that, I think, would be to finagle something using Vim's client-server functionality, possible with the --remote-send flag. See:

:h client-server
:h --remote-send

I don't have an exact answer, but it might be worth taking a look at slime.vim and seeing if anything can be learned from it.

blog post about it

script at vim.org

You might also be interested in Conque http://code.google.com/p/conque/

I use it for Scala

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top