@@ -15,12 +15,12 @@ let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane')
15
15
let g: VimuxTmuxCommand = get (g: , ' VimuxTmuxCommand' , ' tmux' )
16
16
let g: VimuxUseNearest = get (g: , ' VimuxUseNearest' , v: true )
17
17
18
- function ! s: VimuxOption (name) abort
18
+ function ! VimuxOption (name) abort
19
19
return get (b: , a: name , get (g: , a: name ))
20
20
endfunction
21
21
22
- if ! executable (s: VimuxOption (' VimuxTmuxCommand' ))
23
- echohl ErrorMsg | echomsg ' Failed to find executable ' .s: VimuxOption (' VimuxTmuxCommand' ) | echohl None
22
+ if ! executable (VimuxOption (' VimuxTmuxCommand' ))
23
+ echohl ErrorMsg | echomsg ' Failed to find executable ' .VimuxOption (' VimuxTmuxCommand' ) | echohl None
24
24
finish
25
25
endif
26
26
@@ -55,21 +55,17 @@ function! VimuxRunLastCommand()
55
55
endfunction
56
56
57
57
function ! VimuxRunCommand (command , ... )
58
- if ! exists (' g:VimuxRunnerIndex' ) || s: VimuxHasRunner (g: VimuxRunnerIndex ) == # -1
58
+ if ! exists (' g:VimuxRunnerIndex' ) || s: hasRunner (g: VimuxRunnerIndex ) == # -1
59
59
call VimuxOpenRunner ()
60
60
endif
61
-
62
61
let l: autoreturn = 1
63
62
if exists (' a:1' )
64
63
let l: autoreturn = a: 1
65
64
endif
66
-
67
- let resetSequence = s: VimuxOption (' VimuxResetSequence' )
65
+ let resetSequence = VimuxOption (' VimuxResetSequence' )
68
66
let g: VimuxLastCommand = a: command
69
-
70
67
call VimuxSendKeys (resetSequence)
71
68
call VimuxSendText (a: command )
72
-
73
69
if l: autoreturn == # 1
74
70
call VimuxSendKeys (' Enter' )
75
71
endif
@@ -81,76 +77,74 @@ endfunction
81
77
82
78
function ! VimuxSendKeys (keys )
83
79
if exists (' g:VimuxRunnerIndex' )
84
- call s: VimuxTmux (' send-keys -t ' .g: VimuxRunnerIndex .' ' .a: keys )
80
+ call VimuxTmux (' send-keys -t ' .g: VimuxRunnerIndex .' ' .a: keys )
85
81
else
86
82
echo ' No vimux runner pane/window. Create one with VimuxOpenRunner'
87
83
endif
88
84
endfunction
89
85
90
86
function ! VimuxOpenRunner ()
91
- let nearestIndex = s: VimuxNearestIndex ()
92
-
93
- if s: VimuxOption (' VimuxUseNearest' ) == # 1 && nearestIndex != -1
87
+ let nearestIndex = s: nearestIndex ()
88
+ if VimuxOption (' VimuxUseNearest' ) == # 1 && nearestIndex != -1
94
89
let g: VimuxRunnerIndex = nearestIndex
95
90
else
96
- let extraArguments = s: VimuxOption (' VimuxOpenExtraArgs' )
97
- if s: VimuxOption (' VimuxRunnerType' ) == # ' pane'
98
- let height = s: VimuxOption (' VimuxHeight' )
99
- let orientation = s: VimuxOption (' VimuxOrientation' )
100
- call s: VimuxTmux (' split-window -p ' .height.' -' .orientation.' ' .extraArguments)
101
- elseif s: VimuxOption (' VimuxRunnerType' ) == # ' window'
102
- call s: VimuxTmux (' new-window ' .extraArguments)
91
+ let extraArguments = VimuxOption (' VimuxOpenExtraArgs' )
92
+ if VimuxOption (' VimuxRunnerType' ) == # ' pane'
93
+ let height = VimuxOption (' VimuxHeight' )
94
+ let orientation = VimuxOption (' VimuxOrientation' )
95
+ call VimuxTmux (' split-window -p ' .height.' -' .orientation.' ' .extraArguments)
96
+ elseif VimuxOption (' VimuxRunnerType' ) == # ' window'
97
+ call VimuxTmux (' new-window ' .extraArguments)
103
98
endif
104
-
105
- let g: VimuxRunnerIndex = s: VimuxTmuxIndex ()
106
- call s: VimuxSetRunnerName ()
107
- call s: VimuxTmux (' last-' .s: VimuxOption (' VimuxRunnerType' ))
99
+ let g: VimuxRunnerIndex = s: tmuxIndex ()
100
+ call s: setRunnerName ()
101
+ call VimuxTmux (' last-' .VimuxOption (' VimuxRunnerType' ))
108
102
endif
109
103
endfunction
110
104
111
105
function ! VimuxCloseRunner ()
112
106
if exists (' g:VimuxRunnerIndex' )
113
- call s: VimuxTmux (' kill-' .s: VimuxOption (' VimuxRunnerType' ).' -t ' .g: VimuxRunnerIndex )
107
+ call VimuxTmux (' kill-' .VimuxOption (' VimuxRunnerType' ).' -t ' .g: VimuxRunnerIndex )
114
108
unlet g: VimuxRunnerIndex
115
109
endif
116
110
endfunction
117
111
118
112
function ! VimuxTogglePane ()
119
113
if exists (' g:VimuxRunnerIndex' )
120
- if s: VimuxOption (' VimuxRunnerType' ) == # ' window'
121
- call s: VimuxTmux (' join-pane -d -s ' .g: VimuxRunnerIndex .' -p ' .s: VimuxOption (' VimuxHeight' ))
122
- let s: VimuxOption (' VimuxRunnerType' ) = ' pane'
123
- elseif s: VimuxOption (' VimuxRunnerType' ) == # ' pane'
124
- let g: VimuxRunnerIndex= substitute (s: VimuxTmux (' break-pane -d -t ' .g: VimuxRunnerIndex ." -P -F '#{window_id}'" ), ' \n' , ' ' , ' ' )
125
- let s: VimuxOption (' VimuxRunnerType' ) = ' window'
114
+ if VimuxOption (' VimuxRunnerType' ) == # ' window'
115
+ call VimuxTmux (' join-pane -d -s ' .g: VimuxRunnerIndex .' -p ' .VimuxOption (' VimuxHeight' ))
116
+ let VimuxOption (' VimuxRunnerType' ) = ' pane'
117
+ elseif VimuxOption (' VimuxRunnerType' ) == # ' pane'
118
+ let g: VimuxRunnerIndex= substitute (VimuxTmux (' break-pane -d -t ' .g: VimuxRunnerIndex ." -P -F '#{window_id}'" ), ' \n' , ' ' , ' ' )
119
+ let VimuxOption (' VimuxRunnerType' ) = ' window'
126
120
endif
127
121
endif
128
122
endfunction
129
123
130
124
function ! VimuxZoomRunner ()
131
125
if exists (' g:VimuxRunnerIndex' )
132
- if s: VimuxOption (' VimuxRunnerType' ) == # ' pane'
133
- call s: VimuxTmux (' resize-pane -Z -t ' .g: VimuxRunnerIndex )
134
- elseif s: VimuxOption (' VimuxRunnerType' ) == # ' window'
135
- call s: VimuxTmux (' select-window -t ' .g: VimuxRunnerIndex )
126
+ if VimuxOption (' VimuxRunnerType' ) == # ' pane'
127
+ call VimuxTmux (' resize-pane -Z -t ' .g: VimuxRunnerIndex )
128
+ elseif VimuxOption (' VimuxRunnerType' ) == # ' window'
129
+ call VimuxTmux (' select-window -t ' .g: VimuxRunnerIndex )
136
130
endif
137
131
endif
138
132
endfunction
139
133
140
134
function ! VimuxInspectRunner ()
141
- call s: VimuxTmux (' select-' .s: VimuxOption (' VimuxRunnerType' ).' -t ' .g: VimuxRunnerIndex )
142
- call s: VimuxTmux (' copy-mode' )
135
+ call VimuxTmux (' select-' .VimuxOption (' VimuxRunnerType' ).' -t ' .g: VimuxRunnerIndex )
136
+ call VimuxTmux (' copy-mode' )
143
137
endfunction
144
138
145
139
function ! VimuxScrollUpInspect ()
146
140
call VimuxInspectRunner ()
147
- call s: VimuxTmux (' last-' .s: VimuxOption (' VimuxRunnerType' ))
141
+ call VimuxTmux (' last-' .VimuxOption (' VimuxRunnerType' ))
148
142
call VimuxSendKeys (' C-u' )
149
143
endfunction
150
144
151
145
function ! VimuxScrollDownInspect ()
152
146
call VimuxInspectRunner ()
153
- call s: VimuxTmux (' last-' .s: VimuxOption (' VimuxRunnerType' ))
147
+ call VimuxTmux (' last-' .VimuxOption (' VimuxRunnerType' ))
154
148
call VimuxSendKeys (' C-d' )
155
149
endfunction
156
150
@@ -166,88 +160,86 @@ endfunction
166
160
167
161
function ! VimuxClearRunnerHistory ()
168
162
if exists (' g:VimuxRunnerIndex' )
169
- call s: VimuxTmux (' clear-history -t ' .g: VimuxRunnerIndex )
163
+ call VimuxTmux (' clear-history -t ' .g: VimuxRunnerIndex )
170
164
endif
171
165
endfunction
172
166
173
167
function ! VimuxPromptCommand (... )
174
168
let command = a: 0 == # 1 ? a: 1 : ' '
175
- let l: command = input (s: VimuxOption (' VimuxPromptString' ), command , ' shellcmd' )
169
+ let l: command = input (VimuxOption (' VimuxPromptString' ), command , ' shellcmd' )
176
170
call VimuxRunCommand (l: command )
177
171
endfunction
178
172
179
- function ! s: VimuxTmux (arguments)
180
- if s: VimuxOption (' VimuxDebug' )
181
- echom s: VimuxOption (' VimuxTmuxCommand' ).' ' .a: arguments
173
+ function ! VimuxTmux (arguments)
174
+ if VimuxOption (' VimuxDebug' )
175
+ echom VimuxOption (' VimuxTmuxCommand' ).' ' .a: arguments
182
176
endif
183
- return system (s: VimuxOption (' VimuxTmuxCommand' ).' ' .a: arguments )
177
+ return system (VimuxOption (' VimuxTmuxCommand' ).' ' .a: arguments )
184
178
endfunction
185
179
186
- function ! s: VimuxTmuxSession ()
187
- return s: VimuxTmuxProperty (' #S' )
180
+ function ! s: tmuxSession ()
181
+ return s: tmuxProperty (' #S' )
188
182
endfunction
189
183
190
- function ! s: VimuxTmuxIndex ()
191
- if s: VimuxOption (' VimuxRunnerType' ) == # ' pane'
192
- return s: VimuxTmuxPaneId ()
184
+ function ! s: tmuxIndex ()
185
+ if VimuxOption (' VimuxRunnerType' ) == # ' pane'
186
+ return s: tmuxPaneId ()
193
187
else
194
- return s: VimuxTmuxWindowId ()
188
+ return s: tmuxWindowId ()
195
189
end
196
190
endfunction
197
191
198
- function ! s: VimuxTmuxPaneId ()
199
- return s: VimuxTmuxProperty (' #{pane_id}' )
192
+ function ! s: tmuxPaneId ()
193
+ return s: tmuxProperty (' #{pane_id}' )
200
194
endfunction
201
195
202
- function ! s: VimuxTmuxWindowId ()
203
- return s: VimuxTmuxProperty (' #{window_id}' )
196
+ function ! s: tmuxWindowId ()
197
+ return s: tmuxProperty (' #{window_id}' )
204
198
endfunction
205
199
206
- function ! s: VimuxNearestIndex ()
207
- let t = s: VimuxOption (' VimuxRunnerType' )
208
- let filter = s: VimuxGetTargetFilter ()
209
- let views = split (s: VimuxTmux (' list-' .t ." s -F '#{" .t .' _active}:#{' .t ." _id}'" .filter ), ' \n' )
210
-
200
+ function ! s: nearestIndex ()
201
+ let t = VimuxOption (' VimuxRunnerType' )
202
+ let filter = s: getTargetFilter ()
203
+ let views = split (VimuxTmux (' list-' .t ." s -F '#{" .t .' _active}:#{' .t ." _id}'" .filter ), ' \n' )
211
204
for view in views
212
205
if match (view , ' 1:' ) == # -1
213
206
return split (view , ' :' )[1 ]
214
207
endif
215
208
endfor
216
-
217
209
return -1
218
210
endfunction
219
211
220
- function ! s: VimuxGetTargetFilter ()
221
- let targetName = s: VimuxOption (' VimuxRunnerName' )
212
+ function ! s: getTargetFilter ()
213
+ let targetName = VimuxOption (' VimuxRunnerName' )
222
214
if targetName == # ' '
223
215
return ' '
224
216
endif
225
- let t = s: VimuxOption (' VimuxRunnerType' )
217
+ let t = VimuxOption (' VimuxRunnerType' )
226
218
if t == # ' window'
227
219
return " -f '#{==:#{window_name}," .targetName." }'"
228
220
elseif t == # ' pane'
229
221
return " -f '#{==:#{pane_title}," .targetName." }'"
230
222
endif
231
223
endfunction
232
224
233
- function ! s: VimuxSetRunnerName ()
234
- let targetName = s: VimuxOption (' VimuxRunnerName' )
225
+ function ! s: setRunnerName ()
226
+ let targetName = VimuxOption (' VimuxRunnerName' )
235
227
if targetName == # ' '
236
- return
228
+ return
237
229
endif
238
- let t = s: VimuxOption (' VimuxRunnerType' )
230
+ let t = VimuxOption (' VimuxRunnerType' )
239
231
if t == # ' window'
240
- call s: VimuxTmux (' rename-window ' .targetName)
232
+ call VimuxTmux (' rename-window ' .targetName)
241
233
elseif t == # ' pane'
242
- call s: VimuxTmux (' select-pane -T ' .targetName)
234
+ call VimuxTmux (' select-pane -T ' .targetName)
243
235
endif
244
236
endfunction
245
237
246
- function ! s: VimuxTmuxProperty (property)
247
- return substitute (s: VimuxTmux (" display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
238
+ function ! s: tmuxProperty (property)
239
+ return substitute (VimuxTmux (" display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
248
240
endfunction
249
241
250
- function ! s: VimuxHasRunner (index )
251
- let t = s: VimuxOption (' VimuxRunnerType' )
252
- return match (s: VimuxTmux (' list-' .t ." s -F '#{" .t ." _id}'" ), a: index )
242
+ function ! s: hasRunner (index )
243
+ let t = VimuxOption (' VimuxRunnerType' )
244
+ return match (VimuxTmux (' list-' .t ." s -F '#{" .t ." _id}'" ), a: index )
253
245
endfunction
0 commit comments