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.
This commit is contained in:
Fredrik Ekre
2022-04-30 10:14:31 +02:00
committed by GitHub
parent de2232878f
commit df09e03cf7
5 changed files with 125 additions and 24 deletions

View File

@@ -645,6 +645,7 @@ function protocol.make_client_capabilities()
end)();
};
};
isPreferredSupport = true;
dataSupport = true;
resolveSupport = {
properties = { 'edit', }