Skip to content

Commit 409046b

Browse files
committed
Add prompting Doc command
For those cases where you want to look up the docs for a symbol that is not currently in use. The rename of Doc to DocCursor is to reflect the fact that Doc before this commit was really a way to query the docstring of symbol under cursor. Also the use of Doc for the prompting version of docstring lookup matches the use of Eval for the prompting version of evaluating code.
1 parent 1cedbca commit 409046b

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

plugin/socketrepl.vim

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ command! DismissReplLog call ReadyDismissReplLog()
113113

114114
function! Doc()
115115
ReplLog
116-
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'doc', [])
116+
call inputsave()
117+
let symbol = input('Doc for: ')
118+
call inputrestore()
119+
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'doc', [symbol])
117120
return res
118121
endfunction
119122

@@ -126,11 +129,26 @@ function! ReadyDoc()
126129
endfunction
127130
command! Doc call ReadyDoc()
128131

132+
function! DocCursor()
133+
ReplLog
134+
let res = rpcnotify(g:nvim_tcp_plugin_channel, 'doc-cursor', [])
135+
return res
136+
endfunction
137+
138+
function! ReadyCursorDoc()
139+
if g:socket_repl_plugin_ready == 1
140+
call DocCursor()
141+
else
142+
echo s:not_ready
143+
endif
144+
endfunction
145+
command! DocCursor call ReadyCursorDoc()
146+
129147
if !exists('g:disable_socket_repl_mappings')
148+
nnoremap K :DocCursor<cr>
130149
nnoremap <leader>e :Eval<cr>
131150
nnoremap <leader>eb :EvalBuffer<cr>
132151
nnoremap <leader>ef :EvalForm<cr>
133-
nnoremap <leader>doc :Doc<cr>
134152
nnoremap <leader>rlog :ReplLog<cr>
135153
nnoremap <leader>drlog :DismissReplLog<cr>
136154
endif

src/socket_repl/socket_repl_plugin.clj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,24 @@
153153
(nvim/register-method!
154154
nvim
155155
"doc"
156+
(run-command
157+
plugin
158+
(fn [msg]
159+
(let [code (format "(clojure.repl/doc %s)" (-> msg
160+
message/params
161+
ffirst))]
162+
(async/>!! code-channel code)))))
163+
164+
(nvim/register-method!
165+
nvim
166+
"doc-cursor"
156167
(run-command
157168
plugin
158169
(fn [msg]
159170
(api-ext/get-current-word-async
160171
nvim
161172
(fn [word]
162-
(let [code (format "(clojure.repl/doc %s)" word)]
173+
(let [code (format "(clojure.repl/doc %s)" word)]
163174
(async/>!! code-channel code)))))))
164175

165176
(nvim/register-method!

0 commit comments

Comments
 (0)