mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user