@@ -14,16 +14,16 @@ command VimuxPromptCommand :call VimuxPromptCommand()
14
14
command VimuxClearRunnerHistory :call VimuxClearRunnerHistory ()
15
15
16
16
function ! VimuxRunLastCommand ()
17
- if exists (" g:VimuxRunnerPaneIndex " )
17
+ if exists (" g:VimuxRunnerIndex " )
18
18
call VimuxRunCommand (g: VimuxLastCommand )
19
19
else
20
20
echo " No last vimux command."
21
21
endif
22
22
endfunction
23
23
24
24
function ! VimuxRunCommand (command , ... )
25
- if ! exists (" g:VimuxRunnerPaneIndex " ) || _VimuxHasPane (g: VimuxRunnerPaneIndex ) == -1
26
- call VimuxOpenPane ()
25
+ if ! exists (" g:VimuxRunnerIndex " ) || _VimuxHasRunner (g: VimuxRunnerIndex ) == -1
26
+ call VimuxOpenRunner ()
27
27
endif
28
28
29
29
let l: autoreturn = 1
@@ -47,31 +47,36 @@ function! VimuxSendText(text)
47
47
endfunction
48
48
49
49
function ! VimuxSendKeys (keys )
50
- if exists (" g:VimuxRunnerPaneIndex " )
51
- call system (" tmux send-keys -t " .g: VimuxRunnerPaneIndex ." " .a: keys )
50
+ if exists (" g:VimuxRunnerIndex " )
51
+ call system (" tmux send-keys -t " .g: VimuxRunnerIndex ." " .a: keys )
52
52
else
53
- echo " No vimux runner pane. Create one with VimuxOpenPane "
53
+ echo " No vimux runner pane/window . Create one with VimuxOpenRunner "
54
54
endif
55
55
endfunction
56
56
57
- function ! VimuxOpenPane ()
58
- let height = _VimuxOption (" g:VimuxHeight" , 20 )
59
- let orientation = _VimuxOption (" g:VimuxOrientation" , " v" )
60
- let nearestIndex = _VimuxNearestPaneIndex ()
57
+ function ! VimuxOpenRunner ()
58
+ let nearestIndex = _VimuxNearestIndex ()
61
59
62
- if _VimuxOption (" g:VimuxUseNearestPane " , 1 ) == 1 && nearestIndex != -1
63
- let g: VimuxRunnerPaneIndex = nearestIndex
60
+ if _VimuxOption (" g:VimuxUseNearest " , 1 ) == 1 && nearestIndex != -1
61
+ let g: VimuxRunnerIndex = nearestIndex
64
62
else
65
- call system (" tmux split-window -p " .height." -" .orientation)
66
- let g: VimuxRunnerPaneIndex = _VimuxTmuxPaneIndex ()
67
- call system (" tmux last-pane" )
63
+ if _VimuxRunnerType () == " pane"
64
+ let height = _VimuxOption (" g:VimuxHeight" , 20 )
65
+ let orientation = _VimuxOption (" g:VimuxOrientation" , " v" )
66
+ call system (" tmux split-window -p " .height." -" .orientation)
67
+ elseif _VimuxRunnerType () == " window"
68
+ call system (" tmux new-window" )
69
+ endif
70
+
71
+ let g: VimuxRunnerIndex = _VimuxTmuxIndex ()
72
+ call system (" tmux last-" ._VimuxRunnerType ())
68
73
endif
69
74
endfunction
70
75
71
76
function ! VimuxCloseRunner ()
72
- if exists (" g:VimuxRunnerPaneIndex " )
73
- call system (" tmux kill-pane -t " .g: VimuxRunnerPaneIndex )
74
- unlet g: VimuxRunnerPaneIndex
77
+ if exists (" g:VimuxRunnerIndex " )
78
+ call system (" tmux kill-" . _VimuxRunnerType (). " -t " .g: VimuxRunnerIndex )
79
+ unlet g: VimuxRunnerIndex
75
80
endif
76
81
endfunction
77
82
@@ -83,19 +88,19 @@ function! VimuxZoomRunner()
83
88
endfunction
84
89
85
90
function ! VimuxInspectRunner ()
86
- call system (" tmux select-pane -t " .g: VimuxRunnerPaneIndex )
91
+ call system (" tmux select-" . _VimuxRunnerType (). " -t " .g: VimuxRunnerIndex )
87
92
call system (" tmux copy-mode" )
88
93
endfunction
89
94
90
95
function ! VimuxScrollUpInspect ()
91
96
call VimuxInspectRunner ()
92
- call system (" tmux last-pane " )
97
+ call system (" tmux last-" . _VimuxRunnerType () )
93
98
call VimuxSendKeys (" C-u" )
94
99
endfunction
95
100
96
101
function ! VimuxScrollDownInspect ()
97
102
call VimuxInspectRunner ()
98
- call system (" tmux last-pane " )
103
+ call system (" tmux last-" . _VimuxRunnerType () )
99
104
call VimuxSendKeys (" C-d" )
100
105
endfunction
101
106
@@ -104,8 +109,8 @@ function! VimuxInterruptRunner()
104
109
endfunction
105
110
106
111
function ! VimuxClearRunnerHistory ()
107
- if exists (" g:VimuxRunnerPaneIndex " )
108
- call system (" tmux clear-history -t " .g: VimuxRunnerPaneIndex )
112
+ if exists (" g:VimuxRunnerIndex " )
113
+ call system (" tmux clear-history -t " .g: VimuxRunnerIndex )
109
114
endif
110
115
endfunction
111
116
@@ -118,16 +123,24 @@ function! _VimuxTmuxSession()
118
123
return _VimuxTmuxProperty (" S" )
119
124
endfunction
120
125
126
+ function ! _VimuxTmuxIndex ()
127
+ if _VimuxRunnerType == " pane"
128
+ return _VimuxTmuxPaneIndex ()
129
+ else
130
+ return _VimuxTmuxWindowIndex ()
131
+ end
132
+ endfunction
133
+
121
134
function ! _VimuxTmuxPaneIndex ()
122
- return _VimuxTmuxProperty (" P" )
135
+ return _VimuxTmuxProperty (" P" )
123
136
endfunction
124
137
125
138
function ! _VimuxTmuxWindowIndex ()
126
139
return _VimuxTmuxProperty (" I" )
127
140
endfunction
128
141
129
- function ! _VimuxNearestPaneIndex ()
130
- let panes = split (system (" tmux list-panes " ), " \n " )
142
+ function ! _VimuxNearestIndex ()
143
+ let panes = split (system (" tmux list-" . _VimuxRunnerType (). " s " ), " \n " )
131
144
132
145
for pane in panes
133
146
if match (pane, " (active)" ) == -1
@@ -138,6 +151,10 @@ function! _VimuxNearestPaneIndex()
138
151
return -1
139
152
endfunction
140
153
154
+ function ! _VimuxRunnerType ()
155
+ return _VimuxOption (" g:VimuxRunnerType" , " pane" )
156
+ endfunction
157
+
141
158
function ! _VimuxOption (option , default)
142
159
if exists (a: option )
143
160
return eval (a: option )
@@ -150,6 +167,6 @@ function! _VimuxTmuxProperty(property)
150
167
return substitute (system (" tmux display -p '#" .a: property ." '" ), ' \n$' , ' ' , ' ' )
151
168
endfunction
152
169
153
- function ! _VimuxHasPane (index )
154
- return match (system (" tmux list-panes " ), a: index ." :" )
170
+ function ! _VimuxHasRunner (index )
171
+ return match (system (" tmux list-" . _VimuxRunnerType (). " s " ), a: index ." :" )
155
172
endfunction
0 commit comments