refactor: address emmylua diagnostics
This commit is contained in:
@@ -6,9 +6,12 @@ local NS = vim.api.nvim_create_namespace("ow.lsp.codelens")
|
||||
local position = "above"
|
||||
local separator = " | "
|
||||
|
||||
---@class ow.lsp.CodeLens : lsp.CodeLens
|
||||
---@field command lsp.Command
|
||||
|
||||
---@class ow.lsp.codelens.Row
|
||||
---@field row integer
|
||||
---@field lenses lsp.CodeLens[]
|
||||
---@field lenses ow.lsp.CodeLens[]
|
||||
---@field pending integer
|
||||
local Row = {}
|
||||
Row.__index = Row
|
||||
@@ -19,7 +22,7 @@ function Row.new(row)
|
||||
return setmetatable({ row = row, lenses = {}, pending = 0 }, Row)
|
||||
end
|
||||
|
||||
---@param lens lsp.CodeLens
|
||||
---@param lens ow.lsp.CodeLens
|
||||
function Row:add(lens)
|
||||
table.insert(self.lenses, lens)
|
||||
end
|
||||
@@ -31,8 +34,8 @@ end
|
||||
---@param lens? lsp.CodeLens
|
||||
function Row:resolve(lens)
|
||||
self.pending = self.pending - 1
|
||||
if lens then
|
||||
table.insert(self.lenses, lens)
|
||||
if lens and lens.command then
|
||||
self:add(lens)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,7 +61,9 @@ function Row:render(buf)
|
||||
end
|
||||
end
|
||||
|
||||
local col, opts
|
||||
---@type vim.api.keyset.set_extmark
|
||||
local opts
|
||||
local col
|
||||
if position == "above" then
|
||||
local line = vim.api.nvim_buf_get_lines(
|
||||
buf,
|
||||
@@ -79,7 +84,8 @@ function Row:render(buf)
|
||||
hl_mode = "combine",
|
||||
}
|
||||
else
|
||||
col = position == "inline" and self.lenses[1].range.start.character or 0
|
||||
local first = assert(self.lenses[1])
|
||||
col = position == "inline" and first.range.start.character or 0
|
||||
opts = {
|
||||
virt_text = parts,
|
||||
virt_text_pos = position,
|
||||
@@ -97,6 +103,11 @@ function Row:render(buf)
|
||||
{ self.row, -1 },
|
||||
{ details = true }
|
||||
)
|
||||
---@type {
|
||||
--- id: integer,
|
||||
--- col: integer,
|
||||
--- details: vim.api.keyset.extmark_details?
|
||||
---}
|
||||
local primary
|
||||
for i, mark in ipairs(marks) do
|
||||
if i == 1 then
|
||||
@@ -107,7 +118,7 @@ function Row:render(buf)
|
||||
end
|
||||
|
||||
if primary and primary.col == col and primary.details then
|
||||
local d = primary.details --[[@as vim.api.keyset.extmark_details]]
|
||||
local d = primary.details
|
||||
local same = opts.virt_lines
|
||||
and vim.deep_equal(d.virt_lines, opts.virt_lines)
|
||||
and d.virt_lines_above == opts.virt_lines_above
|
||||
|
||||
Reference in New Issue
Block a user