Skip to content

Commit e6fb662

Browse files
committed
Replace underscore convention with proper script-local scopes
1 parent 925ae23 commit e6fb662

File tree

1 file changed

+68
-68
lines changed

1 file changed

+68
-68
lines changed

plugin/vimux.vim

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ if exists("g:loaded_vimux") || &cp
33
endif
44
let g:loaded_vimux = 1
55

6-
function! _VimuxOption(option, default)
6+
function! s:VimuxOption(option, default)
77
if exists(a:option)
88
return eval(a:option)
99
else
1010
return a:default
1111
endif
1212
endfunction
1313

14-
function! _VimuxTmuxCmd()
15-
return _VimuxOption("g:VimuxTmuxCommand", "tmux")
14+
function! s:VimuxTmuxCmd()
15+
return s:VimuxOption("g:VimuxTmuxCommand", "tmux")
1616
endfunction
1717

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
2020
finish
2121
endif
2222

@@ -51,7 +51,7 @@ function! VimuxRunLastCommand()
5151
endfunction
5252

5353
function! VimuxRunCommand(command, ...)
54-
if !exists("g:VimuxRunnerIndex") || _VimuxHasRunner(g:VimuxRunnerIndex) == -1
54+
if !exists("g:VimuxRunnerIndex") || s:VimuxHasRunner(g:VimuxRunnerIndex) == -1
5555
call VimuxOpenRunner()
5656
endif
5757

@@ -60,7 +60,7 @@ function! VimuxRunCommand(command, ...)
6060
let l:autoreturn = a:1
6161
endif
6262

63-
let resetSequence = _VimuxOption("g:VimuxResetSequence", "q C-u")
63+
let resetSequence = s:VimuxOption("g:VimuxResetSequence", "q C-u")
6464
let g:VimuxLastCommand = a:command
6565

6666
call VimuxSendKeys(resetSequence)
@@ -77,76 +77,76 @@ endfunction
7777

7878
function! VimuxSendKeys(keys)
7979
if exists("g:VimuxRunnerIndex")
80-
call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
80+
call s:VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
8181
else
8282
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
8383
endif
8484
endfunction
8585

8686
function! VimuxOpenRunner()
87-
let nearestIndex = _VimuxNearestIndex()
87+
let nearestIndex = s:VimuxNearestIndex()
8888

89-
if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1
89+
if s:VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1
9090
let g:VimuxRunnerIndex = nearestIndex
9191
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)
9999
endif
100100

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())
104104
endif
105105
endfunction
106106

107107
function! VimuxCloseRunner()
108108
if exists("g:VimuxRunnerIndex")
109-
call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
109+
call s:VimuxTmux("kill-".s:VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
110110
unlet g:VimuxRunnerIndex
111111
endif
112112
endfunction
113113

114114
function! VimuxTogglePane()
115115
if exists("g:VimuxRunnerIndex")
116-
if _VimuxRunnerType() == "window"
117-
call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
116+
if s:VimuxRunnerType() == "window"
117+
call s:VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p ".s:VimuxOption("g:VimuxHeight", 20))
118118
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", "", "")
119+
elseif s:VimuxRunnerType() == "pane"
120+
let g:VimuxRunnerIndex=substitute(s:VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_id}'"), "\n", "", "")
121121
let g:VimuxRunnerType = "window"
122122
endif
123123
endif
124124
endfunction
125125

126126
function! VimuxZoomRunner()
127127
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)
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)
132132
endif
133133
endif
134134
endfunction
135135

136136
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")
139139
endfunction
140140

141141
function! VimuxScrollUpInspect()
142142
call VimuxInspectRunner()
143-
call _VimuxTmux("last-"._VimuxRunnerType())
143+
call s:VimuxTmux("last-".s:VimuxRunnerType())
144144
call VimuxSendKeys("C-u")
145145
endfunction
146146

147147
function! VimuxScrollDownInspect()
148148
call VimuxInspectRunner()
149-
call _VimuxTmux("last-"._VimuxRunnerType())
149+
call s:VimuxTmux("last-".s:VimuxRunnerType())
150150
call VimuxSendKeys("C-d")
151151
endfunction
152152

