calva

JR 2025-10-24T20:26:56.084849Z

I'm messing around with adding an enhancement to clojure-lsp to extract multiple sexpresssions for extract-function. For now, I've created a new clojure-lsp refactoring called extract-function-2. It works from the tests. 🙂 But I can't get it to be invoked from Calva. When I select it from the popup, I get an error message saying command 'extract-function-2' not found. Do I also need to register this command in Calva's lsp-commands.ts like

{
    command: 'extract-function-2',
    afterCommandFn: renameAfterRefactor,
    defaultName: 'new-fn',
    category: 'clojureLsp.refactor',
  },
Eventually extract-function-2 will take the begin and end of a selection, so I imagine I'll need to modify Calva to handle that for extract-function-2 as well?

ericdallo 2025-10-24T20:29:23.701229Z

I think there is some place in calva you need to register that, but would be nice to get those from clojure-lsp autoamtically in the future

JR 2025-10-24T20:32:07.574449Z

It's in the context menu popup, so at least part of it is coming from clojure-lsp. I think that once I select the menu item it goes back into the Calva code registering things to be done later (?) before invoking clojure-lsp. But yeah, making it fully data driven would be nice.

JR 2025-10-24T20:43:37.850359Z

@ericdallo Is it more fully data driven in emacs? Or is there a way to run clojure-lsp refactor from the command line? (I wouldn't mind only changing one system at a time when testing.)

pez 2025-10-24T20:49:31.959069Z

I don’t quite remember the reasons for the hardcoding. It may be possible to avoid it. Did it work if you added it to clojureLspCommands?

JR 2025-10-24T20:50:35.548959Z

(working on it, but from trying to follow the code, now I'm guessing that it will)