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:
Ashkan Kiani
2019-11-24 03:01:18 -08:00
parent b78fdd7ce5
commit b35f6aa9dd
3 changed files with 79 additions and 22 deletions

View File

@@ -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