mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 17:12:40 +00:00
refactor(lsp): rename foos_by_bar to bar_foos #28505
This commit is contained in:
@@ -41,13 +41,13 @@ function M.on_inlayhint(err, result, ctx, _)
|
|||||||
bufstate.client_hints = vim.defaulttable()
|
bufstate.client_hints = vim.defaulttable()
|
||||||
bufstate.version = ctx.version
|
bufstate.version = ctx.version
|
||||||
end
|
end
|
||||||
local hints_by_client = bufstate.client_hints
|
local client_hints = bufstate.client_hints
|
||||||
local client = assert(vim.lsp.get_client_by_id(client_id))
|
local client = assert(vim.lsp.get_client_by_id(client_id))
|
||||||
|
|
||||||
local new_hints_by_lnum = vim.defaulttable()
|
local new_lnum_hints = vim.defaulttable()
|
||||||
local num_unprocessed = #result
|
local num_unprocessed = #result
|
||||||
if num_unprocessed == 0 then
|
if num_unprocessed == 0 then
|
||||||
hints_by_client[client_id] = {}
|
client_hints[client_id] = {}
|
||||||
bufstate.version = ctx.version
|
bufstate.version = ctx.version
|
||||||
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
||||||
return
|
return
|
||||||
@@ -73,10 +73,10 @@ function M.on_inlayhint(err, result, ctx, _)
|
|||||||
for _, hint in ipairs(result) do
|
for _, hint in ipairs(result) do
|
||||||
local lnum = hint.position.line
|
local lnum = hint.position.line
|
||||||
hint.position.character = pos_to_byte(hint.position)
|
hint.position.character = pos_to_byte(hint.position)
|
||||||
table.insert(new_hints_by_lnum[lnum], hint)
|
table.insert(new_lnum_hints[lnum], hint)
|
||||||
end
|
end
|
||||||
|
|
||||||
hints_by_client[client_id] = new_hints_by_lnum
|
client_hints[client_id] = new_lnum_hints
|
||||||
bufstate.version = ctx.version
|
bufstate.version = ctx.version
|
||||||
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
||||||
end
|
end
|
||||||
@@ -175,19 +175,19 @@ function M.get(filter)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @type vim.lsp.inlay_hint.get.ret[]
|
--- @type vim.lsp.inlay_hint.get.ret[]
|
||||||
local hints = {}
|
local result = {}
|
||||||
for _, client in pairs(clients) do
|
for _, client in pairs(clients) do
|
||||||
local hints_by_lnum = bufstate.client_hints[client.id]
|
local lnum_hints = bufstate.client_hints[client.id]
|
||||||
if hints_by_lnum then
|
if lnum_hints then
|
||||||
for lnum = range.start.line, range['end'].line do
|
for lnum = range.start.line, range['end'].line do
|
||||||
local line_hints = hints_by_lnum[lnum] or {}
|
local hints = lnum_hints[lnum] or {}
|
||||||
for _, hint in pairs(line_hints) do
|
for _, hint in pairs(hints) do
|
||||||
local line, char = hint.position.line, hint.position.character
|
local line, char = hint.position.line, hint.position.character
|
||||||
if
|
if
|
||||||
(line > range.start.line or char >= range.start.character)
|
(line > range.start.line or char >= range.start.character)
|
||||||
and (line < range['end'].line or char <= range['end'].character)
|
and (line < range['end'].line or char <= range['end'].character)
|
||||||
then
|
then
|
||||||
table.insert(hints, {
|
table.insert(result, {
|
||||||
bufnr = bufnr,
|
bufnr = bufnr,
|
||||||
client_id = client.id,
|
client_id = client.id,
|
||||||
inlay_hint = hint,
|
inlay_hint = hint,
|
||||||
@@ -197,7 +197,7 @@ function M.get(filter)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hints
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Clear inlay hints
|
--- Clear inlay hints
|
||||||
@@ -315,14 +315,14 @@ api.nvim_set_decoration_provider(namespace, {
|
|||||||
if not bufstate.client_hints then
|
if not bufstate.client_hints then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local hints_by_client = assert(bufstate.client_hints)
|
local client_hints = assert(bufstate.client_hints)
|
||||||
|
|
||||||
for lnum = topline, botline do
|
for lnum = topline, botline do
|
||||||
if bufstate.applied[lnum] ~= bufstate.version then
|
if bufstate.applied[lnum] ~= bufstate.version then
|
||||||
api.nvim_buf_clear_namespace(bufnr, namespace, lnum, lnum + 1)
|
api.nvim_buf_clear_namespace(bufnr, namespace, lnum, lnum + 1)
|
||||||
for _, hints_by_lnum in pairs(hints_by_client) do
|
for _, lnum_hints in pairs(client_hints) do
|
||||||
local line_hints = hints_by_lnum[lnum] or {}
|
local hints = lnum_hints[lnum] or {}
|
||||||
for _, hint in pairs(line_hints) do
|
for _, hint in pairs(hints) do
|
||||||
local text = ''
|
local text = ''
|
||||||
local label = hint.label
|
local label = hint.label
|
||||||
if type(label) == 'string' then
|
if type(label) == 'string' then
|
||||||
|
|||||||
Reference in New Issue
Block a user