@robert-stuttaford Sorry for the delay, I’ve been off-grid camping over the weekend. So my usual answer to that question is “sometime soon” which unfortunately often turns out to be a lie. However in this case I am actually working on a proof of concept so I can confidently say that it might actually be “soon” :-)
1❤️@raspasov @rextruong Right, sync basically works out which files you’ve changed and loads them all in dependency order. Load file also does that, except only starting with the file that you’re loading (i.e. that file and all its dependencies will be loaded if modified). sync will do that for all files, even if the current file doesn’t depend on them.
1👍I see. I have a habit of loading files whenever I make any changes so I haven’t had a chance to use sync yet
That sounds great. I’d be interested if that completely solves the problem for Clojure projects or if anything else is required.
@cfleming you tease! 😆 seriously, that sounds fantastic, mate. sending you lots of Lisp energy from the Netherlands. good luck!
I habitually use load-file when making changes too, and eval-leftmost-form when doing stuff from inside (comment) blocks (like testing db code)
In the past, there used to be lightbulb that appeared when had the caret close to the beginning of a function/macro head, e.g. (|match [....] ....)
. This allowed me to pick a custom indentation level for e.g. the core.match/match macro. I think I was able to select it from the “context actions” menu when right-clicking too. Doesn’t seem to be around anymore?
“Send top form to REPL” will work in comment blocks too, it sends the topmost form inside the comment, not the comment itself.
Press Alt+Enter to open the context menu, regardless of the light bulb
(depends if you can open the context menu there)
Nope, like I said the capability is gone
@simongray check (macOS?): Preferences > Editor > Intentions > Search for “Clojure” > Enable all checkboxes
Also check File > Power Save Mode (make sure it’s not enabled)
(actually Power Save Mode probably doesn’t matter)
But first one does.
Ha! My whole intellij hangs if i try that it seems
I'll investigate
they were all enabled and power save mode wasn’t on 😞
@conan Try with a dummy lein project first to see if it's working I reckon
1Hmm
Did you try: File > Invalidate Caches/Restart ?
gonna try that in a moment and see if it has any effect. Thanks for taking your time to help, btw.
do you mean the one that is bound to cmd-shift-p, @cfleming?
i don't see a 'topmost' item here
when i use cmd-shift-p, it evals the comment form
Of course! 🙂 Hope it helps… I accidentally disabled the Intentions once and it took me probably 15 min to find it in the Preferences. But I’m not sure why it’s not working for you in this case.
still not working after invalidating caches and restarting… this is so strange
ok, now I figured out the issue. It works with my own functions/macros, but not the ones in Clojure core - and apparently core.match/match is considered part of Clojure core despite being a library and the default indentation is not implemented correctly (it vertically aligns every form) and can’t be changed.
I need it to match the official indentation: https://github.com/clojure/core.match#example-usage
but Cursive seems to disallow it
@robert-stuttaford that behaviour depends on where your caret's at. If you are somewhere inside (def db ... )
then cmdshiftP would eval the def. From your screenshot I'm assuming you are just after the def form.
I've got it working. It breaks when I try to use a WSL2-based JDK, that was the issue. Indexing is slow and my REPL start times also seem down, but everything is working nicely. So I guess currently the choice is between Cursive performance (project on the Windows filesystem) and Linux performance (project on the WSL2 filesystem). It would be great to be able to start an nREPL from linux and connect to it in intellij without having to use a remote configuration.
I've found that for symbols which cannot be resolved, you won't get the lightbulb. If you stick a (declare match)
or something before it, you can get the lightbulb, then you can delete the declare
may not be your issue, but i often get caught out by things that don't resolve for some reason
@simongray That’s definitely not the case, Cursive doesn’t treat core forms as special in any way. My money is on conan’s suggestion - can you navigate from a usage of match
to the declaration of it?
You can also use Tools | REPL | Sync files in REPL, as recently discussed: https://clojurians.slack.com/archives/C0744GXCJ/p1615790200178200?thread_ts=1615527556.163100&cid=C0744GXCJ
2👍Which Jdk were you using on wsl2, if you don't mind me asking?
@cfleming thanks - almost exactly what I wanted, but unfortunately the other way around - I want to reload namespaces that depend upon the one I’m working on - I’m working on some macro related stuff, and want the consumers of the macro to reload, so they get the new behaviour. it’s pretty dull having to go through each of the consumers and reload them..
The clojure.tools.namespace.repl/refresh
approach and the (require '[the-ns] :reload-all)
approaches both didn’t end up working out. I think the require...
approach is reloading dependencies of the namespace (..right?), so not quite right, and the namespace.repl/refresh
thing just didn’t seem to work - suspect it was a problem with retained vars in some places, but even restarting the system as part of it didn’t work.
(wall of text, apologies)
Yeah, there are some other use cases like this too - things like updating protocols and multimethods.
1👍all three of those are some of the most fun bits of clojure too!
As a suggestion, some kind of tree reload might be great, both backwards with dependencies, and forward with dependents.
Yeah, I can see that being useful. It would be pretty easy to accidentally reload your whole app, though, although I suppose that’s what you want if you’re changing some fundamental macro at the bottom of the pile.
It’s a trade off, for sure.
Reloading your entire app is pretty easy: (require your.main :reload-all)
I use this a lot from the REPL actually when I make such changes
Have unplugged now, but will try that later @borkdude thanks
Even a single level of dependents would be handy to reload, without traversing the whole tree..
“Reload direct dependents” would work great, the more I think about it. If I know I need to go further, navigate and execute that command iteratively is straightforward.