aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/lsp.txt
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
committerJosh Rahm <rahm@google.com>2022-10-11 19:00:52 +0000
commit21e2e46242033c7aaa6ccfb23e256680816c063c (patch)
treef089522cfb145d6e9c8a86a01d8e454ce5501e20 /runtime/doc/lsp.txt
parent179d3ed87b17988f5fe00d8b99f2611a28212be7 (diff)
parent760b399f6c0c6470daa0663752bd22886997f9e6 (diff)
downloadrneovim-floattitle.tar.gz
rneovim-floattitle.tar.bz2
rneovim-floattitle.zip
Merge remote-tracking branch 'upstream/master' into floattitlefloattitle
Diffstat (limited to 'runtime/doc/lsp.txt')
-rw-r--r--runtime/doc/lsp.txt554
1 files changed, 260 insertions, 294 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 7fc0daa0ca..139f4c6bc5 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -40,7 +40,7 @@ Follow these steps to get LSP features:
root_dir = vim.fs.dirname(vim.fs.find({'setup.py', 'pyproject.toml'}, { upward = true })[1]),
})
<
- See |vim.lsp.start| for details.
+ See |vim.lsp.start()| for details.
3. Configure keymaps and autocmds to utilize LSP features.
See |lsp-config|.
@@ -48,19 +48,19 @@ Follow these steps to get LSP features:
*lsp-config*
Starting a LSP client will automatically report diagnostics via
-|vim.diagnostic|. Read |vim.diagnostic.config| to learn how to customize the
+|vim.diagnostic|. Read |vim.diagnostic.config()| to learn how to customize the
display.
It also sets some buffer options if the options are otherwise empty and if the
language server supports the functionality.
-- |omnifunc| is set to |vim.lsp.omnifunc|. This allows to trigger completion
- using |i_CTRL-X_CTRL-o|
-- |tagfunc| is set to |vim.lsp.tagfunc|. This enables features like
+- 'omnifunc' is set to |vim.lsp.omnifunc()|. This allows to trigger completion
+ using |i_CTRL-X_CTRL-O|
+- 'tagfunc' is set to |vim.lsp.tagfunc()|. This enables features like
go-to-definition, |:tjump|, and keymaps like |CTRL-]|, |CTRL-W_]|,
|CTRL-W_}| to utilize the language server.
-- |formatexpr| is set to |vim.lsp.formatexpr| if both |formatprg| and
- |formatexpr| are empty. This allows to format lines via |gq| if the language
+- 'formatexpr' is set to |vim.lsp.formatexpr()| if both 'formatprg' and
+ 'formatexpr' are empty. This allows to format lines via |gq| if the language
server supports it.
To use other LSP features like hover, rename, etc. you can setup some
@@ -126,13 +126,14 @@ FAQ *lsp-faq*
"after/ftplugin/python.vim".
- Q: How do I run a request synchronously (e.g. for formatting on file save)?
- A: Use the `_sync` variant of the function provided by |lsp-buf|, if it
- exists.
+ A: Check if the function has an `async` parameter and set the value to
+ false.
E.g. code formatting: >
" Auto-format *.rs (rust) files prior to saving them
- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000)
+ " (async = false is the default for format)
+ autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
<
*lsp-vs-treesitter*
@@ -189,6 +190,7 @@ specification. These LSP requests/notifications are defined by default:
textDocument/typeDefinition*
window/logMessage
window/showMessage
+ window/showDocument
window/showMessageRequest
workspace/applyEdit
workspace/symbol
@@ -244,7 +246,7 @@ For |lsp-request|, each |lsp-handler| has this signature: >
Where `err` must be shaped like an RPC error:
`{ code, message, data? }`
- You can use |vim.lsp.rpc_response_error()| to create this object.
+ You can use |vim.lsp.rpc.rpc_response_error()| to create this object.
For |lsp-notification|, each |lsp-handler| has this signature: >
@@ -337,8 +339,8 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method
}
<
Some handlers do not have an explicitly named handler function (such as
- |on_publish_diagnostics()|). To override these, first create a reference
- to the existing handler: >
+ ||vim.lsp.diagnostic.on_publish_diagnostics()|). To override these, first
+ create a reference to the existing handler: >
local on_references = vim.lsp.handlers["textDocument/references"]
vim.lsp.handlers["textDocument/references"] = vim.lsp.with(
@@ -359,7 +361,7 @@ Handlers can be set by:
vim.lsp.handlers["textDocument/definition"] = my_custom_default_definition
<
-- The {handlers} parameter for |vim.lsp.start_client|.
+- The {handlers} parameter for |vim.lsp.start_client()|.
This will set the |lsp-handler| as the default handler for this server.
For example: >
@@ -468,7 +470,7 @@ LspCodeLens
|nvim_buf_set_extmark()|.
LspCodeLensSeparator *hl-LspCodeLensSeparator*
- Used to color the separator between two or more code lens.
+ Used to color the separator between two or more code lenses.
*lsp-highlight-signature*
@@ -513,7 +515,7 @@ callback in the "data" table. Example: >
end,
})
<
-In addition, the following |User| |autocommands| are provided:
+Also the following |User| |autocommand|s are provided:
LspProgressUpdate *LspProgressUpdate*
Upon receipt of a progress notification from the server. See
@@ -538,8 +540,8 @@ buf_attach_client({bufnr}, {client_id}) *vim.lsp.buf_attach_client()*
Without calling this, the server won't be notified of changes to a buffer.
Parameters: ~
- {bufnr} (number) Buffer handle, or 0 for current
- {client_id} (number) Client id
+ • {bufnr} (number) Buffer handle, or 0 for current
+ • {client_id} (number) Client id
buf_detach_client({bufnr}, {client_id}) *vim.lsp.buf_detach_client()*
Detaches client from the specified buffer. Note: While the server is
@@ -547,23 +549,23 @@ buf_detach_client({bufnr}, {client_id}) *vim.lsp.buf_detach_client()*
send notifications should it ignore this notification.
Parameters: ~
- {bufnr} (number) Buffer handle, or 0 for current
- {client_id} (number) Client id
+ • {bufnr} (number) Buffer handle, or 0 for current
+ • {client_id} (number) 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} (number) Buffer handle, or 0 for current
- {client_id} (number) the client id
+ • {bufnr} (number) Buffer handle, or 0 for current
+ • {client_id} (number) the client id
buf_notify({bufnr}, {method}, {params}) *vim.lsp.buf_notify()*
Send a notification to a server
Parameters: ~
- {bufnr} [number] (optional): The number of the buffer
- {method} [string]: Name of the request method
- {params} [string]: Arguments to send to the server
+ • {bufnr} [number] (optional): The number of the buffer
+ • {method} [string]: Name of the request method
+ • {params} [string]: Arguments to send to the server
Return: ~
true if any client returns true; false otherwise
@@ -575,10 +577,10 @@ buf_request_all({bufnr}, {method}, {params}, {callback})
|vim.lsp.buf_request()| but the return result and callback are different.
Parameters: ~
- {bufnr} (number) Buffer handle, or 0 for current.
- {method} (string) LSP method name
- {params} (optional, table) Parameters to send to the server
- {callback} (function) The callback to call when all requests are
+ • {bufnr} (number) Buffer handle, or 0 for current.
+ • {method} (string) LSP method name
+ • {params} (optional, table) Parameters to send to the server
+ • {callback} (function) The callback to call when all requests are
finished.
Return: ~
@@ -594,10 +596,10 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
result is different. Wait maximum of {timeout_ms} (default 1000) ms.
Parameters: ~
- {bufnr} (number) Buffer handle, or 0 for current.
- {method} (string) LSP method name
- {params} (optional, table) Parameters to send to the server
- {timeout_ms} (optional, number, default=1000) Maximum time in
+ • {bufnr} (number) Buffer handle, or 0 for current.
+ • {method} (string) LSP method name
+ • {params} (optional, table) Parameters to send to the server
+ • {timeout_ms} (optional, number, default=1000) Maximum time in
milliseconds to wait for a result.
Return: ~
@@ -665,7 +667,7 @@ client_is_stopped({client_id}) *vim.lsp.client_is_stopped()*
Checks whether a client is stopped.
Parameters: ~
- {client_id} (Number)
+ • {client_id} (Number)
Return: ~
true if client is stopped, false otherwise.
@@ -675,8 +677,8 @@ for_each_buffer_client({bufnr}, {fn})
Invokes a function for each LSP client attached to a buffer.
Parameters: ~
- {bufnr} (number) Buffer number
- {fn} (function) Function to run on each client attached to buffer
+ • {bufnr} (number) Buffer number
+ • {fn} (function) Function to run on each client attached to buffer
{bufnr}. The function takes the client, client ID, and buffer
number as arguments. Example: >
@@ -695,7 +697,7 @@ formatexpr({opts}) *vim.lsp.formatexpr()*
'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`.
Parameters: ~
- {opts} (table) options for customizing the formatting expression
+ • {opts} (table) options for customizing the formatting expression
which takes the following optional keys:
• timeout_ms (default 500ms). The timeout period for the
formatting request.
@@ -704,7 +706,7 @@ get_active_clients({filter}) *vim.lsp.get_active_clients()*
Get active clients.
Parameters: ~
- {filter} (table|nil) A table with key-value pairs used to filter the
+ • {filter} (table|nil) A table with key-value pairs used to filter the
returned clients. The available keys are:
• id (number): Only return clients with the given id
• bufnr (number): Only return clients attached to this
@@ -719,17 +721,17 @@ get_buffers_by_client_id({client_id})
Returns list of buffers attached to client_id.
Parameters: ~
- {client_id} (number) client id
+ • {client_id} (number) client id
Return: ~
- list of buffer ids
+ (list) of buffer ids
get_client_by_id({client_id}) *vim.lsp.get_client_by_id()*
Gets a client by id, or nil if the id is invalid. The returned client may
not yet be fully initialized.
Parameters: ~
- {client_id} (number) client id
+ • {client_id} (number) client id
Return: ~
|vim.lsp.client| object, or nil
@@ -744,8 +746,8 @@ omnifunc({findstart}, {base}) *vim.lsp.omnifunc()*
Implements 'omnifunc' compatible LSP completion.
Parameters: ~
- {findstart} 0 or 1, decides behavior
- {base} If findstart=0, text to match against
+ • {findstart} 0 or 1, decides behavior
+ • {base} If findstart=0, text to match against
Return: ~
(number) Decided by {findstart}:
@@ -767,7 +769,7 @@ set_log_level({level}) *vim.lsp.set_log_level()*
Use `lsp.log_levels` for reverse lookup.
Parameters: ~
- {level} [number|string] the case insensitive level name or number
+ • {level} [number|string] the case insensitive level name or number
See also: ~
|vim.lsp.log_levels|
@@ -787,7 +789,8 @@ start({config}, {opts}) *vim.lsp.start()*
})
<
- See |lsp.start_client| for all available options. The most important are:
+ See |vim.lsp.start_client()| for all available options. The most important
+ are:
`name` is an arbitrary name for the LSP client. It should be unique per
language server.
@@ -797,9 +800,9 @@ start({config}, {opts}) *vim.lsp.start()*
constructs like `~` are NOT expanded.
`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.find|
- and |vim.fs.dirname| to detect the root by traversing the file system
- upwards starting from the current directory until either a
+ an existing client should be re-used. The example above uses
+ |vim.fs.find()| and |vim.fs.dirname()| 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` a list of { uri:string, name: string } tables. The
@@ -811,21 +814,23 @@ start({config}, {opts}) *vim.lsp.start()*
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
+ 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|)
Parameters: ~
- {config} (table) Same configuration as documented in
- |lsp.start_client()|
- {opts} nil|table Optional keyword arguments:
+ • {config} (table) Same configuration as documented in
+ |vim.lsp.start_client()|
+ • {opts} nil|table Optional keyword arguments:
• reuse_client (fun(client: client, config: table): boolean)
Predicate used to decide 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.
+ • bufnr (number) Buffer handle to attach to if starting or
+ re-using a client (0 for current).
Return: ~
- (number) client_id
+ (number|nil) client_id
start_client({config}) *vim.lsp.start_client()*
Starts and initializes a client with the given configuration.
@@ -835,29 +840,37 @@ start_client({config}) *vim.lsp.start_client()*
The following parameters describe fields in the {config} table.
Parameters: ~
- {cmd} (required, string or list treated like
- |jobstart()|) Base command that initiates the LSP
- client.
- {cmd_cwd} (string, default=|getcwd()|) Directory to launch
+ • {cmd} (table|string|fun(dispatchers: table):table)
+ command string or list treated like |jobstart()|.
+ The command must launch the language server
+ process. `cmd` can also be a function that
+ creates an RPC client. The function receives a
+ dispatchers table and must return a table with
+ the functions `request`, `notify`, `is_closing`
+ and `terminate` See |vim.lsp.rpc.request()| and
+ |vim.lsp.rpc.notify()| For TCP there is a
+ built-in rpc client factory:
+ |vim.lsp.rpc.connect()|
+ • {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
+ • {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"; }
<
- {detached} (boolean, default true) Daemonize the server
+ • {detached} (boolean, default true) Daemonize the server
process so that it runs in a separate process
group from Nvim. Nvim will shutdown the process
on exit, but if Nvim fails to exit cleanly this
could leave behind orphaned server processes.
- {workspace_folders} (table) List of workspace folders passed to the
+ • {workspace_folders} (table) List of workspace folders passed to the
language server. For backwards compatibility
rootUri and rootPath will be derived from the
first workspace folder in this list. See
`workspaceFolders` in the LSP spec.
- {capabilities} Map overriding the default capabilities defined
+ • {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
@@ -865,44 +878,44 @@ start_client({config}) *vim.lsp.start_client()*
• 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
+ • {handlers} Map of language server method names to
|lsp-handler|
- {settings} Map with language server specific settings. These
+ • {settings} Map with language server specific settings. These
are returned to the language server if requested
via `workspace/configuration`. Keys are
case-sensitive.
- {commands} (table) Table that maps string of clientside
+ • {commands} (table) Table that maps string of clientside
commands to user-defined functions. Commands
passed to start_client take precedence over the
global command registry. Each key must be a
unique command name, and the value is a function
which is called if any LSP action (code action,
code lenses, ...) triggers the command.
- {init_options} Values to pass in the initialization request as
+ • {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
+ • {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
+ • {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
+ • {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.rpc.client_errors| for possible errors.
+ `vim.lsp.rpc.client_errors` for possible errors.
Use `vim.lsp.rpc.client_errors[code]` to get
human-friendly name.
- {before_init} Callback with parameters (initialize_params,
+ • {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
+ • {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
@@ -915,19 +928,19 @@ start_client({config}) *vim.lsp.start_client()*
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
+ • {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
+ • {on_attach} Callback (client, bufnr) invoked when client
attaches to a buffer.
- {trace} "off" | "messages" | "verbose" | nil passed
+ • {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
+ • {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
@@ -937,11 +950,11 @@ start_client({config}) *vim.lsp.start_client()*
debounce occurs if nil
• exit_timeout (number|boolean, default false):
Milliseconds to wait for server to exit cleanly
- after sending the 'shutdown' request before
+ after sending the "shutdown" request before
sending kill -15. If set to false, nvim exits
- immediately after sending the 'shutdown'
+ immediately after sending the "shutdown"
request to the server.
- {root_dir} (string) Directory where the LSP server will base
+ • {root_dir} (string) Directory where the LSP server will base
its workspaceFolders, rootUri, and rootPath on
initialization.
@@ -964,8 +977,8 @@ stop_client({client_id}, {force}) *vim.lsp.stop_client()*
for this client, then force-shutdown is attempted.
Parameters: ~
- {client_id} client id or |vim.lsp.client| object, or list thereof
- {force} (boolean) (optional) shutdown forcefully
+ • {client_id} client id or |vim.lsp.client| object, or list thereof
+ • {force} (boolean) (optional) shutdown forcefully
tagfunc({...}) *vim.lsp.tagfunc()*
Provides an interface between the built-in client and 'tagfunc'.
@@ -976,8 +989,8 @@ tagfunc({...}) *vim.lsp.tagfunc()*
LSP servers, falls back to using built-in tags.
Parameters: ~
- {pattern} Pattern used to find a workspace symbol
- {flags} See |tag-function|
+ • {pattern} Pattern used to find a workspace symbol
+ • {flags} See |tag-function|
Return: ~
A list of matching tags
@@ -986,8 +999,8 @@ with({handler}, {override_config}) *vim.lsp.with()*
Function to manage overriding defaults for LSP handlers.
Parameters: ~
- {handler} (function) See |lsp-handler|
- {override_config} (table) Table containing the keys to override
+ • {handler} (function) See |lsp-handler|
+ • {override_config} (table) Table containing the keys to override
behavior of the {handler}
@@ -1006,7 +1019,7 @@ code_action({options}) *vim.lsp.buf.code_action()*
Selects a code action available at the current cursor position.
Parameters: ~
- {options} (table|nil) Optional table which holds the following
+ • {options} (table|nil) Optional table which holds the following
optional fields:
• context: (table|nil) Corresponds to `CodeActionContext` of the LSP specification:
• diagnostics (table|nil): LSP`Diagnostic[]` . Inferred from the current position if not provided.
@@ -1033,13 +1046,13 @@ completion({context}) *vim.lsp.buf.completion()*
called in Insert mode.
Parameters: ~
- {context} (context support not yet implemented) Additional
+ • {context} (context support not yet implemented) Additional
information about the context in which a completion was
triggered (how it was triggered, and by which trigger
character, if applicable)
See also: ~
- |vim.lsp.protocol.constants.CompletionTriggerKind|
+ vim.lsp.protocol.constants.CompletionTriggerKind
declaration({options}) *vim.lsp.buf.declaration()*
Jumps to the declaration of the symbol under the cursor.
@@ -1048,7 +1061,7 @@ declaration({options}) *vim.lsp.buf.declaration()*
|vim.lsp.buf.definition()| instead.
Parameters: ~
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• reuse_win: (boolean) Jump to existing window if buffer is
already open.
• on_list: (function) handler for list results. See
@@ -1058,7 +1071,7 @@ definition({options}) *vim.lsp.buf.definition()*
Jumps to the definition of the symbol under the cursor.
Parameters: ~
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• reuse_win: (boolean) Jump to existing window if buffer is
already open.
• on_list: (function) handler for list results. See
@@ -1076,13 +1089,14 @@ document_highlight() *vim.lsp.buf.document_highlight()*
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. |LspReferenceText| |LspReferenceRead| |LspReferenceWrite|
+ highlights. |hl-LspReferenceText| |hl-LspReferenceRead|
+ |hl-LspReferenceWrite|
document_symbol({options}) *vim.lsp.buf.document_symbol()*
Lists all symbols in the current buffer in the quickfix window.
Parameters: ~
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• on_list: (function) handler for list results. See
|lsp-on-list-handler|
@@ -1090,7 +1104,7 @@ execute_command({command_params}) *vim.lsp.buf.execute_command()*
Executes an LSP server command.
Parameters: ~
- {command_params} (table) A valid `ExecuteCommandParams` object
+ • {command_params} (table) A valid `ExecuteCommandParams` object
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand
@@ -1100,7 +1114,7 @@ format({options}) *vim.lsp.buf.format()*
server clients.
Parameters: ~
- {options} table|nil Optional table which holds the following optional
+ • {options} table|nil Optional table which holds the following optional
fields:
• formatting_options (table|nil): Can be used to specify
FormattingOptions. Some unspecified options will be
@@ -1128,59 +1142,11 @@ format({options}) *vim.lsp.buf.format()*
ID (client.id) matching this field.
• name (string|nil): Restrict formatting to the client with
name (client.name) matching this field.
-
-formatting({options}) *vim.lsp.buf.formatting()*
- Formats the current buffer.
-
- Parameters: ~
- {options} (table|nil) Can be used to specify FormattingOptions. Some
- unspecified options will be automatically derived from the
- current Neovim options.
-
- See also: ~
- https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting
-
- *vim.lsp.buf.formatting_seq_sync()*
-formatting_seq_sync({options}, {timeout_ms}, {order})
- Formats the current buffer by sequentially requesting formatting from
- attached clients.
-
- Useful when multiple clients with formatting capability are attached.
-
- Since it's synchronous, can be used for running on save, to make sure
- buffer is formatted prior to being saved. {timeout_ms} is passed on to the
- |vim.lsp.client| `request_sync` method. Example: >
-
- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
-<
-
- Parameters: ~
- {options} (table|nil) `FormattingOptions` entries
- {timeout_ms} (number|nil) Request timeout
- {order} (table|nil) List of client names. Formatting is
- requested from clients in the following order: first all
- clients that are not in the `order` list, then the
- remaining clients in the order as they occur in the
- `order` list.
-
- *vim.lsp.buf.formatting_sync()*
-formatting_sync({options}, {timeout_ms})
- Performs |vim.lsp.buf.formatting()| synchronously.
-
- Useful for running on save, to make sure buffer is formatted prior to
- being saved. {timeout_ms} is passed on to |vim.lsp.buf_request_sync()|.
- Example:
->
-
- autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
-<
-
- Parameters: ~
- {options} (table|nil) with valid `FormattingOptions` entries
- {timeout_ms} (number) Request timeout
-
- See also: ~
- |vim.lsp.buf.formatting_seq_sync|
+ • range (table|nil) Range to format. Table must contain
+ `start` and `end` keys with {row, col} tuples using (1,0)
+ indexing. Defaults to current selection in visual mode
+ Defaults to `nil` in other modes, formatting the full
+ buffer
hover() *vim.lsp.buf.hover()*
Displays hover information about the symbol under the cursor in a floating
@@ -1191,14 +1157,14 @@ implementation({options}) *vim.lsp.buf.implementation()*
quickfix window.
Parameters: ~
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• on_list: (function) handler for list results. See
|lsp-on-list-handler|
incoming_calls() *vim.lsp.buf.incoming_calls()*
Lists all the call sites of the symbol under the cursor in the |quickfix|
window. If the symbol can resolve to multiple items, the user can pick one
- in the |inputlist|.
+ in the |inputlist()|.
list_workspace_folders() *vim.lsp.buf.list_workspace_folders()*
List workspace folders.
@@ -1206,41 +1172,15 @@ list_workspace_folders() *vim.lsp.buf.list_workspace_folders()*
outgoing_calls() *vim.lsp.buf.outgoing_calls()*
Lists all the items that are called by the symbol under the cursor in the
|quickfix| window. If the symbol can resolve to multiple items, the user
- can pick one in the |inputlist|.
-
- *vim.lsp.buf.range_code_action()*
-range_code_action({context}, {start_pos}, {end_pos})
- Performs |vim.lsp.buf.code_action()| for a given range.
-
- Parameters: ~
- {context} (table|nil) `CodeActionContext` of the LSP specification:
- • diagnostics: (table|nil) LSP`Diagnostic[]` . Inferred from the current position if not provided.
- • only: (table|nil) List of LSP `CodeActionKind`s used to
- filter the code actions. Most language servers support
- values like `refactor` or `quickfix`.
- {start_pos} ({number, number}, optional) mark-indexed position.
- Defaults to the start of the last visual selection.
- {end_pos} ({number, number}, optional) mark-indexed position.
- Defaults to the end of the last visual selection.
-
- *vim.lsp.buf.range_formatting()*
-range_formatting({options}, {start_pos}, {end_pos})
- Formats a given range.
-
- Parameters: ~
- {options} Table with valid `FormattingOptions` entries.
- {start_pos} ({number, number}, optional) mark-indexed position.
- Defaults to the start of the last visual selection.
- {end_pos} ({number, number}, optional) mark-indexed position.
- Defaults to the end of the last visual selection.
+ can pick one in the |inputlist()|.
references({context}, {options}) *vim.lsp.buf.references()*
Lists all the references to the symbol under the cursor in the quickfix
window.
Parameters: ~
- {context} (table) Context for the request
- {options} (table|nil) additional options
+ • {context} (table) Context for the request
+ • {options} (table|nil) additional options
• on_list: (function) handler for list results. See
|lsp-on-list-handler|
@@ -1256,9 +1196,9 @@ rename({new_name}, {options}) *vim.lsp.buf.rename()*
Renames all references to the symbol under the cursor.
Parameters: ~
- {new_name} (string|nil) If not provided, the user will be prompted
+ • {new_name} (string|nil) If not provided, the user will be prompted
for a new name using |vim.ui.input()|.
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• filter (function|nil): Predicate used to filter clients.
Receives a client as argument and must return a boolean.
Clients matching the predicate are included.
@@ -1280,7 +1220,7 @@ type_definition({options}) *vim.lsp.buf.type_definition()*
Jumps to the definition of the type of the symbol under the cursor.
Parameters: ~
- {options} (table|nil) additional options
+ • {options} (table|nil) additional options
• reuse_win: (boolean) Jump to existing window if buffer is
already open.
• on_list: (function) handler for list results. See
@@ -1294,8 +1234,8 @@ workspace_symbol({query}, {options}) *vim.lsp.buf.workspace_symbol()*
string means no filtering is done.
Parameters: ~
- {query} (string, optional)
- {options} (table|nil) additional options
+ • {query} (string, optional)
+ • {options} (table|nil) additional options
• on_list: (function) handler for list results. See
|lsp-on-list-handler|
@@ -1308,7 +1248,7 @@ get_namespace({client_id}) *vim.lsp.diagnostic.get_namespace()*
|vim.diagnostic|.
Parameters: ~
- {client_id} (number) The id of the LSP client
+ • {client_id} (number) The id of the LSP client
*vim.lsp.diagnostic.on_publish_diagnostics()*
on_publish_diagnostics({_}, {result}, {ctx}, {config})
@@ -1337,7 +1277,7 @@ on_publish_diagnostics({_}, {result}, {ctx}, {config})
<
Parameters: ~
- {config} (table) Configuration table (see |vim.diagnostic.config()|).
+ • {config} (table) Configuration table (see |vim.diagnostic.config()|).
==============================================================================
@@ -1347,15 +1287,15 @@ display({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.display()*
Display the lenses using virtual text
Parameters: ~
- {lenses} (table) of lenses to display (`CodeLens[] | null`)
- {bufnr} (number)
- {client_id} (number)
+ • {lenses} (table) of lenses to display (`CodeLens[] | null`)
+ • {bufnr} (number)
+ • {client_id} (number)
get({bufnr}) *vim.lsp.codelens.get()*
Return all lenses for the given buffer
Parameters: ~
- {bufnr} (number) Buffer number. 0 can be used for the current buffer.
+ • {bufnr} (number) Buffer number. 0 can be used for the current buffer.
Return: ~
(table) (`CodeLens[]`)
@@ -1379,9 +1319,9 @@ save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()*
Store lenses for a specific buffer and client
Parameters: ~
- {lenses} (table) of lenses to store (`CodeLens[] | null`)
- {bufnr} (number)
- {client_id} (number)
+ • {lenses} (table) of lenses to store (`CodeLens[] | null`)
+ • {bufnr} (number)
+ • {client_id} (number)
==============================================================================
@@ -1399,7 +1339,7 @@ hover({_}, {result}, {ctx}, {config}) *vim.lsp.handlers.hover()*
<
Parameters: ~
- {config} (table) Configuration table.
+ • {config} (table) Configuration table.
• border: (default=nil)
• Add borders to the floating window
• See |nvim_open_win()|
@@ -1418,10 +1358,10 @@ signature_help({_}, {result}, {ctx}, {config})
<
Parameters: ~
- {config} (table) Configuration table.
+ • {config} (table) Configuration table.
• border: (default=nil)
• Add borders to the floating window
- • See |vim.api.nvim_open_win()|
+ • See |nvim_open_win()|
==============================================================================
@@ -1433,8 +1373,8 @@ apply_text_document_edit({text_document_edit}, {index}, {offset_encoding})
document.
Parameters: ~
- {text_document_edit} table: a `TextDocumentEdit` object
- {index} number: Optional index of the edit, if from a
+ • {text_document_edit} (table) a `TextDocumentEdit` object
+ • {index} (number) Optional index of the edit, if from a
list of edits (or nil, if not from a list)
See also: ~
@@ -1445,9 +1385,9 @@ apply_text_edits({text_edits}, {bufnr}, {offset_encoding})
Applies a list of text edits to a buffer.
Parameters: ~
- {text_edits} (table) list of `TextEdit` objects
- {bufnr} (number) Buffer id
- {offset_encoding} (string) utf-8|utf-16|utf-32
+ • {text_edits} (table) list of `TextEdit` objects
+ • {bufnr} (number) Buffer id
+ • {offset_encoding} (string) utf-8|utf-16|utf-32
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit
@@ -1457,24 +1397,24 @@ apply_workspace_edit({workspace_edit}, {offset_encoding})
Applies a `WorkspaceEdit`.
Parameters: ~
- {workspace_edit} (table) `WorkspaceEdit`
- {offset_encoding} (string) utf-8|utf-16|utf-32 (required)
+ • {workspace_edit} (table) `WorkspaceEdit`
+ • {offset_encoding} (string) utf-8|utf-16|utf-32 (required)
buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()*
Removes document highlights from a buffer.
Parameters: ~
- {bufnr} (number) Buffer id
+ • {bufnr} (number) Buffer id
*vim.lsp.util.buf_highlight_references()*
buf_highlight_references({bufnr}, {references}, {offset_encoding})
Shows a list of document highlights for a certain buffer.
Parameters: ~
- {bufnr} (number) Buffer id
- {references} (table) List of `DocumentHighlight` objects to
+ • {bufnr} (number) Buffer id
+ • {references} (table) List of `DocumentHighlight` objects to
highlight
- {offset_encoding} (string) One of "utf-8", "utf-16", "utf-32".
+ • {offset_encoding} (string) One of "utf-8", "utf-16", "utf-32".
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight
@@ -1484,10 +1424,10 @@ character_offset({buf}, {row}, {col}, {offset_encoding})
Returns the UTF-32 and UTF-16 offsets for a position in a certain buffer.
Parameters: ~
- {buf} (number) buffer number (0 for current)
- {row} 0-indexed line
- {col} 0-indexed byte offset in line
- {offset_encoding} (string) utf-8|utf-16|utf-32|nil defaults to
+ • {buf} (number) buffer number (0 for current)
+ • {row} 0-indexed line
+ • {col} 0-indexed byte offset in line
+ • {offset_encoding} (string) utf-8|utf-16|utf-32|nil defaults to
`offset_encoding` of first client of `buf`
Return: ~
@@ -1502,8 +1442,8 @@ convert_input_to_markdown_lines({input}, {contents})
`textDocument/signatureHelp`, and potentially others.
Parameters: ~
- {input} (`MarkedString` | `MarkedString[]` | `MarkupContent`)
- {contents} (table, optional, default `{}`) List of strings to extend
+ • {input} (`MarkedString` | `MarkedString[]` | `MarkupContent`)
+ • {contents} (table, optional, default `{}`) List of strings to extend
with converted lines
Return: ~
@@ -1517,14 +1457,14 @@ convert_signature_help_to_markdown_lines({signature_help}, {ft}, {triggers})
Converts `textDocument/SignatureHelp` response to markdown lines.
Parameters: ~
- {signature_help} Response of `textDocument/SignatureHelp`
- {ft} optional filetype that will be use as the `lang` for
+ • {signature_help} Response of `textDocument/SignatureHelp`
+ • {ft} optional filetype that will be use as the `lang` for
the label markdown code block
- {triggers} optional list of trigger characters from the lsp
+ • {triggers} optional list of trigger characters from the lsp
server. used to better determine parameter offsets
Return: ~
- list of lines of converted markdown.
+ (list) of lines of converted markdown.
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
@@ -1534,7 +1474,7 @@ extract_completion_items({result})
Can be used to extract the completion items from a `textDocument/completion` request, which may return one of `CompletionItem[]` , `CompletionList` or null.
Parameters: ~
- {result} (table) The result of a `textDocument/completion` request
+ • {result} (table) The result of a `textDocument/completion` request
Return: ~
(table) List of completion items
@@ -1546,26 +1486,26 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
Returns indentation size.
Parameters: ~
- {bufnr} (number|nil): Buffer handle, defaults to current
+ • {bufnr} (number|nil) Buffer handle, defaults to current
Return: ~
(number) indentation size
See also: ~
- |shiftwidth|
+ 'shiftwidth'
*vim.lsp.util.jump_to_location()*
jump_to_location({location}, {offset_encoding}, {reuse_win})
Jumps to a location.
Parameters: ~
- {location} (table) (`Location`|`LocationLink`)
- {offset_encoding} (string) utf-8|utf-16|utf-32 (required)
- {reuse_win} (boolean) Jump to existing window if buffer is
- already opened.
+ • {location} (table) (`Location`|`LocationLink`)
+ • {offset_encoding} "utf-8" | "utf-16" | "utf-32"
+ • {reuse_win} (boolean) Jump to existing window if buffer is
+ already open.
Return: ~
- `true` if the jump succeeded
+ (boolean) `true` if the jump succeeded
*vim.lsp.util.locations_to_items()*
locations_to_items({locations}, {offset_encoding})
@@ -1576,8 +1516,8 @@ locations_to_items({locations}, {offset_encoding})
|setloclist()|.
Parameters: ~
- {locations} (table) list of `Location`s or `LocationLink`s
- {offset_encoding} (string) offset_encoding for locations
+ • {locations} (table) list of `Location`s or `LocationLink`s
+ • {offset_encoding} (string) offset_encoding for locations
utf-8|utf-16|utf-32
Return: ~
@@ -1587,8 +1527,8 @@ lookup_section({settings}, {section}) *vim.lsp.util.lookup_section()*
Helper function to return nested values in language server settings
Parameters: ~
- {settings} a table of language server settings
- {section} a string indicating the field of the settings table
+ • {settings} a table of language server settings
+ • {section} a string indicating the field of the settings table
Return: ~
(table or string) The value of settings accessed via section
@@ -1599,9 +1539,9 @@ make_floating_popup_options({width}, {height}, {opts})
table can be passed to |nvim_open_win()|.
Parameters: ~
- {width} (number) window width (in character cells)
- {height} (number) window height (in character cells)
- {opts} (table, optional)
+ • {width} (number) window width (in character cells)
+ • {height} (number) window height (in character cells)
+ • {opts} (table, optional)
• offset_x (number) offset to add to `col`
• offset_y (number) offset to add to `row`
• border (string or table) override `border`
@@ -1617,7 +1557,7 @@ make_formatting_params({options})
cursor position.
Parameters: ~
- {options} (table|nil) with valid `FormattingOptions` entries
+ • {options} (table|nil) with valid `FormattingOptions` entries
Return: ~
`DocumentFormattingParams` object
@@ -1631,13 +1571,13 @@ make_given_range_params({start_pos}, {end_pos}, {bufnr}, {offset_encoding})
similar to |vim.lsp.util.make_range_params()|.
Parameters: ~
- {start_pos} number[]|nil {row, col} mark-indexed position.
+ • {start_pos} number[]|nil {row, col} mark-indexed position.
Defaults to the start of the last visual selection.
- {end_pos} number[]|nil {row, col} mark-indexed position.
+ • {end_pos} number[]|nil {row, col} mark-indexed position.
Defaults to the end of the last visual selection.
- {bufnr} (number|nil) buffer handle or 0 for current,
+ • {bufnr} (number|nil) buffer handle or 0 for current,
defaults to current
- {offset_encoding} "utf-8"|"utf-16"|"utf-32"|nil defaults to
+ • {offset_encoding} "utf-8"|"utf-16"|"utf-32"|nil defaults to
`offset_encoding` of first client of `bufnr`
Return: ~
@@ -1650,9 +1590,9 @@ make_position_params({window}, {offset_encoding})
cursor position.
Parameters: ~
- {window} number|nil: window handle or 0 for current,
+ • {window} (number|nil) window handle or 0 for current,
defaults to current
- {offset_encoding} (string) utf-8|utf-16|utf-32|nil defaults to
+ • {offset_encoding} (string) utf-8|utf-16|utf-32|nil defaults to
`offset_encoding` of first client of buffer of
`window`
@@ -1670,9 +1610,9 @@ make_range_params({window}, {offset_encoding})
`textDocument/rangeFormatting`.
Parameters: ~
- {window} number|nil: window handle or 0 for current,
+ • {window} (number|nil) window handle or 0 for current,
defaults to current
- {offset_encoding} "utf-8"|"utf-16"|"utf-32"|nil defaults to
+ • {offset_encoding} "utf-8"|"utf-16"|"utf-32"|nil defaults to
`offset_encoding` of first client of buffer of
`window`
@@ -1685,7 +1625,7 @@ make_text_document_params({bufnr})
Creates a `TextDocumentIdentifier` object for the current buffer.
Parameters: ~
- {bufnr} number|nil: Buffer handle, defaults to current
+ • {bufnr} (number|nil) Buffer handle, defaults to current
Return: ~
`TextDocumentIdentifier`
@@ -1698,18 +1638,18 @@ make_workspace_params({added}, {removed})
Create the workspace params
Parameters: ~
- {added}
- {removed}
+ • {added}
+ • {removed}
*vim.lsp.util.open_floating_preview()*
open_floating_preview({contents}, {syntax}, {opts})
Shows contents in a floating window.
Parameters: ~
- {contents} (table) of lines to show in window
- {syntax} (string) of syntax to set for opened buffer
- {opts} (table) with optional fields (additional keys are passed
- on to |vim.api.nvim_open_win()|)
+ • {contents} (table) of lines to show in window
+ • {syntax} (string) of syntax to set for opened buffer
+ • {opts} (table) with optional fields (additional keys are passed
+ on to |nvim_open_win()|)
• height: (number) height of floating window
• width: (number) width of floating window
• wrap: (boolean, default true) wrap long lines
@@ -1737,7 +1677,7 @@ parse_snippet({input}) *vim.lsp.util.parse_snippet()*
Parses snippets in a completion entry.
Parameters: ~
- {input} (string) unparsed snippet
+ • {input} (string) unparsed snippet
Return: ~
(string) parsed snippet
@@ -1751,7 +1691,7 @@ preview_location({location}, {opts}) *vim.lsp.util.preview_location()*
definition)
Parameters: ~
- {location} a single `Location` or `LocationLink`
+ • {location} a single `Location` or `LocationLink`
Return: ~
(bufnr,winnr) buffer and window number of floating window or nil
@@ -1760,7 +1700,7 @@ rename({old_fname}, {new_fname}, {opts}) *vim.lsp.util.rename()*
Rename old_fname to new_fname
Parameters: ~
- {opts} (table)
+ • {opts} (table)
set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()*
Replaces text in a range with new text.
@@ -1768,14 +1708,30 @@ set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()*
CAUTION: Changes in-place!
Parameters: ~
- {lines} (table) Original list of strings
- {A} (table) Start position; a 2-tuple of {line, col} numbers
- {B} (table) End position; a 2-tuple of {line, col} numbers
- {new_lines} A list of strings to replace the original
+ • {lines} (table) Original list of strings
+ • {A} (table) Start position; a 2-tuple of {line, col} numbers
+ • {B} (table) End position; a 2-tuple of {line, col} numbers
+ • {new_lines} A list of strings to replace the original
Return: ~
(table) The modified {lines} object
+ *vim.lsp.util.show_document()*
+show_document({location}, {offset_encoding}, {opts})
+ Shows document and optionally jumps to the location.
+
+ Parameters: ~
+ • {location} (table) (`Location`|`LocationLink`)
+ • {offset_encoding} "utf-8" | "utf-16" | "utf-32"
+ • {opts} (table) options
+ • reuse_win (boolean) Jump to existing window if
+ buffer is already open.
+ • focus (boolean) Whether to focus/jump to location
+ if possible. Defaults to true.
+
+ Return: ~
+ (boolean) `true` if succeeded
+
*vim.lsp.util.stylize_markdown()*
stylize_markdown({bufnr}, {contents}, {opts})
Converts markdown into syntax highlighted regions by stripping the code
@@ -1789,8 +1745,8 @@ stylize_markdown({bufnr}, {contents}, {opts})
`open_floating_preview` instead
Parameters: ~
- {contents} (table) of lines to show in window
- {opts} dictionary with optional fields
+ • {contents} (table) of lines to show in window
+ • {opts} dictionary with optional fields
• height of floating window
• width of floating window
• wrap_at character to wrap at for computing height
@@ -1807,7 +1763,7 @@ symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()*
Converts symbols to quickfix list items.
Parameters: ~
- {symbols} DocumentSymbol[] or SymbolInformation[]
+ • {symbols} DocumentSymbol[] or SymbolInformation[]
*vim.lsp.util.text_document_completion_list_to_complete_items()*
text_document_completion_list_to_complete_items({result}, {prefix})
@@ -1815,10 +1771,10 @@ text_document_completion_list_to_complete_items({result}, {prefix})
vim-compatible |complete-items|.
Parameters: ~
- {result} The result of a `textDocument/completion` call, e.g. from
+ • {result} The result of a `textDocument/completion` call, e.g. from
|vim.lsp.buf.completion()|, which may be one of
`CompletionItem[]`, `CompletionList` or `null`
- {prefix} (string) the prefix to filter the completion items
+ • {prefix} (string) the prefix to filter the completion items
Return: ~
{ matches = complete-items table, incomplete = bool }
@@ -1830,7 +1786,7 @@ trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()*
Removes empty lines from the beginning and end.
Parameters: ~
- {lines} (table) list of lines to trim
+ • {lines} (table) list of lines to trim
Return: ~
(table) trimmed list of lines
@@ -1843,10 +1799,10 @@ try_trim_markdown_code_blocks({lines})
CAUTION: Modifies the input in-place!
Parameters: ~
- {lines} (table) list of lines
+ • {lines} (table) list of lines
Return: ~
- (string) filetype or 'markdown' if it was unchanged.
+ (string) filetype or "markdown" if it was unchanged.
==============================================================================
@@ -1868,20 +1824,20 @@ set_format_func({handle}) *vim.lsp.log.set_format_func()*
Sets formatting function used to format logs
Parameters: ~
- {handle} (function) function to apply to logging arguments, pass
+ • {handle} (function) function to apply to logging arguments, pass
vim.inspect for multi-line formatting
set_level({level}) *vim.lsp.log.set_level()*
Sets the current log level.
Parameters: ~
- {level} (string or number) One of `vim.lsp.log.levels`
+ • {level} (string or number) One of `vim.lsp.log.levels`
should_log({level}) *vim.lsp.log.should_log()*
Checks whether the level is sufficient for logging.
Parameters: ~
- {level} (number) log level
+ • {level} (number) log level
Return: ~
(bool) true if would log, false if not
@@ -1890,11 +1846,22 @@ should_log({level}) *vim.lsp.log.should_log()*
==============================================================================
Lua module: vim.lsp.rpc *lsp-rpc*
+connect({host}, {port}) *vim.lsp.rpc.connect()*
+ Create a LSP RPC client factory that connects via TCP to the given host
+ and port
+
+ Parameters: ~
+ • {host} (string)
+ • {port} (number)
+
+ Return: ~
+ (function)
+
format_rpc_error({err}) *vim.lsp.rpc.format_rpc_error()*
Constructs an error message from an LSP error object.
Parameters: ~
- {err} (table) The error object
+ • {err} (table) The error object
Return: ~
(string) The formatted error message
@@ -1903,8 +1870,8 @@ notify({method}, {params}) *vim.lsp.rpc.notify()*
Sends a notification to the LSP server.
Parameters: ~
- {method} (string) The invoked LSP method
- {params} (table): Parameters for the invoked LSP method
+ • {method} (string) The invoked LSP method
+ • {params} (table|nil) Parameters for the invoked LSP method
Return: ~
(bool) `true` if notification could be sent, `false` if not
@@ -1914,10 +1881,11 @@ request({method}, {params}, {callback}, {notify_reply_callback})
Sends a request to the LSP server and runs {callback} upon response.
Parameters: ~
- {method} (string) The invoked LSP method
- {params} (table) Parameters for the invoked LSP method
- {callback} (function) Callback to invoke
- {notify_reply_callback} (function|nil) Callback to invoke as soon as
+ • {method} (string) The invoked LSP method
+ • {params} (table|nil) Parameters for the invoked LSP
+ method
+ • {callback} (function) Callback to invoke
+ • {notify_reply_callback} (function|nil) Callback to invoke as soon as
a request is no longer pending
Return: ~
@@ -1929,28 +1897,29 @@ rpc_response_error({code}, {message}, {data})
Creates an RPC response object/table.
Parameters: ~
- {code} (number) RPC error code defined in
+ • {code} (number) RPC error code defined in
`vim.lsp.protocol.ErrorCodes`
- {message} (string|nil) arbitrary message to send to server
- {data} any|nil arbitrary data to send to server
+ • {message} (string|nil) arbitrary message to send to server
+ • {data} any|nil arbitrary data to send to server
*vim.lsp.rpc.start()*
start({cmd}, {cmd_args}, {dispatchers}, {extra_spawn_params})
Starts an LSP server process and create an LSP RPC client object to
- interact with it. Communication with the server is currently limited to
- stdio.
+ interact with it. Communication with the spawned process happens via
+ stdio. For communication via TCP, spawn a process manually and use
+ |vim.lsp.rpc.connect()|
Parameters: ~
- {cmd} (string) Command to start the LSP server.
- {cmd_args} (table) List of additional string arguments to
+ • {cmd} (string) Command to start the LSP server.
+ • {cmd_args} (table) List of additional string arguments to
pass to {cmd}.
- {dispatchers} (table|nil) Dispatchers for LSP message types.
+ • {dispatchers} (table|nil) Dispatchers for LSP message types.
Valid dispatcher names are:
• `"notification"`
• `"server_request"`
• `"on_error"`
• `"on_exit"`
- {extra_spawn_params} (table|nil) Additional context for the LSP
+ • {extra_spawn_params} (table|nil) Additional context for the LSP
server process. May contain:
• {cwd} (string) Working directory for the LSP
server process
@@ -1962,11 +1931,8 @@ start({cmd}, {cmd_args}, {dispatchers}, {extra_spawn_params})
Methods:
• `notify()` |vim.lsp.rpc.notify()|
• `request()` |vim.lsp.rpc.request()|
-
- Members:
- • {pid} (number) The LSP server's PID.
- • {handle} A handle for low-level interaction with the LSP server
- process |vim.loop|.
+ • `is_closing()` returns a boolean indicating if the RPC is closing.
+ • `terminate()` terminates the RPC client.
==============================================================================
@@ -1977,14 +1943,14 @@ compute_diff({___MissingCloseParenHere___})
Returns the range table for the difference between prev and curr lines
Parameters: ~
- {prev_lines} (table) list of lines
- {curr_lines} (table) list of lines
- {firstline} (number) line to begin search for first difference
- {lastline} (number) line to begin search in old_lines for last
+ • {prev_lines} (table) list of lines
+ • {curr_lines} (table) list of lines
+ • {firstline} (number) line to begin search for first difference
+ • {lastline} (number) line to begin search in old_lines for last
difference
- {new_lastline} (number) line to begin search in new_lines for last
+ • {new_lastline} (number) line to begin search in new_lines for last
difference
- {offset_encoding} (string) encoding requested by language server
+ • {offset_encoding} (string) encoding requested by language server
Return: ~
(table) TextDocumentContentChangeEvent see https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocumentContentChangeEvent
@@ -2003,7 +1969,7 @@ resolve_capabilities({server_capabilities})
Creates a normalized object describing LSP server capabilities.
Parameters: ~
- {server_capabilities} (table) Table of capabilities supported by the
+ • {server_capabilities} (table) Table of capabilities supported by the
server
Return: ~