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 88 [neovim-client.1.api.window :as api.window]))
99
1010(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"
1214 [nvim]
1315 (api.window/get-cursor nvim (api/get-current-win nvim)))
1416
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 22 (:require [clojure.test :as test :refer [deftest use-fixtures is]]
33 [neovim-client.1.api :as api]
44 [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]]))
257
268; ; TODO - this one will be hard to test. From the client-library's perspective,
279; ; it will always have access to standard out. If it runs at all, standard
6345 _ (api.buffer/set-lines conn b2 0 1 false [" bar" ])]
6446 (is (= [" foo" ] (api.buffer/get-lines conn b1 0 1 false )))
6547 (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