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