Skip to content

Commit 874cf10

Browse files
committed
Fail gracefully when not connected to socket repl
1 parent 6e83cee commit 874cf10

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

TODO

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ TODO alpha
3838
[_] demo video
3939
[X] architecture diagram
4040
nvim<--msgpack/stdio-->plugin(jar)<--localhost:5555-->socketrepl
41-
[_] Error handle repl server not running
41+
[X] Error handle repl server not running
4242
Connection localhost:3333
4343
Then trying an ,eb doesn't fail gracefully
4444
->Exception in logs, current-connection still nil?
45-
Add logging
4645
[_] Script debugging
4746
open nvim w/ NVIM_LISTEN_ADDRESS
4847
can we source debug vimscript from CLI?
1.11 KB
Binary file not shown.

src/socket_repl/socket_repl_plugin.clj

+9-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@
8989
[]
9090
(swap! current-connection assoc :last (System/currentTimeMillis)))
9191

92+
(defn connected-to-socket-repl?
93+
"Returns true if currently connected to a socket repl server."
94+
[connection]
95+
;; Choose one of the properties set by establishing the connection.
96+
(:host connection))
97+
9298
(defn warn-if-disconnect*
93-
[connection f]
99+
[connection-atom f]
94100
(fn [msg]
95-
(if-not @connection
101+
(if-not (connected-to-socket-repl? @connection-atom)
96102
(nvim/vim-command-async
97103
":echo 'Use :Connect host:port to connect to a socket repl'"
98104
(fn [_]))
@@ -122,7 +128,7 @@
122128
`handler` is a function which accepts one string argument."
123129
[host port handler]
124130
(let [conn (connection host port)
125-
chan (async/chan 10)
131+
chan (async/chan 1024)
126132
file (output-file)]
127133
(reset! current-connection
128134
(assoc conn

0 commit comments

Comments
 (0)