LSP: Add textDocument/codeAction support (#11607)

* Add textDocument/codeAction

* Add callback for workspace/executeCommand
* Escape newlines in codeAction titles
* Return empty list in get_line_diagnostics if no buffer diagnostics
* Add stub documentation
* Validate context parameter in code_action
* Add support for edit in CodeAction responses
* Group diagnostics by line in vim.lsp.util.get_line_diagnostics()
* Advertise code action literal support
This commit is contained in:
Jesse
2020-05-16 01:18:59 +02:00
committed by GitHub
parent c37d9fa3da
commit f559e5249e
5 changed files with 97 additions and 8 deletions

View File

@@ -161,5 +161,21 @@ function M.clear_references()
util.buf_clear_references()
end
function M.code_action(context)
validate { context = { context, 't', true } }
context = context or { diagnostics = util.get_line_diagnostics() }
local params = util.make_range_params()
params.context = context
request('textDocument/codeAction', params)
end
function M.execute_command(command)
validate {
command = { command.command, 's' },
arguments = { command.arguments, 't', true }
}
request('workspace/executeCommand', command)
end
return M
-- vim:sw=2 ts=2 et