[mirror] Make your go dev experience better github.com/olexsmir/gopher.nvim
neovim golang

feat(config): vim.validate all config after setup (#98)

authored by olexsmir.xyz and committed by olexsmir.xyz a993ece5 6ee261cf

verified
Changed files
+24 -1
lua
gopher
+24 -1
lua/gopher/config.lua
··· 90 90 ---@param user_config? gopher.Config 91 91 ---@private 92 92 function config.setup(user_config) 93 - _config = vim.tbl_deep_extend("force", default_config, user_config or {}) 93 + vim.validate { user_config = { user_config, "table", true } } 94 + 95 + _config = vim.tbl_deep_extend("force", vim.deepcopy(default_config), user_config or {}) 96 + 97 + vim.validate { 98 + log_level = { _config.log_level, "number" }, 99 + timeout = { _config.timeout, "number" }, 100 + setup_commands = { _config.setup_commands, "boolean" }, 101 + ["commands"] = { _config.commands, "table" }, 102 + ["commands.go"] = { _config.commands.go, "string" }, 103 + ["commands.gomodifytags"] = { _config.commands.gomodifytags, "string" }, 104 + ["commands.gotests"] = { _config.commands.gotests, "string" }, 105 + ["commands.impl"] = { _config.commands.impl, "string" }, 106 + ["commands.iferr"] = { _config.commands.iferr, "string" }, 107 + ["gotests"] = { _config.gotests, "table" }, 108 + ["gotests.template"] = { _config.gotests.template, "string" }, 109 + ["gotests.template_dir"] = { _config.gotests.template, "string", true }, 110 + ["gotests.named"] = { _config.gotests.named, "boolean" }, 111 + ["gotag"] = { _config.gotag, "table" }, 112 + ["gotag.transform"] = { _config.gotag.transform, "string" }, 113 + ["gotag.default_tag"] = { _config.gotag.default_tag, "string" }, 114 + ["iferr"] = { _config.iferr, "table" }, 115 + ["iferr.message"] = { _config.iferr.message, "string", true }, 116 + } 94 117 end 95 118 96 119 ---@return boolean