Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CoffeeScript REPL support for tmux #13

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions ftplugin/coffee/slime.vim
@@ -0,0 +1,12 @@


" CoffeeScript REPL enters multi-line mode with Ctrl+v
function! _PreTmux_coffee(socket_name, target_pane)
call system("tmux -L " . a:socket_name . " send-keys C-v -t " . a:target_pane)
endfunction

" Exit multi-line REPL mode with Ctrl+d
function! _PostTmux_coffee(socket_name, target_pane)
call system("tmux -L " . a:socket_name . " send-keys C-d -t " . a:target_pane)
endfunction

21 changes: 21 additions & 0 deletions plugin/slime.vim
Expand Up @@ -32,8 +32,14 @@ let g:slime_loaded = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


function! s:ScreenSend(config, text) function! s:ScreenSend(config, text)

call s:ExecFileTypeFn("_PreScreen_", [a:config["sessionname"], a:config["windowname"]])

let escaped_text = s:_EscapeText(a:text) let escaped_text = s:_EscapeText(a:text)
call system("screen -S " . a:config["sessionname"] . " -p " . a:config["windowname"] . " -X stuff " . escaped_text) call system("screen -S " . a:config["sessionname"] . " -p " . a:config["windowname"] . " -X stuff " . escaped_text)

call s:ExecFileTypeFn("_PostScreen_", [a:config["socket_name"], a:config["target_pane"]])

endfunction endfunction


" Leave this function exposed as it's called outside the plugin context " Leave this function exposed as it's called outside the plugin context
Expand All @@ -55,9 +61,15 @@ endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


function! s:TmuxSend(config, text) function! s:TmuxSend(config, text)

call s:ExecFileTypeFn("_PreTmux_", [a:config["socket_name"], a:config["target_pane"]])

let escaped_text = s:_EscapeText(a:text) let escaped_text = s:_EscapeText(a:text)
call system("tmux -L " . a:config["socket_name"] . " set-buffer " . escaped_text) call system("tmux -L " . a:config["socket_name"] . " set-buffer " . escaped_text)
call system("tmux -L " . a:config["socket_name"] . " paste-buffer -t " . a:config["target_pane"]) call system("tmux -L " . a:config["socket_name"] . " paste-buffer -t " . a:config["target_pane"])

call s:ExecFileTypeFn("_PostTmux_", [a:config["socket_name"], a:config["target_pane"]])

endfunction endfunction


function! s:TmuxConfig() function! s:TmuxConfig()
Expand Down Expand Up @@ -86,6 +98,15 @@ function! s:_EscapeText(text)
return substitute(shellescape(transformed_text), "\\\\\\n", "\n", "g") return substitute(shellescape(transformed_text), "\\\\\\n", "\n", "g")
endfunction endfunction


function s:ExecFileTypeFn(fn_name, args)
if exists("&filetype")
let fullname = a:fn_name . &filetype
if exists("*" . fullname)
call call(fullname, a:args)
end
end
endfunction

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Public interface " Public interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Expand Down