From 4c22f84b31ebfee1b8fd59dbb254917582f3985e Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:04:03 -0500 Subject: [PATCH] feat(init): validate provider config eagerly in setup (#16) --- lua/preview/init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/preview/init.lua b/lua/preview/init.lua index 4a44a33..f4f2831 100644 --- a/lua/preview/init.lua +++ b/lua/preview/init.lua @@ -85,6 +85,20 @@ function M.setup(opts) end end + for ft, provider in pairs(providers) do + local prefix = 'providers.' .. ft + vim.validate(prefix .. '.cmd', provider.cmd, 'table') + vim.validate(prefix .. '.cmd[1]', provider.cmd[1], 'string') + vim.validate(prefix .. '.args', provider.args, { 'table', 'function' }, true) + vim.validate(prefix .. '.cwd', provider.cwd, { 'string', 'function' }, true) + vim.validate(prefix .. '.output', provider.output, { 'string', 'function' }, true) + vim.validate(prefix .. '.error_parser', provider.error_parser, 'function', true) + vim.validate(prefix .. '.errors', provider.errors, function(x) + return x == nil or x == false or x == 'diagnostic' or x == 'quickfix' + end, 'false, "diagnostic", or "quickfix"') + vim.validate(prefix .. '.open', provider.open, { 'boolean', 'table' }, true) + end + config = vim.tbl_deep_extend('force', default_config, { debug = debug, providers = providers,