Skip to content

Commit fe8ee8d

Browse files
committed
Add Unix Domain Socket support
1 parent 3a1f14a commit fe8ee8d

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/socket_repl/socket_repl_plugin.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
(:code-channel plugin))
7878

7979
(defn start
80-
[{:keys [debug nvim repl-log socket-repl code-channel] :as plugin}]
80+
[{:keys [nvim repl-log socket-repl code-channel] :as plugin}]
8181

8282
;; Wire sub-component io.
8383
(log-start
@@ -191,9 +191,8 @@
191191
plugin))
192192

193193
(defn new
194-
[debug nvim repl-log socket-repl]
194+
[nvim repl-log socket-repl]
195195
{:nvim nvim
196196
:repl-log repl-log
197197
:socket-repl socket-repl
198-
:debug debug
199198
:code-channel (async/chan 1024)})

src/socket_repl/system.clj

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,34 @@
22
"The system created by wiring various components together."
33
(:require
44
[clojure.core.async :as async]
5+
[clojure.tools.logging :as log]
56
[neovim-client.nvim :as nvim]
67
[socket-repl.socket-repl-plugin :as plugin]
78
[socket-repl.repl-log :as repl-log]
89
[socket-repl.socket-repl :as socket-repl])
910
(:gen-class))
1011

11-
(defn new-system
12-
[debug]
13-
;; TODO - separate new & start in nvim
14-
(let [nvim (if debug
15-
(nvim/new "localhost" 7777)
16-
(nvim/new))
17-
socket-repl (socket-repl/start (socket-repl/new))
12+
(defn new-system*
13+
[nvim]
14+
(let [socket-repl (socket-repl/start (socket-repl/new))
1815
repl-log (repl-log/start (repl-log/new socket-repl))
19-
plugin (plugin/start (plugin/new debug nvim repl-log socket-repl))]
16+
plugin (plugin/start (plugin/new nvim repl-log socket-repl))]
2017
{:nvim nvim
2118
:repl-log repl-log
2219
:socket-repl socket-repl
2320
:plugin plugin}))
2421

22+
(defn new-system
23+
([]
24+
(log/info "starting plugin using STDIO")
25+
(new-system* (nvim/new)))
26+
([uds-filepath]
27+
(log/info "starting plugin using UDS" uds-filepath)
28+
(new-system* (nvim/new uds-filepath)))
29+
([host port]
30+
(log/info (format "starting plugin using TCP socket %s:%s" host port))
31+
(new-system* (nvim/new host port))))
32+
2533
(defn stop
2634
[{:keys [nvim plugin repl-log socket-repl] :as system}]
2735
(plugin/stop plugin)
@@ -31,4 +39,6 @@
3139

3240
(defn -main
3341
[& args]
34-
(new-system false))
42+
(if (= 1 (count args))
43+
(new-system (first args))
44+
(new-system)))

src/user.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
(defn go
1616
"Start the plugin."
1717
[]
18-
(reset! system-atom (system/new-system true)))
18+
(reset! system-atom (system/new-system "localhost" 7777)))
1919

2020
(defn stop
2121
[]

0 commit comments

Comments
 (0)