diff --git a/README.mkd b/README.mkd index 7832c66..d60f576 100644 --- a/README.mkd +++ b/README.mkd @@ -86,6 +86,24 @@ map rx :CloseVimTmuxPanes map rs :InterruptVimTmuxRunner ``` +### tslime replacement + +Here is how to use vimux to send code to a REPL. This is similar to tslime. First, add some helpful mappings. + +```viml + +" Prompt for a command to run +map vp :PromptVimTmuxCommand + +" If text is selected, save it in the v buffer and send that buffer it to tmux +vmap vs "vy :call RunVimTmuxCommand(@v) + +" Select current paragraph and send it to tmux +nmap vs vipvs +``` + +Now, open a clojure file. Let's say your leader is backslash (\). Type \vp, and then type lein repl at the prompt. This opens a tmux split running a REPL. Then, select text or put the cursor on a function and type \vs. This will send it to the REPL and evaluate it. + ## Options ### VimuxHeight diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 9818b94..4765d65 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -1,3 +1,8 @@ +if exists("g:loaded_vimux") || &cp + finish +endif +let g:loaded_vimux = 1 + if !has("ruby") finish end @@ -9,12 +14,12 @@ command InspectVimTmuxRunner :call InspectVimTmuxRunner() command InterruptVimTmuxRunner :call InterruptVimTmuxRunner() command PromptVimTmuxCommand :call PromptVimTmuxCommand() -function! RunVimTmuxCommand(command) +function RunVimTmuxCommand(command) let g:_VimTmuxCmd = a:command ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd")) endfunction -function! RunLastVimTmuxCommand() +function RunLastVimTmuxCommand() if exists("g:_VimTmuxCmd") ruby CurrentTmuxSession.new.run_shell_command(Vim.evaluate("g:_VimTmuxCmd")) else @@ -22,32 +27,32 @@ function! RunLastVimTmuxCommand() endif endfunction -function! ClearVimTmuxWindow() +function ClearVimTmuxWindow() if exists("g:_VimTmuxRunnerPane") unlet g:_VimTmuxRunnerPane end endfunction -function! CloseVimTmuxWindows() +function CloseVimTmuxWindows() ruby CurrentTmuxSession.new.close_other_panes call ClearVimTmuxWindow() echoerr "CloseVimTmuxWindows is deprecated, use CloseVimTmuxPanes" endfunction -function! CloseVimTmuxPanes() +function CloseVimTmuxPanes() ruby CurrentTmuxSession.new.close_other_panes call ClearVimTmuxWindow() endfunction -function! InterruptVimTmuxRunner() +function InterruptVimTmuxRunner() ruby CurrentTmuxSession.new.interrupt_runner endfunction -function! InspectVimTmuxRunner() +function InspectVimTmuxRunner() ruby CurrentTmuxSession.new.inspect_runner endfunction -function! PromptVimTmuxCommand() +function PromptVimTmuxCommand() let l:command = input("Command? ") call RunVimTmuxCommand(l:command) endfunction