@@ -162,47 +162,47 @@ endfunction
162162

163163
function! VimuxClearRunnerHistory()
164164
if exists("g:VimuxRunnerIndex")
165-
call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex)
165+
call s:VimuxTmux("clear-history -t ".g:VimuxRunnerIndex)
166166
endif
167167
endfunction
168168

169169
function! VimuxPromptCommand(...)
170170
let command = a:0 == 1 ? a:1 : ""
171-
let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd')
171+
let l:command = input(s:VimuxOption("g:VimuxPromptString", "Command? "), command, 'shellcmd')
172172
call VimuxRunCommand(l:command)
173173
endfunction
174174

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
178178
endif
179-
return system(_VimuxTmuxCmd()." ".a:arguments)
179+
return system(s:VimuxTmuxCmd()." ".a:arguments)
180180
endfunction
181181

182-
function! _VimuxTmuxSession()
183-
return _VimuxTmuxProperty("#S")
182+
function! s:VimuxTmuxSession()
183+
return s:VimuxTmuxProperty("#S")
184184
endfunction
185185

186-
function! _VimuxTmuxIndex()
187-
if _VimuxRunnerType() == "pane"
188-
return _VimuxTmuxPaneId()
186+
function! s:VimuxTmuxIndex()
187+
if s:VimuxRunnerType() == "pane"
188+
return s:VimuxTmuxPaneId()
189189
else
190-
return _VimuxTmuxWindowId()
190+
return s:VimuxTmuxWindowId()
191191
end
192192
endfunction
193193

194-
function! _VimuxTmuxPaneId()
195-
return _VimuxTmuxProperty("#{pane_id}")
194+
function! s:VimuxTmuxPaneId()
195+
return s:VimuxTmuxProperty("#{pane_id}")
196196
endfunction
197197

198-
function! _VimuxTmuxWindowId()
199-
return _VimuxTmuxProperty("#{window_id}")
198+
function! s:VimuxTmuxWindowId()
199+
return s:VimuxTmuxProperty("#{window_id}")
200200
endfunction
201201

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")
206206

207207
for view in views
208208
if match(view, "1:") == -1
@@ -213,42 +213,42 @@ function! _VimuxNearestIndex()
213213
return -1
214214
endfunction
215215

216-
function! _VimuxGetTargetFilter()
217-
let targetName = _VimuxOption("g:VimuxRunnerName", "")
216+
function! s:VimuxGetTargetFilter()
217+
let targetName = s:VimuxOption("g:VimuxRunnerName", "")
218218
if targetName == ""
219219
return ""
220220
endif
221-
let t = _VimuxRunnerType()
221+
let t = s:VimuxRunnerType()
222222
if t == "window"
223223
return " -f '#{==:#{window_name},".targetName."}'"
224224
elseif t == "pane"
225225
return " -f '#{==:#{pane_title},".targetName."}'"
226226
endif
227227
endfunction
228228

229-
function! _VimuxSetRunnerName()
230-
let targetName = _VimuxOption("g:VimuxRunnerName", "")
229+
function! s:VimuxSetRunnerName()
230+
let targetName = s:VimuxOption("g:VimuxRunnerName", "")
231231
if targetName == ""
232232
return
233233
endif
234-
let t = _VimuxRunnerType()
234+
let t = s:VimuxRunnerType()
235235
if t == "window"
236-
call _VimuxTmux("rename-window ".targetName)
236+
call s:VimuxTmux("rename-window ".targetName)
237237
elseif t == "pane"
238-
call _VimuxTmux("select-pane -T ".targetName)
238+
call s:VimuxTmux("select-pane -T ".targetName)
239239
endif
240240
endfunction
241241

242242

243-
function! _VimuxRunnerType()
244-
return _VimuxOption("g:VimuxRunnerType", "pane")
243+
function! s:VimuxRunnerType()
244+
return s:VimuxOption("g:VimuxRunnerType", "pane")
245245
endfunction
246246

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$', '', '')
249249
endfunction
250250

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)
254254
endfunction

0 commit comments

Comments
 (0)