Home Explore Blog CI



neovim

11th chunk of `runtime/doc/lsp.txt`
dcb49f3872bdd83f2d883baa1f0facdaf0cd10dde322ae720000000100000fb2
 args.data.client_id, 'MyMutableVariableHighlight'
          )
        end
      end,
    })
<
    Note: doing anything other than calling
    |vim.lsp.semantic_tokens.highlight_token()| is considered experimental.

==============================================================================
Lua module: vim.lsp                                                 *lsp-core*

*vim.lsp.Config*
    Extends: |vim.lsp.ClientConfig|


    Fields: ~
      • {cmd}?           (`string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient`)
                         See `cmd` in |vim.lsp.ClientConfig|.
      • {filetypes}?     (`string[]`) Filetypes the client will attach to, if
                         activated by `vim.lsp.enable()`. If not provided, the
                         client will attach to all filetypes.
      • {reuse_client}?  (`fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean`)
                         Predicate which decides if a client should be
                         re-used. Used on all running clients. The default
                         implementation re-uses a client if name and root_dir
                         matches.
      • {root_dir}?      (`string|fun(bufnr: integer, on_dir:fun(root_dir?:string))`)
                         *lsp-root_dir()* Decides the workspace root: the
                         directory where the LSP server will base its
                         workspaceFolders, rootUri, and rootPath on
                         initialization. The function form must call the
                         `on_dir` callback to provide the root dir, or LSP
                         will not be activated for the buffer. Thus a
                         `root_dir()` function can dynamically decide
                         per-buffer whether to activate (or skip) LSP. See
                         example at |vim.lsp.enable()|.
      • {root_markers}?  (`(string|string[])[]`)                                    *lsp-root_markers*
                         Filename(s) (".git/", "package.json", …) used to
                         decide the workspace root. Unused if `root_dir` is
                         defined. The list order decides priority. To indicate
                         "equal priority", specify names in a nested list
                         `{ { 'a.txt', 'b.lua' }, ... }`.

                         For each item, Nvim will search upwards (from the
                         buffer file) for that marker, or list of markers;
                         search stops at the first directory containing that
                         marker, and the directory is used as the root dir
                         (workspace folder).

                         Example: Find the first ancestor directory containing
                         file or directory "stylua.toml"; if not found, find
                         the first ancestor containing ".git": >lua
                               root_markers = { '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

Title: vim.lsp Module and Configuration
Summary
This section describes the `vim.lsp` Lua module, focusing on the `vim.lsp.Config` object, which extends `vim.lsp.ClientConfig`. It details the configurable fields like `cmd`, `filetypes`, `reuse_client`, `root_dir` (including its function form for dynamic LSP activation), and `root_markers` for workspace root determination. It also covers `vim.lsp.buf_attach_client()` and `vim.lsp.buf_detach_client()` functions, which are used to attach and detach a language server client to a specific buffer, enabling or disabling notifications of changes.