Fork me on GitHub
#cursive
<
2021-03-31
>
henryw37409:03:07

what tricks do people have for cursive when you have macros that generate a bunch of symbols? I know you can teach intellij in simple cases as described here: https://cursive-ide.com/userguide/macros.html

3
imre09:03:16

Subscribing to this. I am unaware of a way to do this now.

thheller09:03:23

not the answer you are looking for probably but disabling all "unresolved symbol" warnings works for me 😉

😉 3
☝️ 3
henryw37409:03:16

thanks I'll have a read of that. btw There was a bit of discussion in the recent defn cast about kondo and cursive and the overlap in some bits of functionality

imre09:03:44

Thanks, I'll look that up

cfleming20:03:54

One thing that’s not documented yet is the new Resolve as: None which will disable the warnings locally inside that macro form. This works well for DSL-style macros which define a lot of local symbols, but doesn’t help for macros which define global var-style ones.

manutter5112:03:59

I wonder if it would be useful/practical to have something like the following:

;;@resolve with-my-wrapper :as let
(defmacro with-my-wrapper [bindings & body]
  ,,,)

(with-my-wrapper [foo bar]
  (do-stuff))             ;; <-- Cursive now knows to treat this like a `let` expression

manutter5112:03:36

Kind of like Java annotations, except it would be IDE-specific and wouldn’t affect how the code actually runs. Cursive would just check comments for a leading ;;@resolve and then do the same thing as when you select Resolve As via the GUI.

manutter5112:03:45

Pros: automatically configures Cursive correctly when sharing code; alternative to generating stubs; avoids needing to regenerate stubs for same source

onetom16:03:57

- how would u "annotate" 3rd-party libs? fork them and use :git/url, instead of :mvn/version? - how about closed source stuff, like datomic, where u only have access to the AOT compiled class files? - as u said, it's an IDE-specific solution; it wouldn't work with most teams, because they are typically not homogenous editor-wise. - using comments is a horrible hack, as we saw in other instances, like javadoc. it

onetom16:03:16

- it's also not easy to process programmatically, because u would need to write a character level parser for the comment strings, as opposed to using the already existing clojure parser - u r also losing reflection capabilities, so for example editor tooling can't query a running clojure process about these formatting settings

Stuart12:03:10

I have a clojurescript project that when I open in IDEAJ and Cursive on my linux box it all works fine, but when I open it on windows it yellow underlines everything: What could I be missing between my linux install and windows install? It builds and runs fine, hot-realoading works etc. It's just cursive doesn't seem to like it. On Linux I do shadow-cljs pom to create the pom.xml and load that as the project file, did same on windows and it made no difference.

helios13:03:16

@cfleming bug report. If deps.edn has a map with extra keys, then cursive complains about The following errors were found during project resolve: /path/to/deps.edn: : nodename nor servname provided, or not known. Example broken edn

'{org.clojure/clojurescript {:mvn/version "1.10.844"
                               #_:git/url ""
                               #_:sha "3fdaabedb1343f434b6cb4f75fa28e748f96eff0"
                               #_#_:local/root "/Users/mk/Downloads/clojurescript/"
                               #_#_:local/root "/Users/kommen/work/clojurescript/"}}
#:org.clojure{clojurescript {:mvn/version "1.10.844", "" "3fdaabedb1343f434b6cb4f75fa28e748f96eff0"}}

helios13:03:45

note that :git/url and :sha only have one #_ so the https line is not commented, neither the value of the sha itself

helios13:03:03

putting #_ #_ fixed everything 🤷

onetom16:03:43

why the shrug emoji? is it not clear why do u need 2 #_ forms?

jcsims21:03:24

#_ only comments the very next form, so it ended up being a map with key "" and value "3fdaabedb1343f434b6cb4f75fa28e748f96eff0" - not sure how that's parsed

jcsims21:03:51

i.e. :git/url and :sha are the only things commented out

jcsims21:03:03

(in the first two lines)

cfleming23:03:48

That’s right - that’s what helios’s original comment shows at the end, the resulting map. Oddly, deps itself accepts this so I’m not sure why it would fail with Cursive since Cursive is getting that error back from deps. I’ll try to reproduce this and see if I can figure it out.

cfleming00:04:11

Interestingly, even though the CLI doesn’t produce an error, it doesn’t produce the right result either:

~/d/c/helios-deps-problem> cat deps.edn
{org.clojure/clojurescript {:mvn/version "1.10.844"
                               #_:git/url ""
                               #_:sha "3fdaabedb1343f434b6cb4f75fa28e748f96eff0"
                               #_#_:local/root "/Users/mk/Downloads/clojurescript/"
                               #_#_:local/root "/Users/kommen/work/clojurescript/"}}⏎
~/d/c/helios-deps-problem> clojure -Stree
org.clojure/clojure 1.10.3
  . org.clojure/spec.alpha 0.2.194
  . org.clojure/core.specs.alpha 0.2.56
~/d/c/helios-deps-problem> clojure -Spath
src:/Users/colin/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/Users/colin/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/Users/colin/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar

cfleming00:04:06

I’d have expected it to pick up clojurescript and just ignore the map entry it doesn’t understand. @U064X3EF3 might know why that is.

Alex Miller (Clojure team)00:04:41

And deps.edn is read with the the edn reader

Alex Miller (Clojure team)00:04:48

Not sure if that’s a clue

cfleming00:04:54

Oh, interesting, I had forgotten that. Shouldn’t that produce a read error then?

Alex Miller (Clojure team)00:04:44

The discard sequence is part of edn

Alex Miller (Clojure team)00:04:00

I don’t recognize that error, don’t know what that is

cfleming00:04:33

Ok, I’ll try to debug this later and report back.

cfleming01:04:22

@U0AD3JSHL I’m not seeing an error with this. Cursive imports without the CLJS dep but that’s because Deps doesn’t return it, as detailed above. I’m using CLI tools 1.10.3.810.

cfleming01:04:43

That error seems to be something to do with ssh. Do you have something in your user deps file which might cause deps to do something with ssh? The most likely candidate would be something with git and the new git shell integration, but that’s getting outside the realms of my deps CLI knowledge.

Alex Miller (Clojure team)02:04:03

The error was about Maven so that doesn’t match up

Alex Miller (Clojure team)02:04:00

That deps.edn above is wrong - missing the outer map with :deps key

onetom02:04:37

in the original message the map had a quote, so i assumed it wasn't the whole deps.edn

cfleming02:04:59

Ugh, you are absolutely right, I’m not paying attention. If I add the outer map and :deps, both Cursive and CLI do the right thing. I can’t repro the initial error.

helios06:04:13

yes, sorry, it wasn't the whole deps.edn 🙂

helios06:04:26

was just the culprit part of a larger deps.edn that worked fine