Hello! I see a ton of commands on the https://clojure-lsp.io/features/#execute-command. Is it possible to add my own custom commands?
I'd like to be able to run a command that modifies my top requires for each Unresolved namespace X error on the current file
That's an idea I discussed with @andreribeirocamargo , it should be simpler now that we have sci integration for custom linters, we should have a similar feature. So these commands could be setup and have a function predicate to show them as code actions, which would be convenient. Feel free to create an issue about it,.it would help with priorization
Well, I just managed to use the diagnostics information to run add-missing-libspec . I ended up with something like:
(fn add-missing-libspec [diagnostics uri]
(let [unresolved (->> diagnostics
(filter (fn [{: code}]
(= code :unresolved-namespace)))
(first))]
(when unresolved
{:command :add-missing-libspec
:arguments [uri unresolved.lnum unresolved.col]})))
(fn get-lsp-client! []
(->> (vim.lsp.get_clients)
(filter (fn [client]
(= client.name :clojure_lsp)))
(first)))
(let [bufnr 15]
(let [client (get-lsp-client!)]
(-?> (add-missing-libspec (vim.diagnostic.get bufnr)
(vim.uri_from_bufnr bufnr))
(client:exec_cmd {: bufnr}))))
I'll skip creating the issue until I find something that really requires a custom command(☝️ the code is for neovim, using fennel)
Cool, looks promissing