File tree Expand file tree Collapse file tree 4 files changed +45
-25
lines changed Expand file tree Collapse file tree 4 files changed +45
-25
lines changed Original file line number Diff line number Diff line change 8
8
[neovim-client.1.api.window :as api.window]))
9
9
10
10
(defn get-cursor-location
11
- " Gets the cursor's current position as a tuple (row, col)."
11
+ " Gets the cursor's current position as a tuple (row, col).
12
+ row - starts at 1
13
+ col - starts at 0"
12
14
[nvim]
13
15
(api.window/get-cursor nvim (api/get-current-win nvim)))
14
16
Original file line number Diff line number Diff line change
1
+ (ns neovim-client.1.api-ext-test
2
+ (:require [clojure.test :as test :refer [deftest use-fixtures is]]
3
+ [neovim-client.1.api :as api]
4
+ [neovim-client.1.api.buffer :as api.buffer]
5
+ [neovim-client.1.api-ext :as api-ext]
6
+ [neovim-client.nvim :as client.nvim]
7
+ [neovim-client.test-helper :refer [with-neovim]]))
8
+
9
+ (deftest get-cursor-location
10
+ (with-neovim
11
+ (let [{:keys [in out]} *neovim*
12
+ conn (client.nvim/new* 1 in out false )]
13
+ (api/command conn " norm ifoo\n bar\n baz" )
14
+ (let [[row col] (api-ext/get-cursor-location conn)]
15
+ (is (= row 3 ))
16
+ (is (= col 2 ))))))
17
+
18
+ ; ; TODO get-current-buffer-text
19
+ ; ; TODO get-current-word-async
20
+ ; ; TODO buffer-visible?-async
Original file line number Diff line number Diff line change 2
2
(:require [clojure.test :as test :refer [deftest use-fixtures is]]
3
3
[neovim-client.1.api :as api]
4
4
[neovim-client.1.api.buffer :as api.buffer]
5
- [neovim-client.nvim :as client.nvim]))
6
-
7
- (defn- neovim
8
- " Make a neovim subprocess."
9
- []
10
- (let [p (.exec (Runtime/getRuntime ) " nvim --embed" )]
11
- {:process p
12
- :in (.getInputStream p)
13
- :out (.getOutputStream p)}))
14
-
15
- (defn- stop-neovim
16
- [{:keys [process]}]
17
- (.destroy process))
18
-
19
- (defmacro with-neovim
20
- [& body]
21
- `(let [~'*neovim* (neovim )]
22
- (try
23
- ~@body
24
- (finally (stop-neovim ~'*neovim*)))))
5
+ [neovim-client.nvim :as client.nvim]
6
+ [neovim-client.test-helper :refer [with-neovim stop-neovim]]))
25
7
26
8
; ; TODO - this one will be hard to test. From the client-library's perspective,
27
9
; ; it will always have access to standard out. If it runs at all, standard
63
45
_ (api.buffer/set-lines conn b2 0 1 false [" bar" ])]
64
46
(is (= [" foo" ] (api.buffer/get-lines conn b1 0 1 false )))
65
47
(is (= [" bar" ] (api.buffer/get-lines conn b2 0 1 false )))))))
66
-
67
- #_(clojure.tools.namespace.repl/refresh )
68
- #_(clojure.test/run-tests 'neovim-client.nvim-test)
69
- #_(neovim-client.nvim-test/change-buffer-text )
Original file line number Diff line number Diff line change
1
+ (ns neovim-client.test-helper )
2
+
3
+ (defn neovim
4
+ " Make a neovim subprocess."
5
+ []
6
+ (let [p (.exec (Runtime/getRuntime ) " nvim --embed" )]
7
+ {:process p
8
+ :in (.getInputStream p)
9
+ :out (.getOutputStream p)}))
10
+
11
+ (defn stop-neovim
12
+ [{:keys [process]}]
13
+ (.destroy process))
14
+
15
+ (defmacro with-neovim
16
+ [& body]
17
+ `(let [~'*neovim* (neovim )]
18
+ (try
19
+ ~@body
20
+ (finally (stop-neovim ~'*neovim*)))))
You can’t perform that action at this time.
0 commit comments