Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 144 additions & 108 deletions runtime/doc/lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -816,109 +816,117 @@ start_client({config}) *vim.lsp.start_client()*
table.

Parameters: ~
{root_dir} (required, string) Directory where the
LSP server will base its rootUri on
initialization.
{cmd} (required, string or list treated like
|jobstart()|) Base command that
initiates the LSP client.
{cmd_cwd} (string, default=|getcwd()|) Directory
to launch the `cmd` process. Not
related to `root_dir` .
{cmd_env} (table) Environment flags to pass to
the LSP on spawn. Can be specified
using keys like a map or as a list with `k=v` pairs or both. Non-string values are
coerced to string. Example: >
{root_dir} (required, string) Directory where
the LSP server will base its rootUri
on initialization.
{cmd} (required, string or list treated
like |jobstart()|) Base command that
initiates the LSP client.
{cmd_cwd} (string, default=|getcwd()|)
Directory to launch the `cmd`
process. Not related to `root_dir` .
{cmd_env} (table) Environment flags to pass to
the LSP on spawn. Can be specified
using keys like a map or as a list
with `k=v` pairs or both. Non-string values are
coerced to string. Example: >
{ "PRODUCTION=true"; "TEST=123"; PORT = 8080; HOST = "0.0.0.0"; }
<
{capabilities} Map overriding the default capabilities
defined by
|vim.lsp.protocol.make_client_capabilities()|,
passed to the language server on
initialization. Hint: use
make_client_capabilities() and modify
its result.
• Note: To send an empty dictionary use
`{[vim.type_idx]=vim.types.dictionary}`
, else it will be encoded as an
array.
{handlers} Map of language server method names to
|lsp-handler|
{settings} Map with language server specific
settings. These are returned to the
language server if requested via
`workspace/configuration` . Keys are
case-sensitive.
{init_options} Values to pass in the initialization
request as `initializationOptions` .
See `initialize` in the LSP spec.
{name} (string, default=client-id) Name in log
messages.
{get_language_id} function(bufnr, filetype) -> language
ID as string. Defaults to the filetype.
{offset_encoding} (default="utf-16") One of "utf-8",
"utf-16", or "utf-32" which is the
encoding that the LSP server expects.
Client does not verify this is correct.
{on_error} Callback with parameters (code, ...),
invoked when the client operation
throws an error. `code` is a number
describing the error. Other arguments
may be passed depending on the error
kind. See |vim.lsp.client_errors| for
possible errors. Use
`vim.lsp.client_errors[code]` to get
human-friendly name.
{before_init} Callback with parameters
(initialize_params, config) invoked
before the LSP "initialize" phase,
where `params` contains the parameters
being sent to the server and `config`
is the config that was passed to
|vim.lsp.start_client()|. You can use
this to modify parameters before they
are sent.
{on_init} Callback (client, initialize_result)
invoked after LSP "initialize", where
`result` is a table of `capabilities`
and anything else the server may send.
For example, clangd sends
`initialize_result.offsetEncoding` if
`capabilities.offsetEncoding` was sent
to it. You can only modify the
`client.offset_encoding` here before
any notifications are sent. Most
language servers expect to be sent
client specified settings after
initialization. Neovim does not make
this assumption. A
`workspace/didChangeConfiguration`
notification should be sent to the
server during on_init.
{on_exit} Callback (code, signal, client_id)
invoked on client exit.
• code: exit code of the process
• signal: number describing the signal
used to terminate (if any)
• client_id: client handle
{on_attach} Callback (client, bufnr) invoked when
client attaches to a buffer.
{trace} "off" | "messages" | "verbose" | nil
passed directly to the language server
in the initialize request.
Invalid/empty values will default to
"off"
{flags} A table with flags for the client. The
current (experimental) flags are:
• allow_incremental_sync (bool, default
true): Allow using incremental sync
for buffer edits
• debounce_text_changes (number,
default nil): Debounce didChange
notifications to the server by the
given number in milliseconds. No
debounce occurs if nil
{capabilities} Map overriding the default
capabilities defined by
|vim.lsp.protocol.make_client_capabilities()|,
passed to the language server on
initialization. Hint: use
make_client_capabilities() and modify
its result.
• Note: To send an empty dictionary
use
`{[vim.type_idx]=vim.types.dictionary}`
, else it will be encoded as an
array.
{handlers} Map of language server method names
to |lsp-handler|
{settings} Map with language server specific
settings. These are returned to the
language server if requested via
`workspace/configuration` . Keys are
case-sensitive.
{init_options} Values to pass in the initialization
request as `initializationOptions` .
See `initialize` in the LSP spec.
{name} (string, default=client-id) Name in
log messages.
{workspace_folders} (table) List of workspace folders
passed to the language server.
Defaults to root_dir if not set. See
`workspaceFolders` in the LSP spec
{get_language_id} function(bufnr, filetype) -> language
ID as string. Defaults to the
filetype.
{offset_encoding} (default="utf-16") One of "utf-8",
"utf-16", or "utf-32" which is the
encoding that the LSP server expects.
Client does not verify this is
correct.
{on_error} Callback with parameters (code, ...),
invoked when the client operation
throws an error. `code` is a number
describing the error. Other arguments
may be passed depending on the error
kind. See |vim.lsp.client_errors| for
possible errors. Use
`vim.lsp.client_errors[code]` to get
human-friendly name.
{before_init} Callback with parameters
(initialize_params, config) invoked
before the LSP "initialize" phase,
where `params` contains the
parameters being sent to the server
and `config` is the config that was
passed to |vim.lsp.start_client()|.
You can use this to modify parameters
before they are sent.
{on_init} Callback (client, initialize_result)
invoked after LSP "initialize", where
`result` is a table of `capabilities`
and anything else the server may
send. For example, clangd sends
`initialize_result.offsetEncoding` if
`capabilities.offsetEncoding` was
sent to it. You can only modify the
`client.offset_encoding` here before
any notifications are sent. Most
language servers expect to be sent
client specified settings after
initialization. Neovim does not make
this assumption. A
`workspace/didChangeConfiguration`
notification should be sent to the
server during on_init.
{on_exit} Callback (code, signal, client_id)
invoked on client exit.
• code: exit code of the process
• signal: number describing the
signal used to terminate (if any)
• client_id: client handle
{on_attach} Callback (client, bufnr) invoked when
client attaches to a buffer.
{trace} "off" | "messages" | "verbose" | nil
passed directly to the language
server in the initialize request.
Invalid/empty values will default to
"off"
{flags} A table with flags for the client.
The current (experimental) flags are:
• allow_incremental_sync (bool,
default true): Allow using
incremental sync for buffer edits
• debounce_text_changes (number,
default nil): Debounce didChange
notifications to the server by the
given number in milliseconds. No
debounce occurs if nil

