Skip to content

Commit 43681e9

Browse files
committed
refactor: Simplify script-local private function names
1 parent 6017491 commit 43681e9

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

plugin/vimux.vim

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function! VimuxOption(option, default)
1111
endif
1212
endfunction
1313

14-
function! s:VimuxTmuxCmd()
14+
function! s:tmuxCmd()
1515
return VimuxOption('g:VimuxTmuxCommand', 'tmux')
1616
endfunction
1717

18-
if !executable(s:VimuxTmuxCmd())
19-
echohl ErrorMsg | echomsg 'Failed to find executable '.s:VimuxTmuxCmd() | echohl None
18+
if !executable(s:tmuxCmd())
19+
echohl ErrorMsg | echomsg 'Failed to find executable '.s:tmuxCmd() | 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') || s:VimuxHasRunner(g:VimuxRunnerIndex) ==# -1
54+
if !exists('g:VimuxRunnerIndex') || s:hasRunner(g:VimuxRunnerIndex) ==# -1
5555
call VimuxOpenRunner()
5656
endif
5757

@@ -77,76 +77,76 @@ endfunction
7777

7878
function! VimuxSendKeys(keys)
7979
if exists('g:VimuxRunnerIndex')
80-
call s:VimuxTmux('send-keys -t '.g:VimuxRunnerIndex.' '.a:keys)
80+
call s:tmux('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 = s:VimuxNearestIndex()
87+
let nearestIndex = s:nearestIndex()
8888

8989
if VimuxOption('g:VimuxUseNearest', 1) ==# 1 && nearestIndex != -1
9090
let g:VimuxRunnerIndex = nearestIndex
9191
else
9292
let extraArguments = VimuxOption('g:VimuxOpenExtraArgs', '')
93-
if s:VimuxRunnerType() ==# 'pane'
93+
if s:runnerType() ==# 'pane'
9494
let height = VimuxOption('g:VimuxHeight', 20)
9595
let orientation = 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)
96+
call s:tmux('split-window -p '.height.' -'.orientation.' '.extraArguments)
97+
elseif s:runnerType() ==# 'window'
98+
call s:tmux('new-window '.extraArguments)
9999
endif
100100

101-
let g:VimuxRunnerIndex = s:VimuxTmuxIndex()
102-
call s:VimuxSetRunnerName()
103-
call s:VimuxTmux('last-'.s:VimuxRunnerType())
101+
let g:VimuxRunnerIndex = s:tmuxIndex()
102+
call s:setRunnerName()
103+
call s:tmux('last-'.s:runnerType())
104104
endif
105105
endfunction
106106

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

114114
function! VimuxTogglePane()
115115
if exists('g:VimuxRunnerIndex')
116-
if s:VimuxRunnerType() ==# 'window'
117-
call s:VimuxTmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20))
116+
if s:runnerType() ==# 'window'
117+
call s:tmux('join-pane -d -s '.g:VimuxRunnerIndex.' -p '.VimuxOption('g:VimuxHeight', 20))
118118
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', '', '')
119+
elseif s:runnerType() ==# 'pane'
120+
let g:VimuxRunnerIndex=substitute(s:tmux('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 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)
128+
if s:runnerType() ==# 'pane'
129+
call s:tmux('resize-pane -Z -t '.g:VimuxRunnerIndex)
130+
elseif s:runnerType() ==# 'window'
131+
call s:tmux('select-window -t '.g:VimuxRunnerIndex)
132132
endif
133133
endif
134134
endfunction
135135

136136
function! VimuxInspectRunner()
137-
call s:VimuxTmux('select-'.s:VimuxRunnerType().' -t '.g:VimuxRunnerIndex)
138-
call s:VimuxTmux('copy-mode')
137+
call s:tmux('select-'.s:runnerType().' -t '.g:VimuxRunnerIndex)
138+
call s:tmux('copy-mode')
139139
endfunction
140140

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

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

@@ -162,7 +162,7 @@ endfunction
162162

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

@@ -172,37 +172,37 @@ function! VimuxPromptCommand(...)
172172
call VimuxRunCommand(l:command)
173173
endfunction
174174

175-
function! s:VimuxTmux(arguments)
175+
function! s:tmux(arguments)
176176
if VimuxOption('g:VimuxDebug', 0) != 0
177-
echom s:VimuxTmuxCmd().' '.a:arguments
177+
echom s:tmuxCmd().' '.a:arguments
178178
endif
179-
return system(s:VimuxTmuxCmd().' '.a:arguments)
179+
return system(s:tmuxCmd().' '.a:arguments)
180180
endfunction
181181

182-
function! s:VimuxTmuxSession()
183-
return s:VimuxTmuxProperty('#S')
182+
function! s:tmuxSession()
183+
return s:tmuxProperty('#S')
184184
endfunction
185185

186-
function! s:VimuxTmuxIndex()
187-
if s:VimuxRunnerType() ==# 'pane'
188-
return s:VimuxTmuxPaneId()
186+
function! s:tmuxIndex()
187+
if s:runnerType() ==# 'pane'
188+
return s:tmuxPaneId()
189189
else
190-
return s:VimuxTmuxWindowId()
190+
return s:tmuxWindowId()
191191
end
192192
endfunction
193193

194-
function! s:VimuxTmuxPaneId()
195-
return s:VimuxTmuxProperty('#{pane_id}')
194+
function! s:tmuxPaneId()
195+
return s:tmuxProperty('#{pane_id}')
196196
endfunction
197197

198-
function! s:VimuxTmuxWindowId()
199-
return s:VimuxTmuxProperty('#{window_id}')
198+
function! s:tmuxWindowId()
199+
return s:tmuxProperty('#{window_id}')
200200
endfunction
201201

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')
202+
function! s:nearestIndex()
203+
let t = s:runnerType()
204+
let filter = s:getTargetFilter()
205+
let views = split(s:tmux('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! s:VimuxNearestIndex()
213213
return -1
214214
endfunction
215215

216-
function! s:VimuxGetTargetFilter()
216+
function! s:getTargetFilter()
217217
let targetName = VimuxOption('g:VimuxRunnerName', '')
218218
if targetName ==# ''
219219
return ''
220220
endif
221-
let t = s:VimuxRunnerType()
221+
let t = s:runnerType()
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! s:VimuxSetRunnerName()
229+
function! s:setRunnerName()
230230
let targetName = VimuxOption('g:VimuxRunnerName', '')
231231
if targetName ==# ''
232232
return
233233
endif
234-
let t = s:VimuxRunnerType()
234+
let t = s:runnerType()
235235
if t ==# 'window'
236-
call s:VimuxTmux('rename-window '.targetName)
236+
call s:tmux('rename-window '.targetName)
237237
elseif t ==# 'pane'
238-
call s:VimuxTmux('select-pane -T '.targetName)
238+
call s:tmux('select-pane -T '.targetName)
239239
endif
240240
endfunction
241241

242242

243-
function! s:VimuxRunnerType()
243+
function! s:runnerType()
244244
return VimuxOption('g:VimuxRunnerType', 'pane')
245245
endfunction
246246

247-
function! s:VimuxTmuxProperty(property)
248-
return substitute(s:VimuxTmux("display -p '".a:property."'"), '\n$', '', '')
247+
function! s:tmuxProperty(property)
248+
return substitute(s:tmux("display -p '".a:property."'"), '\n$', '', '')
249249
endfunction
250250

251-
function! s:VimuxHasRunner(index)
252-
let t = s:VimuxRunnerType()
253-
return match(s:VimuxTmux('list-'.t."s -F '#{".t."_id}'"), a:index)
251+
function! s:hasRunner(index)
252+
let t = s:runnerType()
253+
return match(s:tmux('list-'.t."s -F '#{".t."_id}'"), a:index)
254254
endfunction

0 commit comments

Comments
 (0)