Skip to content

Commit 04f950d

Browse files
committed
Add command to eval current buffer's ns declaration
1 parent d367540 commit 04f950d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/socket_repl/socket_repl_plugin.clj

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[clojure.core.async :as async]
66
[clojure.java.io :as io]
77
[clojure.string :as string]
8+
[clojure.tools.namespace.find :as namespace.find]
89
[clojure.tools.logging :as log]
910
[neovim-client.1.api :as api]
1011
[neovim-client.1.api.buffer :as api.buffer]
@@ -231,6 +232,18 @@
231232
(log/info (:val res))
232233
(.close res-chan))))))))
233234

235+
(nvim/register-method!
236+
nvim
237+
"eval-buffer-ns"
238+
(run-command
239+
plugin
240+
(fn [msg]
241+
(let [buffer-name (api/get-current-buf nvim)
242+
file-name (api.buffer/get-name nvim buffer-name)
243+
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))))))
246+
234247
(nvim/register-method!
235248
nvim
236249
"show-log"

0 commit comments

Comments
 (0)