diff options
Diffstat (limited to 'runtime/doc/lsp.txt')
-rw-r--r-- | runtime/doc/lsp.txt | 103 |
1 files changed, 76 insertions, 27 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index b704d2d6e8..f55c959a03 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -653,9 +653,6 @@ client() *vim.lsp.client* user to |vim.lsp.start_client()|. • {server_capabilities} (table): Response from the server sent on `initialize` describing the server's capabilities. - • {resolved_capabilities} (table): Normalized table of - capabilities that we have detected based on the initialize - response from the server in `server_capabilities`. client_is_stopped({client_id}) *vim.lsp.client_is_stopped()* Checks whether a client is stopped. @@ -969,18 +966,28 @@ add_workspace_folder({workspace_folder}) clear_references() *vim.lsp.buf.clear_references()* Removes document highlights from current buffer. -code_action({context}) *vim.lsp.buf.code_action()* +code_action({options}) *vim.lsp.buf.code_action()* Selects a code action available at the current cursor position. Parameters: ~ - {context} table|nil `CodeActionContext` of the LSP specification: - • diagnostics: (table|nil) LSP`Diagnostic[]` . Inferred from the current position if not - provided. - • only: (string|nil) LSP `CodeActionKind` used - to filter the code actions. Most language - servers support values like `refactor` or - `quickfix`. + {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. + • only (string|nil): LSP `CodeActionKind` + used to filter the code actions. Most + language servers support values like + `refactor` or `quickfix`. + + • filter (function|nil): Predicate function + taking an `CodeAction` and returning a + boolean. + • apply (boolean|nil): When set to `true`, and + there is just one remaining action (after + filtering), the action is applied without + user query. See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction @@ -1038,11 +1045,54 @@ execute_command({command_params}) *vim.lsp.buf.execute_command()* See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand +format({options}) *vim.lsp.buf.format()* + Formats a buffer using the attached (and optionally filtered) + language server clients. + + Parameters: ~ + {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 automatically + derived from the current Neovim options. + + See also: ~ + https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting + • timeout_ms (integer|nil, default 1000): Time in + milliseconds to block for formatting requests. No effect + if async=true + • bufnr (number|nil): Restrict formatting to the clients + attached to the given buffer, defaults to the current + buffer (0). + • filter (function|nil): Predicate to filter clients used + for formatting. Receives the list of clients attached to + bufnr as the argument and must return the list of + clients on which to request formatting. Example: • > + + -- Never request typescript-language-server for formatting + vim.lsp.buf.format { + filter = function(clients) + return vim.tbl_filter( + function(client) return client.name ~= "tsserver" end, + clients + ) + end + } +< + • async boolean|nil If true the method won't block. + Defaults to false. Editing the buffer while formatting + asynchronous can lead to unexpected changes. + • id (number|nil): Restrict formatting to the client with + 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} (optional, table) Can be used to specify + {options} (table|nil) Can be used to specify FormattingOptions. Some unspecified options will be automatically derived from the current Neovim options. @@ -1066,15 +1116,13 @@ formatting_seq_sync({options}, {timeout_ms}, {order}) < Parameters: ~ - {options} (optional, table) `FormattingOptions` - entries - {timeout_ms} (optional, number) Request timeout - {order} (optional, table) 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. + {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}) @@ -1089,7 +1137,8 @@ formatting_sync({options}, {timeout_ms}) < Parameters: ~ - {options} Table with valid `FormattingOptions` entries + {options} table|nil with valid `FormattingOptions` + entries {timeout_ms} (number) Request timeout See also: ~ @@ -1464,8 +1513,7 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* Returns indentation size. Parameters: ~ - {bufnr} (optional, number): Buffer handle, defaults to - current + {bufnr} (number|nil): Buffer handle, defaults to current Return: ~ (number) indentation size @@ -1541,7 +1589,8 @@ make_formatting_params({options}) buffer and cursor position. Parameters: ~ - {options} Table with valid `FormattingOptions` entries + {options} table|nil with valid `FormattingOptions` + entries Return: ~ `DocumentFormattingParams` object @@ -1865,8 +1914,8 @@ request({method}, {params}, {callback}, {notify_reply_callback}) {params} (table) Parameters for the invoked LSP method {callback} (function) Callback to invoke - {notify_reply_callback} (function) Callback to invoke as - soon as a request is no longer + {notify_reply_callback} (function|nil) Callback to invoke + as soon as a request is no longer pending Return: ~ |