fix(init): migrate vim.validate to positional parameter API

Problem: Neovim 0.11+ deprecated the table-based `vim.validate({...})`
form, producing warnings on every plugin load.

Solution: convert all `vim.validate` calls in `init()` to the new
positional `vim.validate(name, value, validator, optional_or_msg)` form.
This commit is contained in:
Barrett Ruth 2026-03-05 23:17:48 -05:00
parent 58589947e8
commit 1fb906824f
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -591,139 +591,122 @@ local function init()
opts.neogit = {} opts.neogit = {}
end end
vim.validate({ vim.validate('debug', opts.debug, function(v)
debug = {
opts.debug,
function(v)
return v == nil or type(v) == 'boolean' or type(v) == 'string' return v == nil or type(v) == 'boolean' or type(v) == 'string'
end, end, 'boolean or string (file path)')
'boolean or string (file path)', vim.validate('hide_prefix', opts.hide_prefix, 'boolean', true)
}, vim.validate('fugitive', opts.fugitive, function(v)
hide_prefix = { opts.hide_prefix, 'boolean', true },
fugitive = {
opts.fugitive,
function(v)
return v == nil or v == false or type(v) == 'table' return v == nil or v == false or type(v) == 'table'
end, end, 'table or false')
'table or false', vim.validate('neogit', opts.neogit, function(v)
},
neogit = {
opts.neogit,
function(v)
return v == nil or v == false or type(v) == 'table' return v == nil or v == false or type(v) == 'table'
end, end, 'table or false')
'table or false', vim.validate('extra_filetypes', opts.extra_filetypes, 'table', true)
}, vim.validate('highlights', opts.highlights, 'table', true)
extra_filetypes = { opts.extra_filetypes, 'table', true },
highlights = { opts.highlights, 'table', true },
})
if opts.highlights then if opts.highlights then
vim.validate({ vim.validate('highlights.background', opts.highlights.background, 'boolean', true)
['highlights.background'] = { opts.highlights.background, 'boolean', true }, vim.validate('highlights.gutter', opts.highlights.gutter, 'boolean', true)
['highlights.gutter'] = { opts.highlights.gutter, 'boolean', true }, vim.validate('highlights.blend_alpha', opts.highlights.blend_alpha, 'number', true)
['highlights.blend_alpha'] = { opts.highlights.blend_alpha, 'number', true }, vim.validate('highlights.overrides', opts.highlights.overrides, 'table', true)
['highlights.overrides'] = { opts.highlights.overrides, 'table', true }, vim.validate('highlights.context', opts.highlights.context, 'table', true)
['highlights.context'] = { opts.highlights.context, 'table', true }, vim.validate('highlights.treesitter', opts.highlights.treesitter, 'table', true)
['highlights.treesitter'] = { opts.highlights.treesitter, 'table', true }, vim.validate('highlights.vim', opts.highlights.vim, 'table', true)
['highlights.vim'] = { opts.highlights.vim, 'table', true }, vim.validate('highlights.intra', opts.highlights.intra, 'table', true)
['highlights.intra'] = { opts.highlights.intra, 'table', true }, vim.validate('highlights.priorities', opts.highlights.priorities, 'table', true)
['highlights.priorities'] = { opts.highlights.priorities, 'table', true },
})
if opts.highlights.context then if opts.highlights.context then
vim.validate({ vim.validate('highlights.context.enabled', opts.highlights.context.enabled, 'boolean', true)
['highlights.context.enabled'] = { opts.highlights.context.enabled, 'boolean', true }, vim.validate('highlights.context.lines', opts.highlights.context.lines, 'number', true)
['highlights.context.lines'] = { opts.highlights.context.lines, 'number', true },
})
end end
if opts.highlights.treesitter then if opts.highlights.treesitter then
vim.validate({ vim.validate(
['highlights.treesitter.enabled'] = { opts.highlights.treesitter.enabled, 'boolean', true }, 'highlights.treesitter.enabled',
['highlights.treesitter.max_lines'] = { opts.highlights.treesitter.enabled,
'boolean',
true
)
vim.validate(
'highlights.treesitter.max_lines',
opts.highlights.treesitter.max_lines, opts.highlights.treesitter.max_lines,
'number', 'number',
true, true
}, )
})
end end
if opts.highlights.vim then if opts.highlights.vim then
vim.validate({ vim.validate('highlights.vim.enabled', opts.highlights.vim.enabled, 'boolean', true)
['highlights.vim.enabled'] = { opts.highlights.vim.enabled, 'boolean', true }, vim.validate('highlights.vim.max_lines', opts.highlights.vim.max_lines, 'number', true)
['highlights.vim.max_lines'] = { opts.highlights.vim.max_lines, 'number', true },
})
end end
if opts.highlights.intra then if opts.highlights.intra then
vim.validate({ vim.validate('highlights.intra.enabled', opts.highlights.intra.enabled, 'boolean', true)
['highlights.intra.enabled'] = { opts.highlights.intra.enabled, 'boolean', true }, vim.validate('highlights.intra.algorithm', opts.highlights.intra.algorithm, function(v)
['highlights.intra.algorithm'] = {
opts.highlights.intra.algorithm,
function(v)
return v == nil or v == 'default' or v == 'vscode' return v == nil or v == 'default' or v == 'vscode'
end, end, "'default' or 'vscode'")
"'default' or 'vscode'", vim.validate('highlights.intra.max_lines', opts.highlights.intra.max_lines, 'number', true)
},
['highlights.intra.max_lines'] = { opts.highlights.intra.max_lines, 'number', true },
})
end end
if opts.highlights.priorities then if opts.highlights.priorities then
vim.validate({ vim.validate('highlights.priorities.clear', opts.highlights.priorities.clear, 'number', true)
['highlights.priorities.clear'] = { opts.highlights.priorities.clear, 'number', true }, vim.validate(
['highlights.priorities.syntax'] = { opts.highlights.priorities.syntax, 'number', true }, 'highlights.priorities.syntax',
['highlights.priorities.line_bg'] = { opts.highlights.priorities.line_bg, 'number', true }, opts.highlights.priorities.syntax,
['highlights.priorities.char_bg'] = { opts.highlights.priorities.char_bg, 'number', true }, 'number',
}) true
)
vim.validate(
'highlights.priorities.line_bg',
opts.highlights.priorities.line_bg,
'number',
true
)
vim.validate(
'highlights.priorities.char_bg',
opts.highlights.priorities.char_bg,
'number',
true
)
end end
end end
if type(opts.fugitive) == 'table' then if type(opts.fugitive) == 'table' then
---@type diffs.FugitiveConfig ---@type diffs.FugitiveConfig
local fug = opts.fugitive local fug = opts.fugitive
vim.validate({ vim.validate('fugitive.horizontal', fug.horizontal, function(v)
['fugitive.horizontal'] = {
fug.horizontal,
function(v)
return v == nil or v == false or type(v) == 'string' return v == nil or v == false or type(v) == 'string'
end, end, 'string or false')
'string or false', vim.validate('fugitive.vertical', fug.vertical, function(v)
},
['fugitive.vertical'] = {
fug.vertical,
function(v)
return v == nil or v == false or type(v) == 'string' return v == nil or v == false or type(v) == 'string'
end, end, 'string or false')
'string or false',
},
})
end end
if opts.conflict then if opts.conflict then
vim.validate({ vim.validate('conflict.enabled', opts.conflict.enabled, 'boolean', true)
['conflict.enabled'] = { opts.conflict.enabled, 'boolean', true }, vim.validate('conflict.disable_diagnostics', opts.conflict.disable_diagnostics, 'boolean', true)
['conflict.disable_diagnostics'] = { opts.conflict.disable_diagnostics, 'boolean', true }, vim.validate('conflict.show_virtual_text', opts.conflict.show_virtual_text, 'boolean', true)
['conflict.show_virtual_text'] = { opts.conflict.show_virtual_text, 'boolean', true }, vim.validate(
['conflict.format_virtual_text'] = { opts.conflict.format_virtual_text, 'function', true }, 'conflict.format_virtual_text',
['conflict.show_actions'] = { opts.conflict.show_actions, 'boolean', true }, opts.conflict.format_virtual_text,
['conflict.priority'] = { opts.conflict.priority, 'number', true }, 'function',
['conflict.keymaps'] = { opts.conflict.keymaps, 'table', true }, true
}) )
vim.validate('conflict.show_actions', opts.conflict.show_actions, 'boolean', true)
vim.validate('conflict.priority', opts.conflict.priority, 'number', true)
vim.validate('conflict.keymaps', opts.conflict.keymaps, 'table', true)
if opts.conflict.keymaps then if opts.conflict.keymaps then
local keymap_validator = function(v) local keymap_validator = function(v)
return v == false or type(v) == 'string' return v == false or type(v) == 'string'
end end
for _, key in ipairs({ 'ours', 'theirs', 'both', 'none', 'next', 'prev' }) do for _, key in ipairs({ 'ours', 'theirs', 'both', 'none', 'next', 'prev' }) do
vim.validate({ vim.validate(
['conflict.keymaps.' .. key] = { 'conflict.keymaps.' .. key,
opts.conflict.keymaps[key], opts.conflict.keymaps[key],
keymap_validator, keymap_validator,
'string or false', 'string or false'
}, )
})
end end
end end
end end