Fork me on GitHub
#cursive
<
2018-08-16
>
kenny00:08:08

When creating a new local REPL in a Deps project, the UI does not auto select your module if there is only one module in your project. Seems like it should do that.

cfleming01:08:53

Also @kenny, I think you asked about this one a while back: https://github.com/cursive-ide/cursive/issues/2031

4
kenny01:08:16

BTW another thing I keep into (even with the auto-import in the latest release) is changing my deps.edn and it not refreshing or not refreshing before I start my REPL. This, of course, causes the REPL classpath to be out of date with what my deps.edn has and can lead to very confusing results. Would it be possible to have a check to see if the current deps.edn is different than the deps.edn that Cursive knows about when starting a REPL?

kenny01:08:17

... and if it is, force a refresh.

cfleming01:08:58

Yeah, the auto-import stuff is based on IntelliJ infrastructure, and I can’t figure out exactly when it actually requests a refresh - it seems like it’s not very aggressive.

cfleming01:08:37

I’ll check to see if I can do that.

kenny01:08:23

Awesome, thanks!

ikitommi09:08:34

Hi. Is there a list of good IDEA setting when using Cursive on osx? Got a new computer and after installing the latest Ultimate + Cursive UI the editor seems bit slow (changing tabs, opening large EDN-files etc.). The default memory max setting is some hundreads on Mbs.

dottedmag10:08:39

How do I start a cljs REPL in Cursive for Figwheel.Main project?

dottedmag10:08:51

There is some documentation for lein-figwheel, but it does not seem to be relevant.

dottedmag12:08:25

@bhauman It seems that Cursive does not run clj, so the main question is how to bring in the dependencies.

dottedmag12:08:34

@cfleming Am I right, or am I mistaken?

bhauman12:08:27

I believe it can now, but you could use lein in the short term to validate it can be done.

schpa14:08:25

What is the most common case for Cursive not showing re-frame symbols? (shadow-cljs)

mfikes15:08:05

@dottedmag (and @bhauman) If you are willing to use the EAP of Cursive (which has support for deps.edn), setting up a figwheel.main REPL in Cursive is trivial. Just pick “Use clojure.main in normal JVM process” and in the Parameters box put something like

-m figwheel.main -b base
or however you start your REPL. Leave off the -r as Cursive supplies it.

amann16:08:01

Does anyone know of a way to get the code inspection to also warn/show globally unused vars instead of just local ones? It’s 🔪 day for the codebase and I’d like to knock off as much dead code as possible.

amann16:08:50

FWIW it looks like Cursive doesn’t expose an inspector for “Unused Global Symbol”?

amann20:08:33

@cfleming this twould be :dope:

amann20:08:01

(only pinging you so that this doesn’t completely fall off your :satellite_antenna: since it’s late in your tmz)

cfleming22:08:44

@U344U5FNH Yeah, the offline inspection doesn’t work for Clojure and I don’t know why. Thanks for the prompt, I’ll ask about it in the JetBrains forum and hopefully it’ll be a quick fix.

cfleming22:08:52

Cursive actually does mark some global symbols as unused in the editor, but not all of them for performance reasons. It shouldn’t have false positives (i.e. if it’s marked as unused there, it’s unused, but it won’t mark them all)

amann14:08:50

Yeah, I mainly wanted to get it in the inspector. Getting it in the editor is muy bueno, but being able to review all the ish at a high level :thumbsup: :thumbsup: :thumbsup:

dottedmag17:08:58

@mfikes Do I need to do something else to make it work (maybe some checkbox in project settings)? I have installed EAP build, put -A:fig into parameters field of REPL, and it runs runs java -classpath <...> clojure.main -A:fig -r

dottedmag17:08:36

I don't see any libraries from deps.edn in -classpath

mfikes17:08:40

I don’t think you can put an alias there

dottedmag17:08:02

Yes, because it does not run clojure wrapper at all.

mfikes17:08:55

(I effectively just copied the :main-opts from what would be in the :fig alias into the Parameters box.)

dottedmag17:08:56

Right, it can be done. But now I need to get all the libraries from the deps.edn and add them as libraries to the project manually?

