nvim lsp has vim.lsp.buf.execute_command
api.
But how to find avaiable lsp commands?
Run :help lsp-buf
.
Sorry, This arrical is not I want.
What I want is some commands like “CocCommand” params.
For CocCommand, you could use <tab>
key to complete for lsp commands.
Do the same thing… Type :lua vim.lsp.buf.
then press <Tab>
.
@jqhr I’m late to reply, but here’s how to get available commands from the LSP
client = vim.lsp.get_client_by_id(client_id)
commands = client.server_capabilities.executeCommandProvider.commands
The result is a table. e.g. { "myLSP.search", "myLSP.searchAndReplace" }
This assumes a couple things:
client_id
is the result ofvim.lsp.start
orvim.lsp.start_client
or similar.- the server actually provides commands. If it doesn’t, then
vim.lsp.get_client_by_id(client_id).server_capabilities.executeCommandProvider
will be nil.
1 Like