i don't know if this is a bug in clj-kondo or clojure-lsp, or exactly how to search for it so my apologies if it's been well tackled here or on github. i have a macro that expands to a number of vars (creates a dynamic variable then a couple functions that use the dynvar). i can create a macroexpand hook to do this for me, but
1. i can't seem to attach {:clj-kondo/ignore [:clojure-lsp/unused-public-var]} metadata to the created vars in a way that clj-kondo/clojure-lsp recognizes
2. using "go to definition" on the macro invocation doesn't seem to work (it returns the self-same location)
1. I recall some past report where we came to the conclusion this doesn't work because clj-kondo drops the meta or something, needs to deep dive on this again
2. you need to include the meta properly so clj-kondo can emit those analysis, let me find an example
this is the less worst example I found:
(defn with-redefs
"This transformation hook converts
(state-flow.labs.state/with-redefs [bindings & flows])
into
(clojure.core/with-redefs bindings
(state-flow.core/flow \"state-flow.labs.state/with-redefs\" flows))"
[{:keys [node]}]
(let [[bindings & flows] (rest (:children node))
new-node (hooks/list-node
[(hooks/token-node 'clojure.core/with-redefs)
bindings
(hooks/list-node
(concat [(hooks/token-node 'state-flow.api/flow)
(hooks/string-node "state-flow.labs.state/with-redefs")]
flows))])]
{:node (with-meta new-node (meta node))
:defined-by 'state-flow.labs.state/with-redefs}))
the with-meta is the key there, where it will copy the meta of the original node to the new oneahhh okay, thank you
i can't get :defined-by to work but i'll keep playing around with it later
i spent more time on this and you’re correct that clj-kondo is dropping metadata from nodes returned by hooks
i can use :exclude-when-defined-by to not warn on unused vars, which is great
i still can’t navigate to the source of the macro, sadly
i pushed an example to that repo
i can create a github issue if you’ like one
hum please do, it will help me prioritize taking a closer look