Home Explore Blog CI



neovim

23th chunk of `runtime/doc/lsp.txt`
e3a59a6bb1f196fd7b5c49c72867a435a797e0a966c6e1660000000100000fc2
 case-sensitive.
      • {trace}?               (`'off'|'messages'|'verbose'`, default: "off")
                               Passed directly to the language server in the
                               initialize request. Invalid/empty values will
      • {workspace_folders}?   (`lsp.WorkspaceFolder[]`) List of workspace
                               folders passed to the language server. For
                               backwards compatibility rootUri and rootPath
                               are derived from the first workspace folder in
                               this list. Can be `null` if the client supports
                               workspace folders but none are configured. See
                               `workspaceFolders` in LSP spec.
      • {workspace_required}?  (`boolean`, default: `false`) Server requires a
                               workspace (no "single file" support). Note:
                               Without a workspace, cross-file features
                               (navigation, hover) may or may not work
                               depending on the language server, even if the
                               server doesn't require a workspace.


Client:cancel_request({id})                          *Client:cancel_request()*
    Cancels a request with a given request id.

    Parameters: ~
      • {id}  (`integer`) id of request to cancel

    Return: ~
        (`boolean`) status indicating if the notification was successful.

    See also: ~
      • |Client:notify()|

Client:exec_cmd({command}, {context}, {handler})           *Client:exec_cmd()*
    Execute a lsp command, either via client command function (if available)
    or via workspace/executeCommand (if supported by the server)

    Parameters: ~
      • {command}  (`lsp.Command`)
      • {context}  (`{bufnr?: integer}?`)
      • {handler}  (`lsp.Handler?`) only called if a server command

Client:is_stopped()                                      *Client:is_stopped()*
    Checks whether a client is stopped.

    Return: ~
        (`boolean`) true if client is stopped or in the process of being
        stopped; false otherwise

Client:notify({method}, {params})                            *Client:notify()*
    Sends a notification to an LSP server.

    Parameters: ~
      • {method}  (`string`) LSP method name.
      • {params}  (`table?`) LSP request params.

    Return: ~
        (`boolean`) status indicating if the notification was successful. If
        it is false, then the client has shutdown.

Client:on_attach({bufnr})                                 *Client:on_attach()*
    Runs the on_attach function from the client's config if it was defined.
    Useful for buffer-local setup.

    Parameters: ~
      • {bufnr}  (`integer`) Buffer number

                                                            *Client:request()*
Client:request({method}, {params}, {handler}, {bufnr})
    Sends a request to the server.

    This is a thin wrapper around {client.rpc.request} with some additional
    checks for capabilities and handler availability.

    Parameters: ~
      • {method}   (`string`) LSP method name.
      • {params}   (`table?`) LSP request params.
      • {handler}  (`lsp.Handler?`) Response |lsp-handler| for this method.
      • {bufnr}    (`integer?`) (default: 0) Buffer handle, or 0 for current.

    Return (multiple): ~
        (`boolean`) status indicates whether the request was successful. If it
        is `false`, then it will always be `false` (the client has shutdown).
        (`integer?`) request_id Can be used with |Client:cancel_request()|.
        `nil` is request failed.

    See also: ~
      • |vim.lsp.buf_request_all()|

                                                       *Client:request_sync()*
Client:request_sync({method}, {params}, {timeout_ms}, {bufnr})
    Sends a request to the server and synchronously waits for the response.

    This is a wrapper around |Client:request()|

    Parameters:

Title: vim.lsp.Client Methods: Cancelling Requests, Executing Commands, Notifications, and Requests
Summary
This section details several `vim.lsp.Client` methods: * `Client:cancel_request({id})`: Cancels a request with a given ID. * `Client:exec_cmd({command}, {context}, {handler})`: Executes an LSP command. * `Client:is_stopped()`: Checks if a client is stopped. * `Client:notify({method}, {params})`: Sends a notification to the LSP server. * `Client:on_attach({bufnr})`: Runs the client's `on_attach` function for buffer-local setup. * `Client:request({method}, {params}, {handler}, {bufnr})`: Sends a request to the server with additional checks. * `Client:request_sync({method}, {params}, {timeout_ms}, {bufnr})`: Sends a request and synchronously waits for the response.