Skip to content

Commit 1600696

Browse files
committed
Update to use neovim-client 0.1.0
1 parent 5497e8a commit 1600696

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
javax.jms/jms
1212
com.sun.jmdk/jmxtools
1313
com.sun.jmx/jmxri]]
14-
[neovim-client "0.1.0-SNAPSHOT"]]
14+
[neovim-client "0.1.0"]]
1515
:main ^:skip-aot socket-repl.system
1616
:target-path "target/%s"
1717
:profiles {:uberjar {:aot [clojure.tools.logging.impl
10.9 KB
Binary file not shown.

src/socket_repl/socket_repl_plugin.clj

+28-23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[clojure.java.io :as io]
77
[clojure.string :as string]
88
[clojure.tools.logging :as log]
9+
[neovim-client.1.api :as api]
10+
[neovim-client.1.api.buffer :as api.buffer]
11+
[neovim-client.1.api.buffer-ext :as api.buffer-ext]
12+
[neovim-client.1.api-ext :as api-ext]
913
[neovim-client.message :as message]
1014
[neovim-client.nvim :as nvim]
1115
[socket-repl.nrepl :as nrepl]
@@ -49,7 +53,7 @@
4953
(if-not (or (socket-repl/connected? socket-repl)
5054
(nrepl/connected? nrepl))
5155
(async/thread
52-
(nvim/vim-command
56+
(api/command
5357
nvim ":echo 'Use :Connect host:port to connect to a socket repl'"))
5458
(async/thread (f msg)))
5559
;; Don't return an async channel, return something msg-pack can serialize.
@@ -58,21 +62,21 @@
5862
(defn get-rlog-buffer
5963
"Returns the buffer w/ b:rlog set, if one exists."
6064
[nvim]
61-
(some->> (nvim/vim-get-buffers nvim)
62-
(filter #(nvim/buffer-get-var nvim % "rlog"))
65+
(some->> (api/list-bufs nvim)
66+
(filter #(api.buffer/get-var nvim % "rlog"))
6367
first))
6468

6569
(defn get-rlog-buffer-name
6670
"Returns the name of the buffer w/ b:rlog set, if one exists."
6771
[nvim]
6872
(let [buffer (get-rlog-buffer nvim)]
69-
(when buffer (nvim/buffer-get-name nvim buffer))))
73+
(when buffer (api.buffer/get-name nvim buffer))))
7074

7175
(defn get-rlog-buffer-number
7276
"Returns the number of the buffer w/ b:rlog set, if one exists."
7377
[nvim]
7478
(let [buffer (get-rlog-buffer nvim)]
75-
(when buffer (nvim/buffer-get-number nvim buffer))))
79+
(when buffer (api.buffer/get-number nvim buffer))))
7680

7781
(defn code-channel
7882
[plugin]
@@ -102,7 +106,7 @@
102106
(socket-repl/connect socket-repl host port)
103107
(catch Throwable t
104108
(log/error t "Error connecting to socket repl")
105-
(async/thread (nvim/vim-command
109+
(async/thread (api/command
106110
nvim
107111
":echo 'Unable to connect to socket repl.'"))))
108112
:done)))
@@ -120,7 +124,7 @@
120124
(nrepl/connect nrepl host port)
121125
(catch Throwable t
122126
(log/error t "Error connecting to nrepl")
123-
(async/thread (nvim/vim-command
127+
(async/thread (api/command
124128
nvim
125129
":echo 'Unable to connect to nrepl.'"))))
126130
:done)))
@@ -131,8 +135,8 @@
131135
(run-command
132136
plugin
133137
(fn [msg]
134-
(let [coords (nvim/get-cursor-location nvim)
135-
buffer-text (nvim/get-current-buffer-text nvim)]
138+
(let [coords (api-ext/get-cursor-location nvim)
139+
buffer-text (api-ext/get-current-buffer-text nvim)]
136140
(try
137141
(async/>!! code-channel (get-form-at buffer-text coords))
138142
(catch Throwable t
@@ -145,15 +149,15 @@
145149
(run-command
146150
plugin
147151
(fn [msg]
148-
(let [buffer (nvim/vim-get-current-buffer nvim)
149-
filename (nvim/buffer-get-name nvim buffer)]
152+
(let [buffer (api/get-current-buf nvim)
153+
filename (api.buffer/get-name nvim buffer)]
150154
(if (.exists (io/as-file filename))
151155
(do
152156
;; Not sure if saving the file is really always what we want,
153157
;; but if we don't, stale data will be loaded.
154-
(nvim/vim-command nvim ":w")
158+
(api/command nvim ":w")
155159
(async/>!! code-channel (format "(load-file \"%s\")" filename)))
156-
(let [code (string/join "\n" (nvim/buffer-get-line-slice
160+
(let [code (string/join "\n" (api.buffer-ext/get-lines
157161
nvim buffer 0 -1))]
158162
(async/>!! code-channel (format "(eval '(do %s))" code))))))))
159163

@@ -163,7 +167,7 @@
163167
(run-command
164168
plugin
165169
(fn [msg]
166-
(nvim/get-current-word-async
170+
(api-ext/get-current-word-async
167171
nvim
168172
(fn [word]
169173
(let [code (format "(clojure.repl/doc %s)" word)]
@@ -176,31 +180,32 @@
176180
plugin
177181
(fn [msg]
178182
(let [file (-> repl-log repl-log/file .getAbsolutePath)]
179-
(let [original-window (nvim/vim-get-current-window nvim)
183+
(let [original-window (api/get-current-win nvim)
180184
buffer-cmd (first (message/params msg))
181185
rlog-buffer (get-rlog-buffer-name nvim)
182186
rlog-buffer-visible? (when rlog-buffer
183-
(async/<!! (nvim/buffer-visible?-async
184-
nvim rlog-buffer)))]
187+
(async/<!!
188+
(api-ext/buffer-visible?-async
189+
nvim rlog-buffer)))]
185190
(when-not rlog-buffer-visible?
186-
(nvim/vim-command
191+
(api/command
187192
nvim
188193
(format "%s | nnoremap <buffer> q :q<cr> | :let b:rlog=1 | :call termopen('tail -f %s') | :set ft=clojurerepl"
189194
buffer-cmd file))
190-
(nvim/vim-set-current-window nvim original-window)))))))
195+
(api/set-current-win nvim original-window)))))))
191196

192197
(nvim/register-method!
193198
nvim
194199
"dismiss-log"
195200
(run-command
196201
plugin
197202
(fn [msg]
198-
(nvim/vim-command
203+
(api/command
199204
nvim (format "bd! %s" (get-rlog-buffer-number nvim))))))
200205

201206
(async/thread
202-
(nvim/vim-command nvim "let g:socket_repl_plugin_ready = 1")
203-
(nvim/vim-command nvim "echo 'SocketREPL plugin ready'"))
207+
(api/command nvim "let g:socket_repl_plugin_ready = 1")
208+
(api/command nvim "echo 'SocketREPL plugin ready'"))
204209

205210
plugin))
206211

@@ -210,7 +215,7 @@
210215
"plugin"
211216

212217
;; Close the repl log buffer
213-
(nvim/vim-command
218+
(api/command
214219
nvim (format "bd! %s" (get-rlog-buffer-number nvim)))
215220

216221
(async/close! (:code-channel plugin))

src/socket_repl/system.clj

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
(defn new-system
2626
([]
2727
(log/info "starting plugin using STDIO")
28-
(new-system* (nvim/new)))
28+
(new-system* (nvim/new 1)))
2929
([uds-filepath]
3030
(log/info "starting plugin using UDS" uds-filepath)
31-
(new-system* (nvim/new uds-filepath)))
31+
(new-system* (nvim/new 1 uds-filepath)))
3232
([host port]
3333
(log/info (format "starting plugin using TCP socket %s:%s" host port))
34-
(new-system* (nvim/new host port))))
34+
(new-system* (nvim/new 1 host port))))
3535

3636
(defn stop
3737
[{:keys [nvim plugin repl-log socket-repl] :as system}]

0 commit comments

Comments
 (0)