1- let g:is_running = 0
2- let g:channel = 0
3-
4- "When the plugin is restarted at the repl, it reconnects, using the next
5- "available channel.
6- function! PluginRestart()
7- let g:is_running = 0
8- endfunction
1+ let g:nvim_tcp_plugin_channel = 0
92
103function! StartIfNotRunning()
11- if g:is_running == 0
12- let g:is_running = 1
13- let g:channel = g:channel + 1
14- endif
154endfunction
165
176function! Connect(host_colon_port)
@@ -21,45 +10,45 @@ function! Connect(host_colon_port)
2110 else
2211 let conn = a:host_colon_port
2312 endif
24- let res = rpcrequest(g:channel , 'connect', conn)
13+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'connect', conn)
2514 return res
2615endfunction
2716command! -nargs=? Connect call Connect("<args>")
2817
2918function! EvalBuffer()
3019 call StartIfNotRunning()
3120 ReplLog
32- let res = rpcrequest(g:channel , 'eval-buffer', [])
21+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'eval-buffer', [])
3322 return res
3423endfunction
3524command! EvalBuffer call EvalBuffer()
3625
3726function! EvalCode()
3827 call StartIfNotRunning()
3928 ReplLog
40- let res = rpcrequest(g:channel , 'eval-code', [])
29+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'eval-code', [])
4130 return res
4231endfunction
4332command! EvalCode call EvalCode()
4433
4534function! ReplLog(buffer_cmd)
4635 call StartIfNotRunning()
47- let res = rpcrequest(g:channel , 'show-log', a:buffer_cmd)
36+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'show-log', a:buffer_cmd)
4837 return res
4938endfunction
5039command! ReplLog call ReplLog(':botright new')
5140
5241function! DismissReplLog()
5342 call StartIfNotRunning()
54- let res = rpcrequest(g:channel , 'dismiss-log', [])
43+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'dismiss-log', [])
5544 return res
5645endfunction
5746command! DismissReplLog call DismissReplLog()
5847
5948function! Doc()
6049 call StartIfNotRunning()
6150 ReplLog
62- let res = rpcrequest(g:channel , 'doc', [])
51+ let res = rpcrequest(g:nvim_tcp_plugin_channel , 'doc', [])
6352 return res
6453endfunction
6554command! Doc call Doc()
0 commit comments