File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ let s:p_dir = expand('<sfile>:p:h')
22let g: is_running = 0
33let g: socket_repl_plugin_ready = 0
44let g: nvim_tcp_plugin_channel = 0
5+ let g: eval_entire_ns_decl = 0 " 0 = SwitchBufferNS uses `in-ns`. 1 = SwitchBufferNS evals entire ns declaration
56
67let s: not_ready = " SocketREPL plugin not ready (starting)"
78
@@ -177,6 +178,19 @@ function! ReadyCursorSource()
177178endfunction
178179command ! SourceCursor call ReadyCursorSource ()
179180
181+ function ! SwitchBufferNS ()
182+ call rpcnotify (g: nvim_tcp_plugin_channel , ' switch-buffer-ns' , [])
183+ endfunction
184+
185+ function ! ReadySwitchBufferNS ()
186+ if g: socket_repl_plugin_ready == 1
187+ call SwitchBufferNS ()
188+ else
189+ echo s: not_ready
190+ endif
191+ endfunction
192+ command ! SwitchBufferNS call ReadySwitchBufferNS ()
193+
180194if ! exists (' g:disable_socket_repl_mappings' )
181195 nnoremap K :DocCursor<cr>
182196 nnoremap [d :SourceCursor<cr>
Original file line number Diff line number Diff line change 234234
235235 (nvim/register-method!
236236 nvim
237- " eval -buffer-ns"
237+ " switch -buffer-ns"
238238 (run-command
239239 plugin
240240 (fn [msg]
241241 (let [buffer-name (api/get-current-buf nvim)
242242 file-name (api.buffer/get-name nvim buffer-name)
243243 file (io/file file-name)
244- namespace-declarations (namespace.find/find-ns-decls-in-dir file)]
245- (async/>!! (socket-repl/input-channel socket-repl) (first namespace-declarations))))))
244+ namespace-declaration (first (namespace.find/find-ns-decls-in-dir file))
245+ eval-entire-declaration? (= 1 (api/get-var nvim " eval_entire_ns_decl" ))
246+ code-form (if eval-entire-declaration?
247+ namespace-declaration
248+ `(clojure.core/in-ns '~(second namespace-declaration)))]
249+ (async/>!! (socket-repl/input-channel socket-repl) code-form)))))
246250
247251 (nvim/register-method!
248252 nvim
You can’t perform that action at this time.
0 commit comments