Skip to content

Commit d3a8e2a

Browse files
committed
Added :Doc command
1 parent 8beed10 commit d3a8e2a

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

socket-repl-plugin/TODO

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ TODO alpha
1212
[X] Name vim functions correctly
1313
[X] create prod & debug plugin.vim
1414
[X] add debug switch (var) to socket-repl-plugin.clj
15-
[_] implement doc (word under cursor)
15+
[_] errors in the middle of a buffer
16+
can be lost - wrap in eval?
17+
[X] implement doc (word under cursor)
1618
[_] Pass host, port in connect
1719
[_] Update README
1820
[X] Move NVIM_LISTEN... stuff to a debug section

socket-repl-plugin/plugin/socketrepl.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ function! ReplLog()
4141
endfunction
4242
command! ReplLog call ReplLog()
4343

44+
function! Doc()
45+
let res = rpcrequest(1, 'doc', [])
46+
return res
47+
endfunction
48+
command! Doc call Doc()
49+
4450
if !exists('g:disable_socket_repl_mappings')
4551
nnoremap <leader>eb :EvalBuffer<cr>
4652
nnoremap <leader>ef :EvalCode<cr>
53+
nnoremap <leader>doc :Doc<cr>
4754
4855
function! ShowLog()
4956
vnew

socket-repl-plugin/plugin/socketrepl.vim.debug

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ function! ReplLog()
2525
endfunction
2626
command! ReplLog call ReplLog()
2727

28+
function! Doc()
29+
let res = rpcrequest(1, 'doc', [])
30+
return res
31+
endfunction
32+
command! Doc call Doc()
33+
2834
if !exists('g:disable_socket_repl_mappings')
2935
nnoremap <leader>eb :EvalBuffer<cr>
3036
nnoremap <leader>ef :EvalCode<cr>
37+
nnoremap <leader>doc :Doc<cr>
3138

3239
function! ShowLog()
3340
vnew
Binary file not shown.

socket-repl-plugin/src/socket_repl/socket_repl_plugin.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@
154154
(nvim/register-method!
155155
"doc"
156156
(fn [msg]
157-
))
157+
(nvim/get-current-word-async
158+
(fn [word]
159+
(let [code (format "(clojure.repl/doc %s)" word)]
160+
(write-output! (str code "\n"))
161+
(write-code! code))))))
158162

159163
(nvim/register-method!
160164
"show-log"
@@ -173,7 +177,7 @@
173177
(Thread/sleep 30000)
174178
(let [elapsed-msec (- (System/currentTimeMillis)
175179
(:last @current-connection))]
176-
(when (> elapsed-msec (* 10 60000))
180+
(when (< elapsed-msec (* 10 60000))
177181
(recur))))
178182

179183
;; Let nvim know we're shutting down.

0 commit comments

Comments
 (0)