diff options
Diffstat (limited to 'runtime/doc/lsp.txt')
-rw-r--r-- | runtime/doc/lsp.txt | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 29f8fab68e..d5ee959c36 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1045,11 +1045,52 @@ 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. + Formatting requests are current synchronous to prevent + editing of the buffer. + • 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 + } +< + • 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. @@ -1073,15 +1114,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}) @@ -1096,7 +1135,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: ~ @@ -1471,8 +1511,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 @@ -1548,7 +1587,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 |