Home Explore Blog CI



neovim

26th chunk of `runtime/doc/lsp.txt`
f1e5a1852bc6762b00e9b77461c3f4b775ae2a4807022bbe0000000100000fc1
 end: integer[]}`) Range for
                  which code actions should be requested. If in visual mode
                  this defaults to the active selection. Table must contain
                  `start` and `end` keys with {row,col} tuples using mark-like
                  indexing. See |api-indexing|

    See also: ~
      • https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
      • vim.lsp.protocol.CodeActionTriggerKind

declaration({opts})                                *vim.lsp.buf.declaration()*
    Jumps to the declaration of the symbol under the cursor.

    Note: ~
      • Many servers do not implement this method. Generally, see
        |vim.lsp.buf.definition()| instead.

    Parameters: ~
      • {opts}  (`vim.lsp.LocationOpts?`) See |vim.lsp.LocationOpts|.

definition({opts})                                  *vim.lsp.buf.definition()*
    Jumps to the definition of the symbol under the cursor.

    Parameters: ~
      • {opts}  (`vim.lsp.LocationOpts?`) See |vim.lsp.LocationOpts|.

document_highlight()                        *vim.lsp.buf.document_highlight()*
    Send request to the server to resolve document highlights for the current
    text document position. This request can be triggered by a key mapping or
    by events such as `CursorHold`, e.g.: >vim
        autocmd CursorHold  <buffer> lua vim.lsp.buf.document_highlight()
        autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
        autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
<

    Note: Usage of |vim.lsp.buf.document_highlight()| requires the following
    highlight groups to be defined or you won't be able to see the actual
    highlights. |hl-LspReferenceText| |hl-LspReferenceRead|
    |hl-LspReferenceWrite|

document_symbol({opts})                        *vim.lsp.buf.document_symbol()*
    Lists all symbols in the current buffer in the |location-list|.

    Parameters: ~
      • {opts}  (`vim.lsp.ListOpts?`) See |vim.lsp.ListOpts|.

format({opts})                                          *vim.lsp.buf.format()*
    Formats a buffer using the attached (and optionally filtered) language
    server clients.

    Parameters: ~
      • {opts}  (`table?`) A table with the following fields:
                • {formatting_options}? (`table`) Can be used to specify
                  FormattingOptions. Some unspecified options will be
                  automatically derived from the current Nvim options. See
                  https://microsoft.github.io/language-server-protocol/specification/#formattingOptions
                • {timeout_ms}? (`integer`, default: `1000`) Time in
                  milliseconds to block for formatting requests. No effect if
                  async=true.
                • {bufnr}? (`integer`, default: current buffer) Restrict
                  formatting to the clients attached to the given buffer.
                • {filter}? (`fun(client: vim.lsp.Client): boolean?`)
                  Predicate used to filter clients. Receives a client as
                  argument and must return a boolean. Clients matching the
                  predicate are included. Example: >lua
                    -- Never request typescript-language-server for formatting
                    vim.lsp.buf.format {
                      filter = function(client) return client.name ~= "ts_ls" end
                    }
<
                • {async}? (`boolean`, default: false) If true the method
                  won't block. Editing the buffer while formatting
                  asynchronous can lead to unexpected changes.
                • {id}? (`integer`) Restrict formatting to the client with ID
                  (client.id) matching this field.
                • {name}? (`string`) Restrict formatting to the client with
                  name (client.name) matching this field.
                • {range}?
                  (`{start:[integer,integer],end:[integer,

Title: vim.lsp.buf Functions: Document Highlighting, Formatting, and Symbol Listing
Summary
This section describes several `vim.lsp.buf` functions, including `document_highlight` (enables document highlighting), `document_symbol` (lists symbols in the current buffer), and `format` (formats the current buffer using attached language server clients). It details the parameters for each function, including options for filtering clients, specifying formatting options, and controlling asynchronous behavior.