From 5a89b82ca156a1af8a11bd39684eead8bbcd4fd9 Mon Sep 17 00:00:00 2001 From: Gentili-S Date: Sun, 28 Jun 2026 20:32:13 +0000 Subject: [PATCH] Fix: vim.validate --- lua/peek/config.lua | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/lua/peek/config.lua b/lua/peek/config.lua index 15ca57e..708a3c8 100644 --- a/lua/peek/config.lua +++ b/lua/peek/config.lua @@ -53,22 +53,30 @@ end function module.setup(incoming) incoming = incoming or {} - - vim.validate({ - config = { incoming, 'table' }, - }) - - vim.validate({ - close_on_bdelete = { incoming.close_on_bdelete, 'boolean', true }, - auto_load = { incoming.auto_load, 'boolean', true }, - syntax = { incoming.syntax, 'boolean', true }, - theme = { incoming.theme, optional(one_of({ 'dark', 'light' })), '"dark" or "light"' }, - update_on_change = { incoming.update_on_change, 'boolean', true }, - throttle_at = { incoming.throttle_at, 'number', true }, - throttle_time = { incoming.throttle_time, optional(one_of({ 'auto', of_type('number') })), '"auto" or number' }, - app = { incoming.app, optional(one_of({ of_type('string'), every(of_type('string')) })), 'string or string[]' }, - filetype = { incoming.filetype, optional(every(of_type('string'))), 'string[]' }, - }) + local M = { + { + 'config', + incoming, + 'table', + }, + { 'close_on_bdelete', incoming.close_on_bdelete, 'boolean', true }, + { 'auto_load', incoming.auto_load, 'boolean', true }, + { 'syntax', incoming.syntax, 'boolean', true }, + { 'theme', incoming.theme, optional(one_of({ 'dark', 'light' })), { 'dark', 'light' } }, + { 'update_on_change', incoming.update_on_change, 'boolean', true }, + { 'throttle_at', incoming.throttle_at, 'number', true }, + { 'throttle_time', incoming.throttle_time, optional(one_of({ 'auto', of_type('number') })), { 'auto', 'number' } }, + { + 'app', + incoming.app, + optional(one_of({ of_type('string'), every(of_type('string')) })), + { 'string', 'string[]' }, + }, + } + for i = 1, #M do + name, value, validator, opt = unpack(M[i]) + vim.validate(name, value, validator, opt) + end config = vim.tbl_extend('force', config, incoming) end