Home Explore Blog CI



neovim

12th chunk of `runtime/doc/lsp.txt`
d336e9c8ec077f503b22b9b67049cab8176f52bc96a170e10000000100000fc7
 'stylua.toml', '.git' }
<

                         Example: Find the first ancestor directory containing
                         EITHER "stylua.toml" or ".luarc.json"; if not found,
                         find the first ancestor containing ".git": >lua
                               root_markers = { { 'stylua.toml', '.luarc.json' }, '.git' }
<


buf_attach_client({bufnr}, {client_id})          *vim.lsp.buf_attach_client()*
    Implements the `textDocument/did…` notifications required to track a
    buffer for any language server.

    Without calling this, the server won't be notified of changes to a buffer.

    Parameters: ~
      • {bufnr}      (`integer`) Buffer handle, or 0 for current
      • {client_id}  (`integer`) Client id

    Return: ~
        (`boolean`) success `true` if client was attached successfully;
        `false` otherwise

buf_detach_client({bufnr}, {client_id})          *vim.lsp.buf_detach_client()*
    Detaches client from the specified buffer. Note: While the server is
    notified that the text document (buffer) was closed, it is still able to
    send notifications should it ignore this notification.

    Parameters: ~
      • {bufnr}      (`integer`) Buffer handle, or 0 for current
      • {client_id}  (`integer`) Client id

buf_is_attached({bufnr}, {client_id})              *vim.lsp.buf_is_attached()*
    Checks if a buffer is attached for a particular client.

    Parameters: ~
      • {bufnr}      (`integer`) Buffer handle, or 0 for current
      • {client_id}  (`integer`) the client id

buf_notify({bufnr}, {method}, {params})                 *vim.lsp.buf_notify()*
    Send a notification to a server

    Attributes: ~
        Since: 0.5.0

    Parameters: ~
      • {bufnr}   (`integer?`) The number of the buffer
      • {method}  (`string`) Name of the request method
      • {params}  (`any`) Arguments to send to the server

    Return: ~
        (`boolean`) success true if any client returns true; false otherwise

                                                   *vim.lsp.buf_request_all()*
buf_request_all({bufnr}, {method}, {params}, {handler})
    Sends an async request for all active clients attached to the buffer and
    executes the `handler` callback with the combined result.

    Attributes: ~
        Since: 0.5.0

    Parameters: ~
      • {bufnr}    (`integer`) Buffer handle, or 0 for current.
      • {method}   (`string`) LSP method name
      • {params}   (`table|(fun(client: vim.lsp.Client, bufnr: integer): table?)?`)
                   Parameters to send to the server. Can also be passed as a
                   function that returns the params table for cases where
                   parameters are specific to the client.
      • {handler}  (`function`) Handler called after all requests are
                   completed. Server results are passed as a
                   `client_id:result` map.

    Return: ~
        (`function`) cancel Function that cancels all requests.

                                                  *vim.lsp.buf_request_sync()*
buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
    Sends a request to all server and waits for the response of all of them.

    Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the
    result. Parameters are the same as |vim.lsp.buf_request_all()| but the
    result is different. Waits a maximum of {timeout_ms}.

    Attributes: ~
        Since: 0.5.0

    Parameters: ~
      • {bufnr}       (`integer`) Buffer handle, or 0 for current.
      • {method}      (`string`) LSP method name
      • {params}      (`table|(fun(client: vim.lsp.Client, bufnr: integer): table?)?`)
                      Parameters to send to the server. Can also be passed as
                      a function that returns the params table for cases where
                      parameters are specific to the client.
      • {timeout_ms}  (`integer?`, default: `1000`) Maximum time in
                      milliseconds to wait for a result.

Title: vim.lsp Buffer Attachment and Request Functions
Summary
This section describes functions for managing LSP clients attached to buffers in Neovim. It details `vim.lsp.buf_attach_client()` and `vim.lsp.buf_detach_client()` for attaching and detaching clients, `vim.lsp.buf_is_attached()` for checking attachment status, `vim.lsp.buf_notify()` for sending notifications, and `vim.lsp.buf_request_all()` for sending asynchronous requests to all active clients. Additionally, it covers `vim.lsp.buf_request_sync()` for sending synchronous requests and waiting for responses from all servers, with a specified timeout.