In the spirit of sharing interesting mappings: I wrote this tonight, an itch I had to try to scratch: https://github.com/Pancia/dotfiles/commit/4886429c6c1e26a78e1feb16b4308a9ee41976bb
function! ResolveSymbol()
call luaeval("require('conjure.client')['with-filetype']('clojure', require('conjure.eval')['eval-str'], { origin = 'dotfiles/clojuredocs', code = '`".expand("<cword>")."', ['on-result'] = function(sym) vim.api.nvim_command('call OpenClojureDocs(\"'..sym..'\")') end})")
endfunction
function! OpenClojureDocs(fqsym)
echomsg "open clojure docs for: " . a:fqsym
let [l:ns, l:sym] = split(a:fqsym, "/")
if l:ns =~? 'clojure\..*'
execute "!open '<https://clojuredocs.org/>".l:ns."/".l:sym."'"
else
execute "!open '<https://www.google.com/search?q=>".a:fqsym."'"
endif
endfunction
nnoremap ,vd :call ResolveSymbol()<CR>
,vd mapping to (V)iew (D)ocs for word under cursor in <http://clojuredocs.org|clojuredocs.org> or google
as a note, you'll want to add ['passive?'] = true
to the map with code = ...
or you'll get lots of `symbols in your repl
@olical how do i send a message that some middleware can pick up? eg:
(defn middleware [handler]
(fn [{:keys [op] :as request}]
(if (= op "nrebl-start-ui")
(rebl/ui)
(handler (assoc request :transport (wrap-rebl-sender request))))))
:thinking_face: not sure what you mean by this exactly
You mean nREPL middleware?
Oh I see! You don't want to eval, you want to send a raw nREPL message!
In the conjure.client.clojure.nrepl.server
module there's a send
function that takes a message and a callback. The message being a Lua table.
eval
is built on top of send
so that's probably the function you'll want to hook into. The chances of that changing are near 0 although you may encounter one breaking change when I one day migrate the nREPL code into it's own reusable module, although that may even still not affect you.
I'm not seeing that in the code... so maybe I should refactor to use eval?