List avaiable lsp commands

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:

  1. client_id is the result of vim.lsp.start or vim.lsp.start_client or similar.
  2. 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