File tree Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Expand file tree Collapse file tree 3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 1
1
TODO
2
- [_] Move this TODO to socket-repl-plugin
3
- [_] Move all of the socket repl stuff to a plugin project
2
+ [X] Move all of the socket repl stuff to a plugin project
4
3
[X] Make buffer-get-text-async work, just test it at the repl
5
4
[X] Get "eval-code" working
6
5
[_] Figure out how to accumulate / display results in vim
13
12
make it autoread
14
13
[_] Name vim functions correctly
15
14
[_] Pass host, port in connect
15
+ [_] Shut down the plugin if no input received for one minute
16
16
17
17
Goals
18
18
-Not a proper nRepl plugin, primary use is as an thought exercise
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function! StartIfNotRunning()
13
13
endif
14
14
endfunction
15
15
16
- function ! EvalConnect ()
16
+ function ! Connect ()
17
17
" call StartIfNotRunning()
18
18
let res = rpcrequest (1 , ' connect' , [])
19
19
return res
Original file line number Diff line number Diff line change 9
9
(java.net Socket)
10
10
(java.io PrintStream)))
11
11
12
+ (def current-connection (atom nil ))
13
+
12
14
(defn connection
15
+ " Create a connection to a socket repl."
13
16
[host port]
14
17
(let [socket (java.net.Socket. " localhost" 5555 )]
15
18
{:host host
19
22
PrintStream.)
20
23
:in (io/reader socket)}))
21
24
22
- (defn eval*
25
+ (defn write-code
26
+ " Writes a string of code to the socket repl connection."
23
27
[{:keys [:out ]} code-string]
24
28
(.println out code-string)
25
29
(.flush out))
26
30
27
- (def current-connection (atom nil ))
28
-
29
31
(defn connect!
32
+ " Connect to a socket repl. Adds the connection to the `current-connection`
33
+ atom. Creates `go-loop`s to delegate input from the socket to `handler` one
34
+ line at a time.
35
+
36
+ `handler` is a function which accepts one string argument."
30
37
[host port handler]
31
38
(let [conn (connection host port)
32
39
chan (async/chan 10 )]
47
54
(recur ))))
48
55
" success" )
49
56
50
- (defn eval*!
57
+ (defn write-code!
58
+ " Like `write-code`, but uses the current socket repl connection."
51
59
[code-string]
52
- (eval* @current-connection code-string))
60
+ (write-code @current-connection code-string))
53
61
54
62
(defn -main
55
63
[& args]
81
89
; ; TODO: send code being executed
82
90
; ; back to vim, to show what actually
83
91
; ; happened in the repl buffer
84
- (eval* ! x)))))
92
+ (write-code ! x)))))
85
93
86
- ; ; TODO: When do we disconnect?
94
+ ; ; TODO: Rather than an arbitrary timeout, the plugin should shut down
95
+ ; ; when it has received no input for some time.
87
96
(comment
88
97
(dotimes [n 60 ]
89
98
(if (= 0 (mod n 10 ))
You can’t perform that action at this time.
0 commit comments