cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
575 stars 7 forks source link

shadow-cljs support #1804

Open thheller opened 7 years ago

thheller commented 7 years ago

shadow-cljs is a full build solution for CLJS projects. It is the successor to shadow-build and is capable of managing :dependencies for CLJS projects. Unfortunately I can't use it with Cursive directly and still have a create a "dummy" project.clj.

It would be neat if Cursive recognized the :dependencies and :source-paths without a project.clj.

shadow-cljs works pretty similar to lein in that it is configured by a shadow-cljs.edn file in the project directory, except that it is pure EDN data. The most basic example config would look something like this:

{:dependencies
 [...]

 :source-paths
 ["src"]

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"
   :modules {:main [my.app]}}}}

:dependencies has the same structure as lein or boot would have as it uses the same underlying cemerick/pomegranate library to manage them. :source-paths is identical as well. There might be a :dev-dependencies, :test-paths and :resource-paths soon too but the same rules would apply here. I don't think there is a need for :profiles.

:builds support could maybe be done at a later date but since :source-paths is global and there are no build-specific :source-paths that is not a high priority. It could maybe exclude all :output-dir paths (always relative to the project root) but thats is also not a high priority. shadow-cljs also provides a nREPL server but that already works perfectly fine with Cursive "Remote nREPL". I know that you are working on Socket REPL support and that should just work as well.

Let me know if there is anything I can do to help. There aren't that many users (yet) but it has been getting some attention.

cursive-ide commented 7 years ago

So... this is quite a lot of work - I'd be interested in supporting this, but realistically generating a fake project.clj is going to be your best option for a while (boot users still have to do this). When I add boot support, I'm going to be using a new IntelliJ API which might make this easier, but I don't have a good feeling for how much easier.

Do you support multiple projects/modules which reference each other?

holyjak commented 5 years ago

I guess Cursive will eventually support deps.edn and if shadow-cljs used it internally as well (its :deps, :paths is all you asked for about, right?) then the issue would be sovled?

wontheone1 commented 4 years ago

What would be the priority of this issue? I think this is quite an important issue to solve.

thheller commented 4 years ago

You can get decent support these days via shadow-cljs pom and importing the generated pom.xml in Cursive (requires Maven plugin) or just using deps.edn. Of course the project.clj way also still works.

conan commented 4 years ago

Is there a way to get support for npm deps that shadow-cljs supports? Currently Cursive fails to resolve all of them:

(ns my.button
  (:require
    ["@rmwc/button" :as button]))

(defn button []
  [:> button/Button {:label "Click me"}])

In this example the button/Button cannot be resolved, even though it all works fine.

tekacs commented 4 years ago

Is there a way to get support for npm deps that shadow-cljs supports? Currently Cursive fails to resolve all of them:

(ns my.button
  (:require
    ["@rmwc/button" :as button]))

(defn button []
  [:> button/Button {:label "Click me"}])

In this example the button/Button cannot be resolved, even though it all works fine.

Related: https://github.com/cursive-ide/cursive/issues/2333

noorvir commented 3 years ago

@thheller I have to re-generate the pom.xml file every time I install a new dependency. That's fine for now because I setup a file watcher to run shadow-cljs pom for me on changes in the shadow-cljs.edn file.

However, I can't get it to resolve variables from the js runtime. Any solutions for that?

image