Fork me on GitHub
#cursive
<
2019-05-04
>
kari16:05:14

I have a "dev-src" alias in my deps.edn in which I keep development time sources and dependencies: :dev-src {:extra-paths ["dev-src"] :extra-deps {org.clojure/tools.namespace {:mvn/version "0.2.11"}}} If I open a file in that "dev-src" IntelliJ IDEA complains that the file "is not under a source root". I can use clojure namespaces defined in that "dev-src", everything works just fine in REPL but there is just that "is not under a source root" IntelliJ IDEA warning in the beginning of the editor window. I can live with that but I was wondering if there is an easy way to disable it?

kari16:05:18

The warning disappears if I add the "dev-src" to paths: :paths ["src", "dev-src"] , of course. But I understood that with deps.edn paths defines the "production code" and you can define other "extra-paths" using aliases, as creating an alias for development time code (used with REPL) as I did.

cjmurphy22:05:00

You can right click a directory in the project pane, then Mark directory as Sources Root.

cfleming23:05:05

@U76D9RZRR In the Clojure Deps toolwindow, open the Aliases tree, select the dev-src alias there and then refresh your project.

kari06:05:42

Thanks @U0567Q30W! That solved my problem. I'm also trying to learn how to use Cursive effectively with deps.edn.

polymeris17:05:59

I am experimenting with shadow-cljs, and to resolve cljs deps, I am using shadow-cljs pom, then having intellij import that pom. Not sure how to get cursive to resolve the npm deps, though. I.e, things like (:require ["foo" :as bar]). Is it possible?

p-himik07:05:59

I don't think the pom is required. At least, I don't use it - all my dependencies are in deps.edn, and Cursive knows how to handle it, as well as Shadow CLJS.

p-himik07:05:42

By "resolve NPM deps" you mean correct highlighting and declaration following when requiring NPM deps from CLJS files? If so, it's not yet implemented AFAIK.

polymeris13:05:20

I am not using deps.edn (only shadow-cljs.edn for clj/s deps and package.json for npm deps)

polymeris13:05:59

Yeah, I meant correctly highlighting the symbols imported from npm deps

polymeris13:05:04

I notice Cursive does highlight some js stuff it seems to magically know about

polymeris13:05:12

E.g. it knows about js/console

polymeris13:05:20

And it knows about e.g. goog.async (but I guess those are defined in the maven deps somewhere, not in the npm deps)

p-himik13:05:19

AFAIK js/console comes from the built-in externs and goog.async is probably a dependency of CLJS itself. Just in case - if you don't want to regenerate the pom each time you change the dependencies, you can just switch to deps.edn + shadow-cljs.edn: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn

cfleming22:05:28

This is correct, Cursive knows about some built-ins (using the ones from Tern: http://ternjs.net/) and also indexes JS code attached via Maven (e.g. Closure itself).

cfleming22:05:04

It doesn’t yet index JS from node_modules or understand the node require syntax, but I’m actually re-vamping the JS parsing right now and hopefully that will make it in as part of this change.

cfleming22:05:22

Since a lot more projects are using it these days.

cfleming22:05:29

I’m currently switching over the JS parsing to use the Google Closure JS parser rather than the Rhino one, which has been giving a lot of problems recently.

polymeris13:05:00

That's great to hear, cfleming. Thanks!

polymeris17:05:41

(where "foo" is in node_modules)

polymeris17:05:58

Adding node_modules as src folder doesn't seem to help