Skip to content

Commit 664813b

Browse files
committed
Added a few convenience functions
1 parent 9b01c6a commit 664813b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject neovim-client "0.1.1"
1+
(defproject neovim-client "0.1.2"
22
:description "Client library for the Neovim RPC API"
33
:url "https://github.com/clojure-vim/neovim-client"
44
:license {:name "Eclipse Public License"

src/neovim_client/1/api_ext.clj

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
(string/join "\n" (api.buffer-ext/get-lines
2121
nvim (api/get-current-buf nvim) 0 -1)))
2222

23+
(defn get-current-buffer-text-async
24+
"Convenience function to get the current buffer's text asynchronously."
25+
[nvim f]
26+
(api/get-current-buf-async
27+
nvim
28+
(fn [buf]
29+
(api.buffer-ext/get-lines-async
30+
nvim buf 0 -1
31+
(fn [lines] (f (string/join "\n" lines)))))))
32+
2333
(defn get-current-word-async
2434
"Get the current word asynchronously."
2535
[nvim f]
@@ -34,3 +44,9 @@
3444
#(api.window/get-buf nvim %))
3545
(api/list-wins nvim))]
3646
((set visible-buffers) buffer-name))))
47+
48+
(defn set-current-buffer-text
49+
"Sets the current buffer's contents."
50+
[nvim text]
51+
(api.buffer-ext/set-lines
52+
nvim (api/get-current-buf nvim) 0 -1 (string/split-lines text)))

test/neovim_client/nvim_test.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(is (thrown-with-msg?
2525
Throwable
2626
#"version not supported"
27-
(client.nvim/new* 2 in out false)))))
27+
(client.nvim/new* Integer/MAX_VALUE in out false)))))
2828

2929
(with-neovim
3030
(let [{:keys [in out]} *neovim*]

0 commit comments

Comments
 (0)