Skip to content

Commit 6476ba0

Browse files
committed
Add UUID plugin
1 parent d747e69 commit 6476ba0

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

uuid-plugin/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/target
2+
/classes
3+
/checkouts
4+
pom.xml
5+
pom.xml.asc
6+
*.jar
7+
*.class
8+
/.lein-*
9+
/.nrepl-port
10+
.hgignore
11+
.hg/

uuid-plugin/plugin/sample.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let s:p_dir = expand('<sfile>:p:h')
2+
let g:is_running = 0
3+
let g:channel = -1
4+
5+
function! StartIfNotRunning()
6+
if g:is_running == 0
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
13+
endif
14+
endfunction
15+
16+
function! GetUUID()
17+
call StartIfNotRunning()
18+
let res = rpcrequest(g:channel, 'uuid', [])
19+
return res
20+
endfunction
21+
22+
echo 'uuid plugin loaded!'

uuid-plugin/project.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(defproject uuid-plugin "0.1.0-SNAPSHOT"
2+
:description "FIXME: write description"
3+
:url "http://example.com/FIXME"
4+
:license {:name "Eclipse Public License"
5+
:url "http://www.eclipse.org/legal/epl-v10.html"}
6+
:dependencies [[org.clojure/clojure "1.8.0"]
7+
[datascript "0.15.2"]
8+
[neovim-client "0.1.0-SNAPSHOT"]]
9+
:main ^:skip-aot uuid-plugin.core
10+
:target-path "target/%s"
11+
:profiles {:uberjar {:aot :all}})

uuid-plugin/src/uuid_plugin/core.clj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns uuid-plugin.core
2+
(:require [neovim-client.nvim :as nvim]
3+
[datascript.core :as d])
4+
#_(:gen-class))
5+
6+
(defn -main
7+
[& args]
8+
(nvim/connect!)
9+
10+
(nvim/register-method!
11+
"uuid"
12+
(fn [msg] (pr-str (d/squuid))))
13+
14+
;; Stay alive for a minute!
15+
(dotimes [n 60]
16+
(if (= 0 (mod n 10))
17+
(nvim/run-command! (str ":echo 'plugin alive for " n " seconds.'")))
18+
(Thread/sleep 1000))
19+
20+
;; Let nvim know we're shutting down.
21+
(nvim/run-command! ":let g:is_running=0")
22+
(nvim/run-command! ":echo 'plugin stopping.'"))

0 commit comments

Comments
 (0)