mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix: another round of type annotation fixes
This commit is contained in:
committed by
Lewis Russell
parent
0ab4d36254
commit
1d4ba8c1ed
@ -282,6 +282,11 @@ M.severity = {
|
||||
[2] = 'WARN',
|
||||
[3] = 'INFO',
|
||||
[4] = 'HINT',
|
||||
--- Mappings from qflist/loclist error types to severities
|
||||
E = 1,
|
||||
W = 2,
|
||||
I = 3,
|
||||
N = 4,
|
||||
}
|
||||
|
||||
--- @alias vim.diagnostic.SeverityInt 1|2|3|4
|
||||
@ -289,12 +294,6 @@ M.severity = {
|
||||
--- See |diagnostic-severity| and |vim.diagnostic.get()|
|
||||
--- @alias vim.diagnostic.SeverityFilter vim.diagnostic.Severity|vim.diagnostic.Severity[]|{min:vim.diagnostic.Severity,max:vim.diagnostic.Severity}
|
||||
|
||||
-- Mappings from qflist/loclist error types to severities
|
||||
M.severity.E = M.severity.ERROR
|
||||
M.severity.W = M.severity.WARN
|
||||
M.severity.I = M.severity.INFO
|
||||
M.severity.N = M.severity.HINT
|
||||
|
||||
--- @type vim.diagnostic.Opts
|
||||
local global_diagnostic_options = {
|
||||
signs = true,
|
||||
@ -891,14 +890,14 @@ local function next_diagnostic(search_forward, opts)
|
||||
if opts.win_id then
|
||||
vim.deprecate('opts.win_id', 'opts.winid', '0.13')
|
||||
opts.winid = opts.win_id
|
||||
opts.win_id = nil
|
||||
opts.win_id = nil --- @diagnostic disable-line
|
||||
end
|
||||
|
||||
-- Support deprecated cursor_position alias
|
||||
if opts.cursor_position then
|
||||
vim.deprecate('opts.cursor_position', 'opts.pos', '0.13')
|
||||
opts.pos = opts.cursor_position
|
||||
opts.cursor_position = nil
|
||||
opts.cursor_position = nil --- @diagnostic disable-line
|
||||
end
|
||||
|
||||
local winid = opts.winid or api.nvim_get_current_win()
|
||||
@ -979,7 +978,7 @@ local function goto_diagnostic(diagnostic, opts)
|
||||
if opts.win_id then
|
||||
vim.deprecate('opts.win_id', 'opts.winid', '0.13')
|
||||
opts.winid = opts.win_id
|
||||
opts.win_id = nil
|
||||
opts.win_id = nil --- @diagnostic disable-line
|
||||
end
|
||||
|
||||
local winid = opts.winid or api.nvim_get_current_win()
|
||||
@ -992,8 +991,9 @@ local function goto_diagnostic(diagnostic, opts)
|
||||
vim.cmd('normal! zv')
|
||||
end)
|
||||
|
||||
if opts.float then
|
||||
local float_opts = type(opts.float) == 'table' and opts.float or {}
|
||||
local float_opts = opts.float
|
||||
if float_opts then
|
||||
float_opts = type(float_opts) == 'table' and float_opts or {}
|
||||
vim.schedule(function()
|
||||
M.open_float(vim.tbl_extend('keep', float_opts, {
|
||||
bufnr = api.nvim_win_get_buf(winid),
|
||||
@ -1317,7 +1317,7 @@ function M.jump(opts)
|
||||
if opts.cursor_position then
|
||||
vim.deprecate('opts.cursor_position', 'opts.pos', '0.13')
|
||||
opts.pos = opts.cursor_position
|
||||
opts.cursor_position = nil
|
||||
opts.cursor_position = nil --- @diagnostic disable-line
|
||||
end
|
||||
|
||||
local diag = nil
|
||||
@ -1488,14 +1488,9 @@ M.handlers.underline = {
|
||||
local get_priority = severity_to_extmark_priority(vim.hl.priorities.diagnostics, opts)
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
--- @type string?
|
||||
-- Default to error if we don't have a highlight associated
|
||||
local higroup = underline_highlight_map[assert(diagnostic.severity)]
|
||||
|
||||
if higroup == nil then
|
||||
-- Default to error if we don't have a highlight associated
|
||||
-- TODO(lewis6991): this is always nil since underline_highlight_map only has integer keys
|
||||
higroup = underline_highlight_map.Error
|
||||
end
|
||||
or underline_highlight_map[vim.diagnostic.severity.ERROR]
|
||||
|
||||
if diagnostic._tags then
|
||||
-- TODO(lewis6991): we should be able to stack these.
|
||||
@ -2115,9 +2110,10 @@ function M.enable(enable, filter)
|
||||
|
||||
enable = enable == nil and true or enable
|
||||
local bufnr = filter.bufnr
|
||||
local ns_id = filter.ns_id
|
||||
|
||||
if bufnr == nil then
|
||||
if filter.ns_id == nil then
|
||||
if not bufnr then
|
||||
if not ns_id then
|
||||
diagnostic_disabled = (
|
||||
enable
|
||||
-- Enable everything by setting diagnostic_disabled to an empty table.
|
||||
@ -2131,12 +2127,12 @@ function M.enable(enable, filter)
|
||||
})
|
||||
)
|
||||
else
|
||||
local ns = M.get_namespace(filter.ns_id)
|
||||
local ns = M.get_namespace(ns_id)
|
||||
ns.disabled = not enable
|
||||
end
|
||||
else
|
||||
bufnr = get_bufnr(bufnr)
|
||||
if filter.ns_id == nil then
|
||||
if not ns_id then
|
||||
diagnostic_disabled[bufnr] = (not enable) and true or nil
|
||||
else
|
||||
if type(diagnostic_disabled[bufnr]) ~= 'table' then
|
||||
@ -2146,14 +2142,14 @@ function M.enable(enable, filter)
|
||||
diagnostic_disabled[bufnr] = {}
|
||||
end
|
||||
end
|
||||
diagnostic_disabled[bufnr][filter.ns_id] = (not enable) and true or nil
|
||||
diagnostic_disabled[bufnr][ns_id] = (not enable) and true or nil
|
||||
end
|
||||
end
|
||||
|
||||
if enable then
|
||||
M.show(filter.ns_id, bufnr)
|
||||
M.show(ns_id, bufnr)
|
||||
else
|
||||
M.hide(filter.ns_id, bufnr)
|
||||
M.hide(ns_id, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user