Skip to content

Commit aa8a444

Browse files
committed
Add ability to change runner type between pane and window
1 parent 49a048e commit aa8a444

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

plugin/vimux.vim

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,31 @@ function! VimuxOpenRunner()
6363
else
6464
call system("tmux split-window -p ".height." -".orientation)
6565
let g:VimuxRunnerIndex = _VimuxTmuxIndex()
66-
call system("tmux last-pane")
66+
call system("tmux last-"._VimuxRunnerType())
6767
endif
6868
endfunction
6969

7070
function! VimuxCloseRunner()
7171
if exists("g:VimuxRunnerIndex")
72-
call system("tmux kill-pane -t ".g:VimuxRunnerIndex)
72+
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
7373
unlet g:VimuxRunnerIndex
7474
endif
7575
endfunction
7676

7777
function! VimuxInspectRunner()
78-
call system("tmux select-pane -t ".g:VimuxRunnerIndex)
78+
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
7979
call system("tmux copy-mode")
8080
endfunction
8181

8282
function! VimuxScrollUpInspect()
8383
call VimuxInspectRunner()
84-
call system("tmux last-pane")
84+
call system("tmux last-"._VimuxRunnerType())
8585
call VimuxSendKeys("C-u")
8686
endfunction
8787

8888
function! VimuxScrollDownInspect()
8989
call VimuxInspectRunner()
90-
call system("tmux last-pane")
90+
call system("tmux last-"._VimuxRunnerType())
9191
call VimuxSendKeys("C-d")
9292
endfunction
9393

@@ -119,7 +119,7 @@ function! _VimuxTmuxWindowIndex()
119119
endfunction
120120

121121
function! _VimuxNearestIndex()
122-
let panes = split(system("tmux list-panes"), "\n")
122+
let panes = split(system("tmux list-"._VimuxRunnerType()."s"), "\n")
123123

124124
for pane in panes
125125
if match(pane, "(active)") == -1
@@ -130,6 +130,10 @@ function! _VimuxNearestIndex()
130130
return -1
131131
endfunction
132132

133+
function! _VimuxRunnerType()
134+
return _VimuxOption("g:VimuxRunnerType", "pane")
135+
endfunction
136+
133137
function! _VimuxOption(option, default)
134138
if exists(a:option)
135139
return eval(a:option)
@@ -143,5 +147,5 @@ function! _VimuxTmuxProperty(property)
143147
endfunction
144148

145149
function! _VimuxHasRunner(index)
146-
return match(system("tmux list-panes"), a:index.":")
150+
return match(system("tmux list-"._VimuxRunnerType()."s"), a:index.":")
147151
endfunction

0 commit comments

Comments
 (0)