@@ -15,8 +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
- if ! executable (g: VimuxTmuxCommand )
19
- echohl ErrorMsg | echomsg ' Failed to find executable ' .g: VimuxTmuxCommand | echohl None
18
+ function ! s: VimuxOption (name) abort
19
+ return get (b: , a: name , get (g: , a: name ))
20
+ endfunction
21
+
22
+ if ! executable (s: VimuxOption (' VimuxTmuxCommand' ))
23
+ echohl ErrorMsg | echomsg ' Failed to find executable ' .s: VimuxOption (' VimuxTmuxCommand' ) | echohl None
20
24
finish
21
25
endif
22
26
@@ -60,7 +64,7 @@ function! VimuxRunCommand(command, ...)
60
64
let l: autoreturn = a: 1
61
65
endif
62
66
63
- let resetSequence = g: VimuxResetSequence
67
+ let resetSequence = s: VimuxOption ( ' VimuxResetSequence' )
64
68
let g: VimuxLastCommand = a: command
65
69
66
70
call VimuxSendKeys (resetSequence)
@@ -86,67 +90,67 @@ endfunction
86
90
function ! VimuxOpenRunner ()
87
91
let nearestIndex = s: VimuxNearestIndex ()
88
92
89
- if g: VimuxUseNearest == # 1 && nearestIndex != -1
93
+ if s: VimuxOption ( ' VimuxUseNearest' ) == # 1 && nearestIndex != -1
90
94
let g: VimuxRunnerIndex = nearestIndex
91
95
else
92
- let extraArguments = g: VimuxOpenExtraArgs
93
- if g: VimuxRunnerType == # ' pane'
94
- let height = g: VimuxHeight
95
- let orientation = g: VimuxOrientation
96
+ let extraArguments = s: VimuxOption ( ' VimuxOpenExtraArgs' )
97
+ if s: VimuxOption ( ' VimuxRunnerType' ) == # ' pane'
98
+ let height = s: VimuxOption ( ' VimuxHeight' )
99
+ let orientation = s: VimuxOption ( ' VimuxOrientation' )
96
100
call s: VimuxTmux (' split-window -p ' .height.' -' .orientation.' ' .extraArguments)
97
- elseif g: VimuxRunnerType == # ' window'
101
+ elseif s: VimuxOption ( ' VimuxRunnerType' ) == # ' window'
98
102
call s: VimuxTmux (' new-window ' .extraArguments)
99
103
endif
100
104
101
105
let g: VimuxRunnerIndex = s: VimuxTmuxIndex ()
102
106
call s: VimuxSetRunnerName ()
103
- call s: VimuxTmux (' last-' .g: VimuxRunnerType )
107
+ call s: VimuxTmux (' last-' .s: VimuxOption ( ' VimuxRunnerType' ) )
104
108
endif
105
109
endfunction
106
110
107
111
function ! VimuxCloseRunner ()
108
112
if exists (' g:VimuxRunnerIndex' )
109
- call s: VimuxTmux (' kill-' .g: VimuxRunnerType .' -t ' .g: VimuxRunnerIndex )
113
+ call s: VimuxTmux (' kill-' .s: VimuxOption ( ' VimuxRunnerType' ) .' -t ' .g: VimuxRunnerIndex )
110
114
unlet g: VimuxRunnerIndex
111
115
endif
112
116
endfunction
113
117
114
118
function ! VimuxTogglePane ()
115
119
if exists (' g:VimuxRunnerIndex' )
116
- if g: VimuxRunnerType == # ' window'
117
- call s: VimuxTmux (' join-pane -d -s ' .g: VimuxRunnerIndex .' -p ' .g: VimuxHeight )
118
- let g: VimuxRunnerType = ' pane'
119
- elseif g: VimuxRunnerType == # ' pane'
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'
120
124
let g: VimuxRunnerIndex= substitute (s: VimuxTmux (' break-pane -d -t ' .g: VimuxRunnerIndex ." -P -F '#{window_id}'" ), ' \n' , ' ' , ' ' )
121
- let g: VimuxRunnerType = ' window'
125
+ let s: VimuxOption ( ' VimuxRunnerType' ) = ' window'
122
126
endif
123
127
endif
124
128
endfunction
125
129
126
130
function ! VimuxZoomRunner ()
127
131
if exists (' g:VimuxRunnerIndex' )
128
- if g: VimuxRunnerType == # ' pane'
132
+ if s: VimuxOption ( ' VimuxRunnerType' ) == # ' pane'
129
133
call s: VimuxTmux (' resize-pane -Z -t ' .g: VimuxRunnerIndex )
130
- elseif g: VimuxRunnerType == # ' window'
134
+ elseif s: VimuxOption ( ' VimuxRunnerType' ) == # ' window'
131
135
call s: VimuxTmux (' select-window -t ' .g: VimuxRunnerIndex )
132
136
endif
133
137
endif
134
138
endfunction
135
139
136
140
function ! VimuxInspectRunner ()
137
- call s: VimuxTmux (' select-' .g: VimuxRunnerType .' -t ' .g: VimuxRunnerIndex )
141
+ call s: VimuxTmux (' select-' .s: VimuxOption ( ' VimuxRunnerType' ) .' -t ' .g: VimuxRunnerIndex )
138
142
call s: VimuxTmux (' copy-mode' )
139
143
endfunction
140
144
141
145
function ! VimuxScrollUpInspect ()
142
146
call VimuxInspectRunner ()
143
- call s: VimuxTmux (' last-' .g: VimuxRunnerType )
147
+ call s: VimuxTmux (' last-' .s: VimuxOption ( ' VimuxRunnerType' ) )
144
148
call VimuxSendKeys (' C-u' )
145
149
endfunction
146
150
147
151
function ! VimuxScrollDownInspect ()
148
152
call VimuxInspectRunner ()
149
- call s: VimuxTmux (' last-' .g: VimuxRunnerType )
153
+ call s: VimuxTmux (' last-' .s: VimuxOption ( ' VimuxRunnerType' ) )
150
154
call VimuxSendKeys (' C-d' )
151
155
endfunction
152
156
@@ -168,23 +172,23 @@ endfunction
168
172
169
173
function ! VimuxPromptCommand (... )
170
174
let command = a: 0 == # 1 ? a: 1 : ' '
171
- let l: command = input (g: VimuxPromptString , command , ' shellcmd' )
175
+ let l: command = input (s: VimuxOption ( ' VimuxPromptString' ) , command , ' shellcmd' )
172
176
call VimuxRunCommand (l: command )
173
177
endfunction
174
178
175
179
function ! s: VimuxTmux (arguments)
176
- if g: VimuxDebug
177
- echom g: VimuxTmuxCommand .' ' .a: arguments
180
+ if s: VimuxOption ( ' VimuxDebug' )
181
+ echom s: VimuxOption ( ' VimuxTmuxCommand' ) .' ' .a: arguments
178
182
endif
179
- return system (g: VimuxTmuxCommand .' ' .a: arguments )
183
+ return system (s: VimuxOption ( ' VimuxTmuxCommand' ) .' ' .a: arguments )
180
184
endfunction
181
185
182
186
function ! s: VimuxTmuxSession ()
183
187
return s: VimuxTmuxProperty (' #S' )
184
188
endfunction
185
189
186
190
function ! s: VimuxTmuxIndex ()
187
- if g: VimuxRunnerType == # ' pane'
191
+ if s: VimuxOption ( ' VimuxRunnerType' ) == # ' pane'
188
192
return s: VimuxTmuxPaneId ()
189
193
else
190
194
return s: VimuxTmuxWindowId ()
@@ -200,7 +204,7 @@ function! s:VimuxTmuxWindowId()
200
204
endfunction
201
205
202
206
function ! s: VimuxNearestIndex ()
203
- let t = g: VimuxRunnerType
207
+ let t = s: VimuxOption ( ' VimuxRunnerType' )
204
208
let filter = s: VimuxGetTargetFilter ()
205
209
let views = split (s: VimuxTmux (' list-' .t ." s -F '#{" .t .' _active}:#{' .t ." _id}'" .filter ), ' \n' )
206
210
@@ -214,11 +218,11 @@ function! s:VimuxNearestIndex()
214
218
endfunction
215
219
216
220
function ! s: VimuxGetTargetFilter ()
217
- let targetName = g: VimuxRunnerName
221
+ let targetName = s: VimuxOption ( ' VimuxRunnerName' )
218
222
if targetName == # ' '
219
223
return ' '
220
224
endif
221
- let t = g: VimuxRunnerType
225
+ let t = s: VimuxOption ( ' VimuxRunnerType' )
222
226
if t == # ' window'
223
227
return " -f '#{==:#{window_name}," .targetName." }'"
224
228
elseif t == # ' pane'
@@ -227,11 +231,11 @@ function! s:VimuxGetTargetFilter()
227
231
endfunction
228
232
229
233
function ! s: VimuxSetRunnerName ()
230
- let targetName = g: VimuxRunnerName
234
+ let targetName = s: VimuxOption ( ' VimuxRunnerName' )
231
235
if targetName == # ' '
232
236
return
233
237
endif
234
- let t = g: VimuxRunnerType
238
+ let t = s: VimuxOption ( ' VimuxRunnerType' )
235
239
if t == # ' window'
236
240
call s: VimuxTmux (' rename-window ' .targetName)
237
241
elseif t == # ' pane'
@@ -244,6 +248,6 @@ function! s:VimuxTmuxProperty(property)
244
248
endfunction
245
249
246
250
function ! s: VimuxHasRunner (index )
247
- let t = g: VimuxRunnerType
251
+ let t = s: VimuxOption ( ' VimuxRunnerType' )
248
252
return match (s: VimuxTmux (' list-' .t ." s -F '#{" .t ." _id}'" ), a: index )
249
253
endfunction
0 commit comments