Fork me on GitHub
#conjure
<
2022-10-03
>
Braden Shepherdson17:10:04

has there been any success binding the Clojure refactoring tools into Conjure? I mostly want thread-first-all, thread-last-all, introduce-let and add-to-let.

Olical17:10:57

Is that stuff built into CIDER? I haven't tried to hook anything in, I kinda want to leave that sort of thing to LSP if it's designed for it in any way.

Braden Shepherdson17:10:12

although I'm not sure how to map sending the form under the cursor to those functions.

Olical17:10:26

So the conjure.extract module is designed to make it easy for any code to pull the current form from under the cursor. If this tooling just needs some code + meta data + nrepl op name then it should be faaaairly straight forward to hook up.

Olical17:10:51

There's also functions to replace forms I think? Since we have <prefix>e! which evals then replaces the form with the result.

Braden Shepherdson17:10:01

hm, so I might bind it to (1) wrap the form with a clj-refactor call; (2) send the eval-replace command

Olical17:10:19

Hmm doable, but does the nREPL feature want an nREPL OP or do you need to evaluate some code?

Olical17:10:39

One is using nREPL as the API, calling ops. The other is using Clojure as the API and evaluating Clojure code to make the refactor happen.

Olical17:10:47

(I have no idea, these are just things I'd dig into)

Braden Shepherdson17:10:58

ah I see the distinction. I'll have to play around with this.

Olical17:10:21

Because Conjure sends nREPL ops which you can also call into. There's a lower level set of functions that send nREPL messages rather than Clojure code (which is an eval op).

Olical17:10:00

I can look into this some day too, but if you want it soon, you might have to look into it yourself first 😅 if you contributed this feature or released your own plugin that piggiebacks on Conjure as a mod I'm sure many would be happy.

Olical17:10:35

I'd quite like to see more 3rd party mods for Conjure that can maaaaybe one day be merged in but also let the person with the desire / vision drive the feature forward and get the credit.

Braden Shepherdson17:10:19

there's an existing plugin for Vim+Fireplace for doing these refactorings, I'll see if I can replace the Fireplace hooks with Conjure ones and get it working. thanks for the pointers; I'm sure I'll be back if I get stuck 😄

Olical17:10:35

Ohh that'd be doable! Great idea

Braden Shepherdson17:10:39

also thanks for Conjure! it works great for me even on a pretty big codebase (Metabase)

❤️ 1
Braden Shepherdson17:10:38

ahaha I just realized that the main author of the Fireplace plugin is a colleague at Metabase. I'll start there.

dharrigan18:10:57

I use CoC and it works with if you're at all interested.