mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
Add support for textDocument/references.
Add set_qflist and set_loclist. - Also add locations_to_items, which calculates byte offsets for character positions in files and avoids unnecessary operations.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
local vim = vim
|
||||
local validate = vim.validate
|
||||
local api = vim.api
|
||||
local vfn = vim.fn
|
||||
@@ -330,5 +331,19 @@ function M.rename(new_name)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.references(context)
|
||||
validate { context = { context, 't', true } }
|
||||
local params = util.make_position_params()
|
||||
params.context = context or {
|
||||
includeDeclaration = true;
|
||||
}
|
||||
params[vim.type_idx] = vim.types.dictionary
|
||||
request('textDocument/references', params, function(_, _, result)
|
||||
if not result then return end
|
||||
util.set_qflist(result)
|
||||
vim.api.nvim_command("copen")
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
-- vim:sw=2 ts=2 et
|
||||
|
||||
Reference in New Issue
Block a user