Fork me on GitHub
AJ Jaro19:03:07

Is there a way to align items in a let block?

👀 1

Calva has a command Format and Align Current Form that does this. You have to place the cursor outside the binding vector for it to work.

AJ Jaro21:03:41

Ah, ok; that wasn’t exactly what I expected but thank you


What did you expect?

AJ Jaro21:03:48

I was imagining that the entire file would format no matter where the cursor was (unless a particular piece was highlighted). Just a different set of expectations is all


Just checking. The command Format and Align Current Form made you expect the whole file to be formatted?

AJ Jaro21:03:45

ha ha 😆 , no but I see your point! 😛


Haha. 😃 I wasn't trying to make a point. I want to understand your expectations. I think there might be an improvement opportunity for Calva here.

AJ Jaro21:03:05

it’s no problem at all! I didn’t read the full description so that is definitely on me!

calva 1
AJ Jaro21:03:51

Is there a capability or one in the future to define the form as a variable? For example if I have this form selected (do-something 1) I’d like to be able to define this in a let block surrounding the form


There is a refactoring Introduce let. Is that what you need?

AJ Jaro21:03:53

Ah, that’s headed in the right direction yes! I could use that some now that I know it is there. Thank you The other piece I was thinking about was to be able to add to an existing let block if one already wraps the form. A bit trickier I imagine


I think the command Calva Refactor: Move to Previous let Box does what you want.


If you search the command palette for “Calva Refactor” you can see the other available refactoring commands.

Lukas Domagala13:03:10

Interesting, I didn’t know calva had its own refactors 😅 We should add them to the refactors that pop up when you hit the refactor key


It’s using clojure-lsp for most/all of them. What’s the refactor key?

Lukas Domagala19:03:59

ctrl+shift+r is the default. I know about all the lsp refactors, since they get show when hitting that key, but introduce let doesn’t. It’s probably a problem with lsp’s CodeAction provider

Lukas Domagala01:03:29

It was a lsp problem, eric fixed it 🙂

😄 1
🎉 1