aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorFredrik Ekre <ekrefredrik@gmail.com>2022-04-30 10:14:31 +0200
committerGitHub <noreply@github.com>2022-04-30 10:14:31 +0200
commitdf09e03cf74337675751c3240069a26aec75fa3b (patch)
tree063e2a54d2a82835587ea981ac2166bb1cb87212 /runtime/doc
parentde2232878fb95bdb84f8219c7cf1d7f2c2828086 (diff)
downloadrneovim-df09e03cf74337675751c3240069a26aec75fa3b.tar.gz
rneovim-df09e03cf74337675751c3240069a26aec75fa3b.tar.bz2
rneovim-df09e03cf74337675751c3240069a26aec75fa3b.zip
feat(lsp): options to filter and auto-apply code actions (#18221)
Implement two new options to vim.lsp.buf.code_action(): - filter (function): predicate taking an Action as input, and returning a boolean. - apply (boolean): when set to true, and there is just one remaining action (after filtering), the action is applied without user query. These options can, for example, be used to filter out, and automatically apply, the action indicated by the server to be preferred: vim.lsp.buf.code_action({ filter = function(action) return action.isPreferred end, apply = true, }) Fix #17514.
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/lsp.txt26
1 files changed, 18 insertions, 8 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index b704d2d6e8..bf4c2b59d1 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -969,18 +969,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