This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-14
Channels
if I run lsp-find-implementation
(or -definition
) on a macro call in a clojurescript file (e.g. something like (reagent.core/with-let [...
) I get LSP :: Not found for: <name of macro>
. Is this normal and expected, a bug, or a user/configuration error?
docstrings don't seem to work either
on the other hand stuff from cljs.core.cljc
seem to resolve ok, stuff like or
.
Sure, I’ll try if I can create a minimal repro.
basically just lein new reagent <name of app>
note the {:lint-as {reagent.core/with-let clojure.core/let}}
lsp-mode
+ clojure-lsp 2022.05.03-12.35.40
also, note that navigating to reagent.core
takes me to reagent.core.cljs
, in which that CLJS namespace requires the macros with (:require-macros [reagent.core])
from reagent.core.clj
. I can't even figure out how can I navigate to that reagent.core.clj
file.
I think this kind of "have a clj and cljs version of the same namespace for macros" approach is described in https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html, if it's somehow related to the problem
I can repro that issue, it seems to me a clj-kondo issue where clj-kondo doesn't find the var-definitions exposed by require-macros
If I understood it correctly.
• the cljs ns macro-repro.core
requires [reagent.core :as reagent]
• the cljs ns reagent.core
doesn't have a with-let
because it's from clj ns reagent.core
and it's imported with (:require-macros [reagent.core])
Does that makes sense for you @U04V15CAJ? should we create a issue on kondo with that minimal repro?
I think we should have var-definitions of the clj required-macro ns, on the cljs ns, right?
I think we can summarize as: clj-kondo doesn't define var-definitions of :require-macros
, it should have a reagent.core/with-let
of that cljs ns
hum, but when we call reagent.core/with-let
, isn't referencing a var-definition on that cljs ns?
Otherwise clojure-lsp would need to check all require-macros when a find-definition is not found, sounds weird to me
so a custom cljs code is created with sometihing lke a var that can be called right?
it does not generate a reagent.core/with-let var in ClojureScript (unless you define it in a .cljc file, there are some edge cases)
so in general you should keep on looking for a var with the same name in the .clj side of things
right, but we could have something from kondo that could help identifying that, otherwise seems to me clojure-lsp would be a little bit blind and need to check multiple places for each find definition of a cljs usage
maybe something on context, or something that helps saying: that macro comes from this other ns
Not sure it's that simple. I think it usually works correctly if you use the .clj var as a fallback
(Just curious: what do you mean with ”the clj var” wrt a macro?)
@U0178V2SLAY The macro var in the JVM
Ah, defmacro creates a var. Never really realized that :)
borkdude’s suggestion of falling back to the var on clj works, just not sure if will work for all use cases of :require-macros
.
For example, I don't think it would work for (ns foo (:require-macros [bar]))
because the ns would be different, right?
oh, didn't know that works.
So one would not be able to (foo/my-macro)
? because the definition is really on bar
?
Got it, alright, will try to fix it on clojure-lsp side so, thanks for the help and info @U04V15CAJ @U0178V2SLAY
@U0178V2SLAY it should be fixed and available in some minutes on #clojure-lsp-builds, LMK if any issues
Hello. How can I run the new move-form
feature from Emacs with lsp-mode? It does not show up in the list when I run lsp-execute-code-action
.
No, I mean moving a function to a different namespace. This one: https://github.com/clojure-lsp/clojure-lsp/pull/871
Oh, right, this one is available only as commands for now, I I tend to add support to code actions soon
You probably need to update ls-mode, even so, I just found that I accidentally committed a hardcoded path 😂 https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-clojure.el#L224
@U2ERGD6UD There was a bug on clojure-lsp side as well, I fixed right now both on lsp-mode and clojure-lsp so to use it you will need to update lsp-mode + use a clojure-lsp from #clojure-lsp-builds if you want.