mfikes17:08:27

No. With the EAP build you should be able to refresh your deps (from the Deps tab on the right), and they will automatically be added

dottedmag17:08:56

Ah, I need a Deps project.

dottedmag18:08:31

Now it works, groovy.

dottedmag18:08:37

@mfikes Thank you.

👍 4
pvrv18:08:25

Hey people! 🙂 Would you know ? currently in intellij: double clicking or ctrl-w on aa - selects the whole symbol or namespace how to select only ‘aa’ in? http://aa.bb.cc aa-bb-cc :aa

sgerguri20:08:54

Has anyone bumped into an issue with unresolved symbols when using Luminus? I have just created a new project through lein new luminus my-app, but when I import it in Cursive (Personal license on latest community IDEA version) I get lots of unresolved symbols, mostly coming in courtesy of mount. I'll take any suggestions on how to resolve this as it's rendering Cursive unusable for this little project of mine.

Chris21:08:19

Hello, I just added java sources to my project in Cursive and now when I go to start the REPL, I get the following error: Error running 'REPL for ag': Cannot run program "java".

Chris21:08:31

When I run leiningen from the command line things work. When I run lein compile it works too and then I can start the REPL. Looks like I don't have JAVA_HOME set in IntelliJ or for the Cursive plugin. I tried to set the environment variable in the runner but that didn't work.

Chris21:08:42

Any ideas on how to set JAVA_HOME for Cursive?

Chris21:08:31

Looks like setting :java-cmd explicitly in my project.clj file did the trick.

cfleming22:08:18

@ikitommi I have my IntelliJ set to use 2G (on a 16G laptop) and that works well - it’s probably overkill, but I usually have 2-3 big projects open at the same time.

cfleming22:08:39

@chris.schreiner When you say “not showing” the symbols, what do you mean?

cfleming22:08:10

@dottedmag @mfikes Yes, you’ll need to use a Deps project for this. I also need to add support for running REPLs with aliases, which is not there yet.

cfleming22:08:31

@vim55k Currently that’s only possible by dragging with the mouse. That’s been a little contentious, but on balance for Clojure I find it more useful than selecting segments when using “expand selection”.

cfleming22:08:11

@sgerguri I’ll try that today and see if I can reproduce. Sometimes the Cursive indexes can get messed up, and the best way to fix them is to use File-&gt;Invalidate caches/Restart, but if the symbols are defined using macros or in other dynamic ways Cursive can struggle too.

kenny22:08:41

Is there a way to run some code in the REPL using the test fixtures for the namespace you're in?

cfleming22:08:02

@kenny Not without wrapping it in a deftest and using the test integration.

cfleming22:08:13

But that should work, although it’s a little messy.

kenny22:08:28

I can do that but I don't see a way to get the result to the REPL.

kenny22:08:40

I could prn it but that's ugly.

kenny22:08:53

Or pprint. But still ugly.

kenny22:08:12

My eyes like colors 🙂

cfleming22:08:18

I can’t think of a non-ugly solution, sorry.

cfleming22:08:27

Haha, yes, and indentation 🙂

4
kenny22:08:29

Actually, is there a way to get the code behind the caret in a custom REPL command?

kenny22:08:46

Because I have this:

