Fork me on GitHub
#cursive
<
2021-03-03
>
mikejcusack13:03:45

Is there a way to get cljsjs function resolution to work? For things like (.useState js/React 0) it is saying that .useState cannot be resolved.

cfleming20:03:04

Not at the moment sorry, but I’m planning improvements in this area.

👍 3
mikejcusack20:03:24

I did realize that changing it to (js/React.useState 0) doesn't throw the false positive

mikejcusack20:03:46

But (js/document.getElementById ...) does throw the false positive

dnolen14:03:05

minor thing - dotted aliases get a warning when defining a REPL using deps.edn - it works but it's a bit confusing

dnolen14:03:15

i.e. foo.bar

Alex Miller (Clojure team)14:03:07

aliases are keywords and according to the reader https://clojure.org/reference/reader, "They cannot contain '.' in the name part, or name classes."

imre14:03:35

What exactly does 'name classes' mean in that sentence?

imre14:03:26

I'm probably missing something obvious

imre14:03:53

as in they should not match the name of a class?

Alex Miller (Clojure team)14:03:45

reduce and java.lang.String are both symbols but follow different paths in resolution so class names are special cases. I assume keywords disallow class names for some place where this collides, but I don't actually know where. iow, I'm not totally sure why this restriction exists.

imre14:03:27

I see, TIL 🙂 I still wonder why the doubling down there matters. If a keyword doesn't contain a period, it cannot be a class name either?

Alex Miller (Clojure team)14:03:51

I guess you'd be more likely to run into a problem with destructuring keyword to symbol (let [{:keys [java.lang.String]} m] ...)

Alex Miller (Clojure team)14:03:31

the period restriction I think is primarily intended to push hierarchical naming to namespaces, not in names

😀 3
imre14:03:28

That's a good point re :keys. On that note, which one is more idiomatic, :keys [foo] or :keys [:foo]?

imre14:03:01

👍:skin-tone-3: thank you Alex

Alex Miller (Clojure team)14:03:58

keywords were primarily (only?) allowed in :keys originally to support autoresolved keyword resolution

Alex Miller (Clojure team)14:03:43

using ::keys or ::alias/keys etc is now preferred

Alex Miller (Clojure team)14:03:30

so I think that's actually a correct warning

Alex Miller (Clojure team)14:03:23

@dnolen some reason you're not using namespaced aliases instead? :my/alias instead of :my.alias ?

dnolen14:03:37

hrm ok, I don't think I realized that dot was restricted to the namespace part

Alex Miller (Clojure team)14:03:19

not sure that's actually enforced anywhere

borkdude16:03:22

I also recently learned about that restriction. Honestly I think a lot of people are just using this without knowing this restriction. Tracking an issue about that here: https://github.com/clj-kondo/clj-kondo/issues/1179

Jakub Holý (HolyJak)21:03:05

Hi @cfleming! What is the status of support for navigating to keywords? Mr. @smith.adriane is using namespaced keywords in #membrane for https://github.com/phronmophobic/membrane/issues/16#issuecomment-790070882 (i.e. an intent is [::some-kwd] and there is (defeffect :the.ns/some-kwd ...) ) is it possible to jump from the former to the latter? is/will there be a general support for that or does Cursive require per-framework extension? Thank you!!!

6
phronmophobic21:03:41

It looks like https://cursive-ide.com/userguide/macros.html might have an answer. It seems like you can tell cursive how to resolve a symbol for a given macro. There's already built in support for the re-frame macros, I wonder if membrane could piggyback on one of those.

cfleming23:03:10

Yes, I think so. I think resolving them as one of the re-frame forms should work. I think I’ll also add a generic keyword def that can be used for this purpose, since the re-frame ones will also affect the icon that’s shown in the structure view etc.

🎉 6
❤️ 3