Fork me on GitHub
#cursive
<
2018-07-06
>
eskos08:07:09

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.

eskos08:07:45

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.

eskos08:07:17

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

cfleming08:07:53

No problem! Shower thoughts are always welcome.

cfleming08:07:43

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.

cfleming08:07:08

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.

cfleming08:07:54

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.

cfleming08:07:13

Extract method will be the next I’ll add.

cfleming08:07:58

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.

cfleming08:07:55

@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.

amann22:07:56

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

cfleming10:07:37

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.

cfleming10:07:52

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

amann22:07:50

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

cfleming08:07:49

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

amann17:07:16

:slowclap:

p-himik09:07:12

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

cfleming09:07:38

@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).

cfleming09:07:04

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

p-himik09:07:35

Great, thanks!

kennytilton16:07:38

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.

kennytilton16:07:55

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

kennytilton16:07:03

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.

p-himik16:07:52

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

p-himik16:07:42

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.

p-himik16:07:02

Does this work for you?

kennytilton17:07:10

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

cfleming20:07:19

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

kennytilton01:07:34

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