conjure

:neovim:+:clj: https://github.com/Olical/conjure - If you're enjoying Conjure and want to say thanks: https://github.com/users/Olical/sponsorship :smile: (alt https://conjure.fun/discord)
adambros 2020-09-01T04:00:07.013Z

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()&lt;CR&gt;
,vd mapping to (V)iew (D)ocs for word under cursor in <http://clojuredocs.org|clojuredocs.org> or google

2😍
adambros 2020-09-01T16:44:26.014200Z

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

adambros 2020-09-01T16:24:43.013900Z

@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))))))

Olical 2020-09-02T10:07:06.014700Z

:thinking_face: not sure what you mean by this exactly

Olical 2020-09-02T10:07:28.014900Z

You mean nREPL middleware?

Olical 2020-09-02T10:10:45.015100Z

Oh I see! You don't want to eval, you want to send a raw nREPL message!

Olical 2020-09-02T10:11:37.015300Z

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.

1👍
Olical 2020-09-02T10:12:38.015500Z

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.

adambros 2020-09-01T16:29:03.014Z

I'm not seeing that in the code... so maybe I should refactor to use eval?

adambros 2020-09-01T16:44:26.014200Z

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