1

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?

4 Answers 4

3

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
1
  • vimClojure looks close to what I want. I'll take a look at it to see their approach. Dec 1, 2010 at 1:00
2

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

2

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

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

I use it for Scala

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.