Merge pull request #30825 from lewis6991/refactor/lsputil

This commit is contained in:
Lewis Russell
2024-10-17 13:35:02 +01:00
committed by GitHub
9 changed files with 568 additions and 550 deletions

View File

@@ -27,15 +27,20 @@ local function query_definition(pattern)
return {}
end
local results = {}
--- @param range lsp.Range
--- @param uri string
--- @param offset_encoding string
local add = function(range, uri, offset_encoding)
table.insert(results, mk_tag_item(pattern, range, uri, offset_encoding))
end
for client_id, lsp_results in pairs(assert(results_by_client)) do
local client = lsp.get_client_by_id(client_id)
local offset_encoding = client and client.offset_encoding or 'utf-16'
local result = lsp_results.result or {}
if result.range then -- Location
add(result.range, result.uri)
add(result.range, result.uri, offset_encoding)
else
result = result --[[@as (lsp.Location[]|lsp.LocationLink[])]]
for _, item in pairs(result) do

View File

@@ -338,6 +338,8 @@ function M.rename(new_name, opts)
-- Compute early to account for cursor movements after going async
local cword = vim.fn.expand('<cword>')
--- @param range lsp.Range
--- @param offset_encoding string
local function get_text_at_range(range, offset_encoding)
return api.nvim_buf_get_text(
bufnr,

File diff suppressed because it is too large Load Diff