Home Explore Blog CI



neovim

5th chunk of `runtime/doc/lsp.txt`
82dffb9fd13316bb90a9d2aea871e416ba39c01e62a835790000000100000fb0
 your server doesn't support them.

You can list them with: >vim

    :lua vim.print(vim.tbl_keys(vim.lsp.handlers))
<
They are also listed below.

- `'callHierarchy/incomingCalls'`
- `'callHierarchy/outgoingCalls'`
- `'client/registerCapability'`
- `'client/unregisterCapability'`
- `'signature_help'`
- `'textDocument/codeLens'`
- `'textDocument/completion'`
- `'textDocument/diagnostic'`
- `'textDocument/documentHighlight'`
- `'textDocument/documentSymbol'`
- `'textDocument/formatting'`
- `'textDocument/hover'`
- `'textDocument/inlayHint'`
- `'textDocument/publishDiagnostics'`
- `'textDocument/rangeFormatting'`
- `'textDocument/rename'`
- `'textDocument/signatureHelp'`
- `'typeHierarchy/subtypes'`
- `'typeHierarchy/supertypes'`
- `'window/logMessage'`
- `'window/showDocument'`
- `'window/showMessage'`
- `'window/showMessageRequest'`
- `'window/workDoneProgress/create'`
- `'workspace/applyEdit'`
- `'workspace/configuration'`
- `'workspace/executeCommand'`
- `'workspace/inlayHint/refresh'`
- `'workspace/semanticTokens/refresh'`
- `'workspace/symbol'`
- `'workspace/workspaceFolders'`

                                                                 *lsp-handler*
LSP handlers are functions that handle |lsp-response|s to requests made by Nvim
to the server. (Notifications, as opposed to requests, are fire-and-forget:
there is no response, so they can't be handled. |lsp-notification|)

Each response handler has this signature: >

    function(err, result, ctx)
<
    Parameters: ~
      • {err}     (`table|nil`) Error info dict, or `nil` if the request
                  completed.
      • {result}  (`Result|Params|nil`) `result` key of the |lsp-response| or
                  `nil` if the request failed.
      • {ctx}     (`table`) Table of calling state associated with the
                  handler, with these keys:
                  • {method}     (`string`) |lsp-method| name.
                  • {client_id}  (`number`) |vim.lsp.Client| identifier.
                  • {bufnr}      (`Buffer`) Buffer handle.
                  • {params}     (`table|nil`) Request parameters table.
                  • {version}    (`number`) Document version at time of
                                 request. Handlers can compare this to the
                                 current document version to check if the
                                 response is "stale". See also |b:changedtick|.

    Returns: ~
        Two values `result, err` where `err` is shaped like an RPC error: >
            { code, message, data? }
<        You can use |vim.lsp.rpc.rpc_response_error()| to create this object.

                                                      *lsp-handler-resolution*
Handlers can be set by (in increasing priority):

                                                            *vim.lsp.handlers*
- Directly calling a LSP method via |Client:request()|. This is the only way
  to "override" the default client-to-server request handling (by
  side-stepping `vim.lsp.buf` and related interfaces). >lua
    local client = assert(vim.lsp.get_clients()[1])
    client:request('textDocument/definition')

- Setting a field in `vim.lsp.handlers`. This global table contains the
  default mappings of |lsp-method| names to handlers. (Note: only for
  server-to-client requests/notifications, not client-to-server.)
  Example: >lua
    vim.lsp.handlers['textDocument/publishDiagnostics'] = my_custom_diagnostics_handler

- Passing a {handlers} parameter to |vim.lsp.start()|. This sets the default
  |lsp-handler| for a specific server. (Note: only for server-to-client
  requests/notifications, not client-to-server.)
  Example: >lua
    vim.lsp.start {
      ..., -- Other configuration omitted.
      handlers = {
        ['textDocument/publishDiagnostics'] = my_custom_diagnostics_handler
      },
    }

- Passing a {handler} parameter to |vim.lsp.buf_request_all()|. This sets the
  |lsp-handler| ONLY for the given request(s).
  Example: >lua
    vim.lsp.buf_request_all(

Title: LSP Handlers: Function Signatures and Resolution
Summary
This section defines LSP handlers as functions that manage responses to requests from Neovim to the server. It details the signature of a response handler, including parameters like error information, results, and context. The context includes the method name, client ID, buffer handle, request parameters, and document version. The section then explains how handlers are set and resolved, listing the methods in order of increasing priority: direct calls via `Client:request()`, setting fields in `vim.lsp.handlers`, using the {handlers} parameter in `vim.lsp.start()`, and using the {handler} parameter in `vim.lsp.buf_request_all()`.