Return: ~
Client id. |vim.lsp.get_client_by_id()| Note: client may
Expand Down Expand Up @@ -1188,6 +1196,34 @@ workspace_symbol({query}) *vim.lsp.buf.workspace_symbol()*
==============================================================================
Lua module: vim.lsp.diagnostic *lsp-diagnostic*

*vim.lsp.diagnostic.apply_to_diagnostic_items()*
apply_to_diagnostic_items({item_handler}, {command}, {opts})
Gets diagnostics, converts them to quickfix/location list
items, and applies the item_handler callback to the items.

Parameters: ~
{item_handler} function Callback to apply to the
diagnostic items
{command} string|nil Command to execute after
applying the item_handler
{opts} table|nil Configuration table. Keys:
• {client_id}: (number)
• If nil, will consider all clients
attached to buffer.

{severity}: (DiagnosticSeverity)
• Exclusive severity to consider.
Overrides {severity_limit}

• {severity_limit}: (DiagnosticSeverity)
• Limit severity of diagnostics found.
E.g. "Warning" means { "Error",
"Warning" } will be valid.

{workspace}: (boolean, default false)
• Set the list with workspace
diagnostics

*vim.lsp.diagnostic.clear()*
clear({bufnr}, {client_id}, {diagnostic_ns}, {sign_ns})
Clears the currently displayed diagnostics
Expand Down Expand Up @@ -1470,13 +1506,13 @@ save({diagnostics}, {bufnr}, {client_id}) *vim.lsp.diagnostic.save()*
save_extmarks({bufnr}, {client_id})
TODO: Documentation

set_qflist({opts}) *vim.lsp.diagnostic.set_qflist()*
Sets the quickfix list
set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()*
Sets the location list

Parameters: ~
{opts} table|nil Configuration table. Keys:
{open}: (boolean, default true)
• Open quickfix list after set
• Open loclist after set

• {client_id}: (number)
• If nil, will consider all clients attached to
Expand All @@ -1491,16 +1527,16 @@ set_qflist({opts}) *vim.lsp.diagnostic.set_qflist()*
"Warning" means { "Error", "Warning" } will be
valid.

{workspace}: (boolean, default true)
{workspace}: (boolean, default false)
• Set the list with workspace diagnostics

set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()*
Sets the location list
set_qflist({opts}) *vim.lsp.diagnostic.set_qflist()*
Sets the quickfix list

Parameters: ~
{opts} table|nil Configuration table. Keys:
{open}: (boolean, default true)
• Open loclist after set
• Open quickfix list after set

• {client_id}: (number)
• If nil, will consider all clients attached to
Expand All @@ -1515,7 +1551,7 @@ set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()*
"Warning" means { "Error", "Warning" } will be
valid.

{workspace}: (boolean, default false)
{workspace}: (boolean, default true)
• Set the list with workspace diagnostics

*vim.lsp.diagnostic.set_signs()*
Expand Down