File tree Expand file tree Collapse file tree 5 files changed +37
-38
lines changed Expand file tree Collapse file tree 5 files changed +37
-38
lines changed Original file line number Diff line number Diff line change @@ -40,23 +40,18 @@ neovim-client.nvim=> (api/command ":echo 'Hello Neovim!'")
40
40
41
41
[ ![ Repling Neovim] ( http://img.youtube.com/vi/g-9DdVwbSTo/0.jpg )] ( https://www.youtube.com/watch?v=g-9DdVwbSTo )
42
42
43
- ### Sample Plugins
43
+ ### Examples
44
44
45
- Several sample plugins -- consumers of neovim-client -- are included.
45
+ #### Included Sample Plugin
46
46
47
- #### Installation
47
+ ##### Installation
48
48
49
- While these plugins can be installed locally, the easiest thing to do is to
50
- run them from the repl, as described above. Simply use ` lein repl ` from the
51
- plugin project's root directory.
49
+ One way to install the sample plugin is by running ` ./deploy-local.sh ` script,
50
+ included, which copies the sample plugin to ` ~/.vim/bundle ` , and then ensure
51
+ Neovim's runtimepath is set correctly by adding `set
52
+ runtimepath^=~ /.vim/bundle/sample-plugin` to ` .vimrc`.
52
53
53
- #### Simple Plugin
54
-
55
- ```
56
- :call RunSamplePluginSimple()
57
- ```
58
-
59
- #### Count Plugin
54
+ ##### Running
60
55
61
56
This plugin stays running, and maintains state. Additionally, it shows how
62
57
plugins are actually servers, which Neovim can make requests to via
Original file line number Diff line number Diff line change
1
+ lein uberjar
2
+ cp target/uberjar/sample-plugin-0.1.0-standalone.jar .
3
+ rm -rf ~ /.vim/bundle/sample-plugin
4
+ cd ..
5
+ cp -rf sample-plugin ~ /.vim/bundle
Original file line number Diff line number Diff line change 1
1
let s: p_dir = expand (' <sfile>:p:h' )
2
- let g: is_running = 0
3
- let g: channel = -1
2
+ let g: sample_is_running = 0
3
+ let g: nvim_tcp_plugin_channel = 0
4
4
5
- function ! StartIfNotRunning ()
6
- if g: is_running == 0
5
+ function ! SampleStartIfNotRunning ()
6
+ if g: sample_is_running == 0
7
7
echo ' starting plugin...'
8
- " TODO - This is a dirty hack. We should launch things without changing
9
- " the working directory.
10
- exec ' :cd ' . s: p_dir
11
- let g: channel = rpcstart (' lein' , [' run' ])
12
- let g: is_running = 1
8
+ let jar_file_path = s: p_dir . ' /../' . ' sample-plugin-0.1.0-standalone.jar'
9
+ call jobstart ([' java' , ' -jar' , jar_file_path], {' rpc' : v: true })
10
+ let g: sample_is_running = 1
13
11
endif
14
12
endfunction
15
13
16
14
function ! SamplePluginCount ()
17
- call StartIfNotRunning ()
18
- let res = rpcrequest (g: channel , ' count' , [])
15
+ call SampleStartIfNotRunning ()
16
+ let res = rpcnotify (g: nvim_tcp_plugin_channel , ' count' , [])
19
17
return res
20
18
endfunction
21
19
Original file line number Diff line number Diff line change 1
- (defproject sample-plugin " 0.1.0-SNAPSHOT "
2
- :description " FIXME: write description "
3
- :url " http ://example .com/FIXME "
1
+ (defproject sample-plugin " 0.1.0"
2
+ :description " Sample Neovim plugin "
3
+ :url " https ://github .com/clojure-vim/neovim-client "
4
4
:license {:name " Eclipse Public License"
5
5
:url " http://www.eclipse.org/legal/epl-v10.html" }
6
- :dependencies [[org.clojure/clojure " 1.6 .0" ]
7
- [neovim-client " 0.1.0-SNAPSHOT " ]]
6
+ :dependencies [[org.clojure/clojure " 1.8 .0" ]
7
+ [neovim-client " 0.1.0" ]]
8
8
:main ^:skip-aot sample-plugin.core
9
9
:target-path " target/%s"
10
10
:profiles {:uberjar {:aot :all }})
Original file line number Diff line number Diff line change 1
1
(ns sample-plugin.core
2
- (:require [neovim-client.nvim :as nvim])
2
+ (:require
3
+ [neovim-client.1.api :as api]
4
+ [neovim-client.nvim :as nvim])
3
5
(:gen-class ))
4
6
5
7
(defn -main
6
8
[& args]
7
- (let [nvim (nvim/new )
9
+ (let [nvim (nvim/new 1 )
8
10
x (atom 0 )]
9
11
(nvim/register-method!
10
12
nvim
11
13
" count"
12
14
(fn [msg]
13
15
; ; Plugin can call back to nvim if it wants to, while
14
16
; ; its doing its own thing.
15
- (nvim/vim-command-async nvim
16
- " :echo 'incrementing'"
17
- (fn [_] nil ))
18
17
(swap! x inc)
19
- @x))
18
+ (api/command-async nvim
19
+ (format " :echo 'incrementing ... %s'" @x)
20
+ (fn [_] nil ))))
20
21
21
22
; ; Stay alive for a minute!
22
23
(dotimes [n 60 ]
23
24
(if (= 0 (mod n 10 ))
24
- (nvim/vim- command nvim (str " :echo 'plugin alive for " n " seconds.'" )))
25
+ (api/ command nvim (str " :echo 'plugin alive for " n " seconds.'" )))
25
26
(Thread/sleep 1000 ))
26
27
27
28
; ; Let nvim know we're shutting down.
28
- (nvim/vim- command nvim " :let g:is_running=0" )
29
- (nvim/vim- command nvim " :echo 'plugin stopping.'" )))
29
+ (api/ command nvim " :let g:is_running=0" )
30
+ (api/ command nvim " :echo 'plugin stopping.'" )))
You can’t perform that action at this time.
0 commit comments