cursive-ide / cursive

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

No support for dom methods in ClojureScript? #2076

Open graforlock opened 6 years ago

graforlock commented 6 years ago

Whenever I try to do any of DOM type of stuff like .getElementById I get cannot resolve. And that through a stock lein template for clojurescript. Is that the kind of support Cursive has for ClojureScript? Reloading/Invalidating etc does not help.

zrzut ekranu 2018-10-28 o 10 33 17

If this is true and expected it'd be quite disappointing for CLJS support.

So my question is: Is this a bug or this is the degree of CLJS support?

evelant commented 5 years ago

I also have this question. I installed cursive to try it out and in a very basic hello world project it says "cannot resolve js/require". The Cursive website advertises "First class ClojureScript support" so I don't know why it seems to fail on basic builtins.

jozuas commented 3 years ago

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

It is possible to avoid these issues to some extent by using the underlying Google Closure library, in this case the goog.dom module. Add [goog.dom :as gdom] to :require and use (gdom/getElement "app") instead of (.getElementById js/document "app").

You can find the Google Closure API docs here.

(I recognise that it has been two years since the issue was opened, but I hope this comment serves as documentation for other folk who run into this issue)

joshuamzm commented 2 years ago

Hey @jozuas, I know this is an old thread, but there's something still bugging me about aliasing goog namespaces to make Cursive detect them.

For example, if I only require a namespace, such as [goog.object] like this, Cursive is not able to detect goog.object/get function... But if I use an alias, such as [goog.object :as gobject], then Cursive is able to detect the symbol and offers pertinent documentation on the method (e.g. gobject/get).

To your knowledge, is there a workaround to make it visible to Cursive with the former option?

cc @cursive-ide

jozuas commented 2 years ago

Hi @joshuamzm, I do not know of a workaround, I switched to Doom Emacs 😄.