File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,11 @@ function! EvalCode()
34
34
endfunction
35
35
command ! EvalCode call EvalCode ()
36
36
37
+ function ! ReplLog ()
38
+ " call StartIfNotRunning()
39
+ let res = rpcrequest (1 , ' show-log' , [])
40
+ return res
41
+ endfunction
42
+ command ! ReplLog call ReplLog ()
43
+
37
44
echo ' socket repl plugin loaded!'
Original file line number Diff line number Diff line change 39
39
40
40
(defn write-output
41
41
" Write a string to the output file."
42
- [{:keys [:file ]} string]
43
- (.print file string)
44
- (.flush file))
42
+ [{:keys [:file-stream ]} string]
43
+ (.print file-stream string)
44
+ (.flush file-stream ))
45
45
46
46
(defn write-output!
47
47
" Like `write-output`, but uses the current socket repl connection."
56
56
`handler` is a function which accepts one string argument."
57
57
[host port handler]
58
58
(let [conn (connection host port)
59
- chan (async/chan 10 )]
59
+ chan (async/chan 10 )
60
+ file (output-file )]
60
61
(reset! current-connection
61
62
(assoc conn
62
63
:handler handler
63
64
:chan chan
64
- :file (PrintStream. (output-file ))))
65
+ :file file
66
+ :file-stream (PrintStream. file)))
65
67
66
68
; ; input producer
67
69
(go-loop []
105
107
(write-output! (str x " \n " ))
106
108
(write-code! x)))))
107
109
110
+ (nvim/register-method!
111
+ " show-log"
112
+ (fn [msg]
113
+
114
+ (nvim/run-command-async!
115
+ (format " :term tail -f %s" (-> @current-connection
116
+ :file
117
+ .getAbsolutePath))
118
+ (fn [_]))
119
+
120
+ ; ; Native solution, but only seems to work when the buffer has focus.
121
+ #_(nvim/run-command-async!
122
+ (format " :e %s" (-> @current-connection
123
+ :file
124
+ .getAbsolutePath))
125
+ (fn [_]
126
+ (nvim/run-command-async!
127
+ " :set updatetime=500 | au CursorHold <buffer> :e!"
128
+ (fn [_] nil ))))))
129
+
108
130
; ; TODO: Rather than an arbitrary timeout, the plugin should shut down
109
131
; ; when it has received no input for some time.
110
132
(comment
You can’t perform that action at this time.
0 commit comments