add vim.validate on user spec
This commit is contained in:
parent
d336fc33f7
commit
3f49721657
13 changed files with 33 additions and 268 deletions
|
|
@ -14,9 +14,15 @@ M.defaults = {
|
|||
codeforces = {
|
||||
cpp_version = 23,
|
||||
},
|
||||
cses = {},
|
||||
cses = {
|
||||
cpp_version = 20,
|
||||
},
|
||||
},
|
||||
snippets = {},
|
||||
hooks = {
|
||||
before_run = nil,
|
||||
before_debug = nil,
|
||||
},
|
||||
}
|
||||
|
||||
local function extend_contest_config(base_config, contest_config)
|
||||
|
|
@ -30,6 +36,25 @@ local function extend_contest_config(base_config, contest_config)
|
|||
end
|
||||
|
||||
function M.setup(user_config)
|
||||
vim.validate({
|
||||
user_config = { user_config, { "table", "nil" }, true },
|
||||
})
|
||||
|
||||
if user_config then
|
||||
vim.validate({
|
||||
contests = { user_config.contests, { "table", "nil" }, true },
|
||||
snippets = { user_config.snippets, { "table", "nil" }, true },
|
||||
hooks = { user_config.hooks, { "table", "nil" }, true },
|
||||
})
|
||||
|
||||
if user_config.hooks then
|
||||
vim.validate({
|
||||
before_run = { user_config.hooks.before_run, { "function", "nil" }, true },
|
||||
before_debug = { user_config.hooks.before_debug, { "function", "nil" }, true },
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local config = vim.tbl_deep_extend("force", M.defaults, user_config or {})
|
||||
|
||||
local default_contest = config.contests.default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue