Skip to content

Commit a159684

Browse files
committed
Make the functions script local
Anything we need to expose should be exposed through a command.
1 parent 7de8918 commit a159684

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

plugin/socketrepl.vim

+44-44
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ function! socketrepl#omnicomplete(findstart, base)
1818
endif
1919
endfunction
2020

21-
function! StartIfNotRunning()
21+
function! s:StartIfNotRunning()
2222
if g:is_running == 0
2323
echo 'Starting SocketREPL plugin...'
2424
let jar_file_path = s:p_dir . '/../' . 'socket-repl-plugin-0.1.0-standalone.jar'
2525
call jobstart(['java', '-jar', jar_file_path], {'rpc': v:true})
2626
let g:is_running = 1
2727
endif
2828
endfunction
29-
command! Start call StartIfNotRunning()
29+
command! Start call s:StartIfNotRunning()
3030

31-
function! Connect(host_colon_port, op_code)
31+
function! s:Connect(host_colon_port, op_code)
3232
if a:host_colon_port == ""
3333
let conn = "localhost:5555"
3434
else
@@ -42,45 +42,45 @@ function! Connect(host_colon_port, op_code)
4242
return res
4343
endfunction
4444

45-
function! ReadyConnect(host_colon_port, op_code)
45+
function! s:ReadyConnect(host_colon_port, op_code)
4646
if g:socket_repl_plugin_ready == 1
47-
call Connect(a:host_colon_port, a:op_code)
47+
call s:Connect(a:host_colon_port, a:op_code)
4848
else
4949
echo s:not_ready
5050
endif
5151
endfunction
52-
command! -nargs=? Connect call ReadyConnect("<args>", "connect")
53-
command! -nargs=? NConnect call ReadyConnect("<args>", "connect-nrepl")
52+
command! -nargs=? Connect call s:ReadyConnect("<args>", "connect")
53+
command! -nargs=? NConnect call s:ReadyConnect("<args>", "connect-nrepl")
5454

55-
function! EvalBuffer()
55+
function! s:EvalBuffer()
5656
ReplLog
5757
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'eval-buffer', [])
5858
return res
5959
endfunction
6060

61-
function! ReadyEvalBuffer()
61+
function! s:ReadyEvalBuffer()
6262
if g:socket_repl_plugin_ready == 1
63-
call EvalBuffer()
63+
call s:EvalBuffer()
6464
else
6565
echo s:not_ready
6666
endif
6767
endfunction
68-
command! EvalBuffer call ReadyEvalBuffer()
68+
command! EvalBuffer call s:ReadyEvalBuffer()
6969

70-
function! EvalForm()
70+
function! s:EvalForm()
7171
ReplLog
7272
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'eval-form', [])
7373
return res
7474
endfunction
7575

76-
function! ReadyEvalForm()
76+
function! s:ReadyEvalForm()
7777
if g:socket_repl_plugin_ready == 1
78-
call EvalForm()
78+
call s:EvalForm()
7979
else
8080
echo s:not_ready
8181
endif
8282
endfunction
83-
command! EvalForm call ReadyEvalForm()
83+
command! EvalForm call s:ReadyEvalForm()
8484

8585
" Thanks vim-fireplace!
8686
function! socketrepl#eval_complete(A, L, P) abort
@@ -89,7 +89,7 @@ function! socketrepl#eval_complete(A, L, P) abort
8989
return sort(map(socketrepl#omnicomplete(0, keyword), 'prefix . v:val.word'))
9090
endfunction
9191

92-
function! Eval()
92+
function! s:Eval()
9393
ReplLog
9494
call inputsave()
9595
let form = input('=> ', '', 'customlist,socketrepl#eval_complete')
@@ -98,42 +98,42 @@ function! Eval()
9898
return res
9999
endfunction
100100

101-
function! ReadyEval()
101+
function! s:ReadyEval()
102102
if g:socket_repl_plugin_ready == 1
103-
call Eval()
103+
call s:Eval()
104104
else
105105
echo s:not_ready
106106
endif
107107
endfunction
108-
command! Eval call ReadyEval()
108+
command! Eval call s:ReadyEval()
109109

110-
function! ReplLog(buffer_cmd)
110+
function! s:ReplLog(buffer_cmd)
111111
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'show-log', a:buffer_cmd)
112112
return res
113113
endfunction
114114

115-
function! ReadyReplLog(buffer_cmd)
115+
function! s:ReadyReplLog(buffer_cmd)
116116
if g:socket_repl_plugin_ready == 1
117-
call ReplLog(a:buffer_cmd)
117+
call s:ReplLog(a:buffer_cmd)
118118
else
119119
echo s:not_ready
120120
endif
121121
endfunction
122-
command! ReplLog call ReadyReplLog(':botright new')
122+
command! ReplLog call s:ReadyReplLog(':botright new')
123123

124-
function! DismissReplLog()
124+
function! s:DismissReplLog()
125125
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'dismiss-log', [])
126126
return res
127127
endfunction
128128

129-
function! ReadyDismissReplLog()
129+
function! s:ReadyDismissReplLog()
130130
if g:socket_repl_plugin_ready == 1
131-
call DismissReplLog()
131+
call s:DismissReplLog()
132132
else
133133
echo s:not_ready
134134
endif
135135
endfunction
136-
command! DismissReplLog call ReadyDismissReplLog()
136+
command! DismissReplLog call s:ReadyDismissReplLog()
137137

138138
function! s:Doc(symbol)
139139
ReplLog
@@ -150,22 +150,22 @@ function! s:ReadyDoc(symbol)
150150
endfunction
151151
command! -bar -nargs=1 -complete=customlist,socketrepl#eval_complete Doc :exe s:ReadyDoc(<q-args>)
152152

153-
function! DocCursor()
153+
function! s:DocCursor()
154154
ReplLog
155155
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'doc-cursor', [])
156156
return res
157157
endfunction
158158

159-
function! ReadyCursorDoc()
159+
function! s:ReadyCursorDoc()
160160
if g:socket_repl_plugin_ready == 1
161-
call DocCursor()
161+
call s:DocCursor()
162162
else
163163
echo s:not_ready
164164
endif
165165
endfunction
166-
command! DocCursor call ReadyCursorDoc()
166+
command! DocCursor call s:ReadyCursorDoc()
167167

168-
function! Source()
168+
function! s:Source()
169169
ReplLog
170170
call inputsave()
171171
let symbol = input('Source for: ')
@@ -174,42 +174,42 @@ function! Source()
174174
return res
175175
endfunction
176176

177-
function! ReadySource()
177+
function! s:ReadySource()
178178
if g:socket_repl_plugin_ready == 1
179-
call Source()
179+
call s:Source()
180180
else
181181
echo s:not_ready
182182
endif
183183
endfunction
184-
command! Source call ReadySource()
184+
command! Source call s:ReadySource()
185185

186-
function! SourceCursor()
186+
function! s:SourceCursor()
187187
ReplLog
188188
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'source-cursor', [])
189189
return res
190190
endfunction
191191

192-
function! ReadyCursorSource()
192+
function! s:ReadyCursorSource()
193193
if g:socket_repl_plugin_ready == 1
194-
call SourceCursor()
194+
call s:SourceCursor()
195195
else
196196
echo s:not_ready
197197
endif
198198
endfunction
199-
command! SourceCursor call ReadyCursorSource()
199+
command! SourceCursor call s:ReadyCursorSource()
200200

201-
function! SwitchBufferNS()
201+
function! s:SwitchBufferNS()
202202
call rpcnotify(g:nvim_tcp_plugin_channel, 'switch-buffer-ns', [])
203203
endfunction
204204

205-
function! ReadySwitchBufferNS()
205+
function! s:ReadySwitchBufferNS()
206206
if g:socket_repl_plugin_ready == 1
207-
call SwitchBufferNS()
207+
call s:SwitchBufferNS()
208208
else
209209
echo s:not_ready
210210
endif
211211
endfunction
212-
command! SwitchBufferNS call ReadySwitchBufferNS()
212+
command! SwitchBufferNS call s:ReadySwitchBufferNS()
213213

214214
augroup socketrepl_completion
215215
autocmd!
@@ -228,6 +228,6 @@ endif
228228

229229
if !exists('g:manually_start_socket_repl_plugin')
230230
if has("nvim")
231-
call StartIfNotRunning()
231+
call s:StartIfNotRunning()
232232
endif
233233
endif

0 commit comments

Comments
 (0)