(defmacro test-env
  "Executes `body` after running all fixtures."
  [& body]
  `(let [once-fixtures# (join-fixtures (:clojure.test/once-fixtures (meta *ns*)))
         each-fixtures# (join-fixtures (:clojure.test/each-fixtures (meta *ns*)))
         fixtures# (join-fixtures [once-fixtures# each-fixtures#])]
     (fixtures#
      (fn []
        ~@body))))

sgerguri22:08:53

@cfleming Thanks! The issue specifically seems to happen with mount only - and can be easily reproduced on a fresh luminus app if you just jump through to mount.core.

cfleming22:08:00

You might be able to do it using an internal function from clojure.test, but I can’t remember well enough how all that works.

cfleming22:08:33

@sgerguri Ok, I’ll try that, thanks!

sgerguri22:08:33

That triggers a StackOverflowException inside IntelliJ, and it does the same when you navigate back. I've tested this across different IDEA versions - 2017.2, 2018.2.1 community and ultimate.

kenny22:08:49

The macro I sent initializes the test env. I just need a way to get the form before the caret.

cfleming22:08:29

@sgerguri Which Cursive version are you on? The recent EAPs have a fix for at least one SOE problem.

sgerguri22:08:41

Latest stable.

cfleming22:08:08

Ok, if you’re willing to run the EAP, hopefully that will fix the problem.

sgerguri22:08:27

Let me give that a spin - will report back shortly.

cfleming22:08:17

~form-before-caret or ~top-level-form should do what you want.

kenny23:08:02

Oooo. That definitely opens up some possibilities.

kenny23:08:23

Can you share REPL commands across computers?

cfleming23:08:29

Indeed - if there’s anything else that would be helpful there, let me know.

4
cfleming23:08:43

Good question - one sec.

cfleming23:08:51

@kenny They’re stored in repl-commands.xml - if you share that file, then I think that should work, yes.

dottedmag23:08:52

Is there a way to have typed (, { or [ wrap current selection instead of replacing it?

cfleming23:08:45

@dottedmag Settings-&gt;Editor-&gt;General-&gt;Smart Keys-&gt;Surround selection on typing quote or brace

dottedmag23:08:51

Yay, thanks.

sgerguri23:08:31

@cfleming the EAP definitely fixes that issue. Thanks for the stellar support here on Slack, Colin - looking forward to the next stable release.

cfleming23:08:59

@sgerguri Great, thanks for letting me know! Next stable should be out in a week or two.

4
sgerguri23:08:21

Just realised I mixed two issues together - the SO and the symbols not resolving. I reported the former, which I ultimately discovered by trying to resolve the latter, so apologies about the confusion!

sgerguri23:08:08

Invalidating caches does not help. The symbols are effectively defined using macros, so I'm guessing that is expected behaviour for now - but if there's any possibility of this getting better in the future then I will certainly very much appreciate it! 🙂

cfleming23:08:27

@sgerguri What does the macro look like? There is some support for telling Cursive to resolve a macro form like def, defn etc, which may be sufficient.

sgerguri23:08:22

#?(:clj
    (defmacro defstate 
      "Defines a state. Restarts on recompilation. 
       Pass ^{:on-reload :noop} to prevent auto-restart
       on ns recompilation, or :stop to stop on recompilation."
      [state & body]
      (let [[state params] (macro/name-with-attributes state body)
            {:keys [start stop] :as lifecycle} (apply hash-map params)
            state-name (with-ns *ns* state)
            order (make-state-seq state-name)]
          (validate lifecycle)
          (let [s-meta (cond-> {:order order
                                :start `(fn [] ~start)
                                :status #{:stopped}}
                         stop (assoc :stop `(fn [] ~stop)))]
            `(do
               ;; (log (str "|| mounting... " ~state-name))
               ;; only create/redefine a new state iff this is not a running ^{:on-reload :noop}
               (if-not (running-noop? ~state-name)
                 (do
                   (~'defonce ~state (DerefableState. ~state-name))
                   (mount-it (~'var ~state) ~state-name ~s-meta))
                 (~'defonce ~state (current-state ~state-name)))
               (~'var ~state))))))

sgerguri23:08:50

Possibly the #?(:clj) is confusing it?

cfleming23:08:57

That’s possible, the cljc support can be flakey sometimes - it’s a tricky problem. Let me generate a luminus project now actually, and I’ll try it out - one sec.

cfleming23:08:58

@sgerguri Ok, I have a luminus project open, where am I looking for the unresolved symbols?

cfleming23:08:47

Oh, I see what you mean by the defstate thing.

sgerguri23:08:04

Anywhere a defstate is used - core is a good example.

cfleming23:08:59

Yeah, you can choose to resolve defstate as def and that works well - see https://cursive-ide.com/userguide/macros.html

cfleming23:08:08

Doc is slightly out of date, it looks like this:

sgerguri23:08:40

Marvellous, I'm off to do that immediately.

sgerguri23:08:33

Worked a treat. Again, thanks for the stellar support.

cfleming23:08:45

No problem!