Fork me on GitHub
#lsp
<
2024-02-15
>
pez10:02:24

With re-frame I can go to the definition (the reg-…) of an event or subscription keyword. What would be involved to get that to work for other things? I have a function where I set up event handlers for dumdom and would like clojure-lsp to quickly take me there from any dispatch of those events. Is there some special treatment for re-frame in clojure-lsp?

ericdallo12:02:28

yes, that was a feature we added to clj-kondo to allow these kind of thing and we supported re-frame as built-in, but I think it should work for other features if you have a custom hook or something, let me find it

ericdallo12:02:12

that happens when a clj-kondo analysis element has a :reg https://github.com/clojure-lsp/clojure-lsp/blob/161c9c80b09d1d209120d09b4cee5b160f433171/lib/src/clojure_lsp/kondo.clj#L132 example:

(require '[re-frame.core :as re-frame])
(re-frame/reg-sub ::foo (fn [_]))
{:ns my-ns,
 :name "foo",
 :auto-resolved true,
 :from my-ns,
 :context {:re-frame.core {:in-id "4", :id "4", :var "reg-sub"}},
 :reg re-frame.core/reg-sub,
 :uri "...",
 :bucket :keyword-definitions}

ericdallo12:02:36

@U0ETXRFEW I think that may work if you use https://github.com/ericdallo/clj-kondo/blob/6bca0676674ae784ba487dea150b63567e2b6b2a/src/clj_kondo/impl/hooks.clj#L54 clj-kondo reg-keyword! hook function in a hook for your macro

pez21:02:52

Thanks, @UKFSJSM38! 🙏 I’ll try this and see where it gets me.