Add KillRunner and FocusRunner commands

This commit is contained in:
Chris Toomey 2012-11-23 00:33:07 -05:00
parent cd0aa7cc7d
commit 42217e1600
2 changed files with 33 additions and 8 deletions

View File

@ -6,6 +6,12 @@ A simple, vimscript only, command runner for sending commands from vim to tmux
This plugin exposes a command to open a small command runner window This plugin exposes a command to open a small command runner window
- Open runner window
- Automatic cd to project root (via git cdup)
- Send command (with escaping, auto-enter, auto-pre-clear)
- Enter tmux-copy mode in pane
- Maximize the runner pane
## Inspiration ## Inspiration
- Tslime.vim - Tslime.vim

View File

@ -17,23 +17,42 @@ function! s:initVariable(var, value)
endfunction endfunction
function! s:OpenRunnerPane() function! s:OpenRunnerPane()
call s:CacheVimTmuxPane() let s:cached_vim_pane = s:ActiveTmuxPaneNumber()
call system("tmux split-window -p 20 -v") call system("tmux split-window -p 20 -v")
call s:RefocusVimPane() let s:cached_runner_pane = s:ActiveTmuxPaneNumber()
call s:FocusTmuxPane(s:cached_vim_pane)
endfunction endfunction
function! s:CacheVimTmuxPane() function! s:KillRunnerPane()
call system("tmux kill-pane -t " . s:cached_runner_pane)
unlet s:cached_runner_pane
endfunction
function! s:ActiveTmuxPaneNumber()
let panes = system("tmux list-panes") let panes = system("tmux list-panes")
for pane_title in split(panes, '\n') for pane_title in split(panes, '\n')
if pane_title =~ '\(active\)' if pane_title =~ '\(active\)'
let s:cached_vim_pane = pane_title[0] return pane_title[0]
echo s:cached_vim_pane
endif endif
endfor endfor
endfunction endfunction
function! s:RefocusVimPane() function! s:TmuxPanes()
call system("tmux select-pane -t " . s:cached_vim_pane) let panes = system("tmux list-panes")
return split(panes, '\n')
endfunction endfunction
command! VimTmuxRunnerOpenRunner :call s:OpenRunnerPane() function! s:FocusTmuxPane(pane_number)
call system("tmux select-pane -t " . a:pane_number)
endfunction
function! s:FocusRunnerPane()
call s:FocusTmuxPane(s:cached_runner_pane)
endfunction
command! VTROpenRunner :call s:OpenRunnerPane()
command! VTRKillRunner :call s:KillRunnerPane()
command! VTRFocusRunnerPane :call s:FocusRunnerPane()
nmap ,vm :VTROpenRunner<cr>
nmap ,kv :VTRKillRunner<cr>
nmap ,fp :VTRFocusRunnerPane<cr>