Fork me on GitHub

There's a detail about Cursive I've been meaning to ask as it pops out out every now and then in discussion within my peers; Does Cursive use IntelliJ's parser/AST tooling for analyzing Clojure code? In these discussions I've had it is usually painted as something Cursive wouldn't actually do which in turns is the cause why most IntelliJ refactorings are not available, at least not in their familiar places.


To be more specific, in one of these discussions the two refactorings were "extract function" and "eliminate duplicates" (it's actually a code analysis tool) and then the discussion sort of went on tangent about how things even work... 🙂 Just asking for clarification, that's all.


Also I don't mean to imply these wouldn't be available, discussions just sometimes tend to be...curious. Sort of technical shower thoughts.


No problem! Shower thoughts are always welcome.


So IntelliJ doesn’t actually provide much for that, since every language is so different. It provides tools to build those things, and base classes for the AST etc, but each language needs its own lexer/parser.


Cursive’s is more or less like a reader, so you get back basically a set of forms, but not decorated for things like defn or whatever, that’s added on later.


The absence of those refactorings is just because I’ve been busy with other things, no fundamental limitation. Extract/inline binding is there, for example.


Extract method will be the next I’ll add.


And then various ones for moving things around. They’re harder because they require rewriting ns forms, which is surprisingly hard to do reliably with cljc.


@amann That’s a classic use case for the stubs functionality. It’s not exposed yet to end users, i.e. you can’t yet say “Do that for this and that ns” but that will happen.


Cool. Can you have it load an external file, run some clj, and then 💸 ? Also, if you’re looking for beta testers/folks to improve that, I know of a CI/CD company that would… ❤️ this feature very much! ie, CircleCI would be so happy to have HugSQL #justwork


The one issue with the stubs for this is that there will be no easy way to detect when they need to be updated - that will have to be a manual refresh.


i.e. you update your SQL and you’ll have to refresh in Cursive to see the changes.


yeah, I mean, that’s better than nothing though, right?


It’s certainly better than a poke in the eye with a sharp stick 🙂




@cfleming Hello. Could you please take a look at my message from yesterday? Thanks!


@p-himik Oh yes, my apologies. There’s no support for vector functions at the moment, although I agree it would be useful. I’ll have to take a look and see if I can do that - the issue is reliably identifying that that’s what you’re doing (you might just have a vector with some functions in it, for example).


There’s an issue for your second question - I should be able to fix that.


Great, thanks!


I cannot make out how to tell Cursive that, when calling a function with multiple parameters and breaking lines between them, that the parameters on following lines should align with the param on the line with the function name.


Not that I like that, but I got beat up in a code review for insufficient indentation. 🙂


I looked at the Clojure preferences and (a) saw no examples with a function with params continued to the next line and (b) could not make out how to use the “Intentions” panel to change anything, or if that is its purpose.


Let me know if you see the image - I got a warning from Slack about storage space.


That's what I see with my settings. I'll try to see if I can export them somehow. Note that I do not remember whether I have changed something at some point in time.


Does this work for you?


Thx! Gotta run, will try later and let you know.


@hiskennyness Settings-&gt;Editor-&gt;Code Style-&gt;Clojure-&gt;General, uncheck “Default to Only Indent”


Thanks, that seems to have done it. Thanks for all your trouble, too, @p-himik!