Home Explore Blog CI



neovim

16th chunk of `runtime/doc/lsp.txt`
c58eed6f09674b8df88eb454eda72008ae590c74422d323f0000000100000fca
 0.10.0

    Parameters: ~
      • {filter}  (`table?`) Key-value pairs used to filter the returned
                  clients.
                  • {id}? (`integer`) Only return clients with the given id
                  • {bufnr}? (`integer`) Only return clients attached to this
                    buffer
                  • {name}? (`string`) Only return clients with the given name
                  • {method}? (`string`) Only return clients supporting the
                    given method

    Return: ~
        (`vim.lsp.Client[]`) List of |vim.lsp.Client| objects

get_log_path()                                        *vim.lsp.get_log_path()*
    Gets the path of the logfile used by the LSP client.

    Return: ~
        (`string`) path to log file

is_enabled({name})                                      *vim.lsp.is_enabled()*
    Checks if the given LSP config is enabled (globally, not per-buffer).

    Unlike `vim.lsp.config['…']`, this does not have the side-effect of
    resolving the config.

    Parameters: ~
      • {name}  (`string`) Config name

    Return: ~
        (`boolean`)

omnifunc({findstart}, {base})                             *vim.lsp.omnifunc()*
    Implements 'omnifunc' compatible LSP completion.

    Parameters: ~
      • {findstart}  (`integer`) 0 or 1, decides behavior
      • {base}       (`integer`) findstart=0, text to match against

    Return: ~
        (`integer|table`) Decided by {findstart}:
        • findstart=0: column where the completion starts, or -2 or -3
        • findstart=1: list of matches (actually just calls |complete()|)

    See also: ~
      • |complete-functions|
      • |complete-items|
      • |CompleteDone|

set_log_level({level})                               *vim.lsp.set_log_level()*
    Sets the global log level for LSP logging.

    Levels by name: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF"

    Level numbers begin with "TRACE" at 0

    Use `lsp.log_levels` for reverse lookup.

    Parameters: ~
      • {level}  (`integer|string`) the case insensitive level name or number

    See also: ~
      • |vim.lsp.log_levels|

start({config}, {opts})                                      *vim.lsp.start()*
    Create a new LSP client and start a language server or reuses an already
    running client if one is found matching `name` and `root_dir`. Attaches
    the current buffer to the client.

    Example: >lua
        vim.lsp.start({
           name = 'my-server-name',
           cmd = {'name-of-language-server-executable'},
           root_dir = vim.fs.root(0, {'pyproject.toml', 'setup.py'}),
        })
<

    See |vim.lsp.ClientConfig| for all available options. The most important
    are:
    • `name` arbitrary name for the LSP client. Should be unique per language
      server.
    • `cmd` command string[] or function.
    • `root_dir` path to the project root. By default this is used to decide
      if an existing client should be re-used. The example above uses
      |vim.fs.root()| to detect the root by traversing the file system upwards
      starting from the current directory until either a `pyproject.toml` or
      `setup.py` file is found.
    • `workspace_folders` list of `{ uri:string, name: string }` tables
      specifying the project root folders used by the language server. If
      `nil` the property is derived from `root_dir` for convenience.

    Language servers use this information to discover metadata like the
    dependencies of your project and they tend to index the contents within
    the project folder.

    To ensure a language server is only started for languages it can handle,
    make sure to call |vim.lsp.start()| within a |FileType| autocmd. Either
    use |:au|, |nvim_create_autocmd()| or put the call in a
    `ftplugin/<filetype_name>.lua` (See |ftplugin-name|)

    Attributes: ~
        Since: 0.8.0

    Parameters: ~
      • {config}  (`vim.lsp.ClientConfig`) Configuration for the server. See
                  |vim.lsp.ClientConfig|.

Title: vim.lsp Configuration and Control Functions
Summary
This section describes several functions for configuring and controlling Language Server Protocol (LSP) clients in Vim. It covers `vim.lsp.get_log_path()` for obtaining the LSP client's log file path, `vim.lsp.is_enabled()` for checking if an LSP configuration is enabled, `vim.lsp.omnifunc()` for enabling LSP completion, `vim.lsp.set_log_level()` for setting the global log level for LSP logging, and `vim.lsp.start()` for creating and starting a new LSP client.