aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormax397574 <[email protected]>2021-12-08 14:26:07 +0100
committermax397574 <[email protected]>2021-12-08 14:26:07 +0100
commit7f3864273e7b6d8f2f1aaac6293b158149e67096 (patch)
tree10675516fb9d3ebd02cc684d1fec25eb6d98f358
parent87d1ca970849274fb1352eafab20b20d36ca5ac8 (diff)
feat(utils): add defaults in validate
-rw-r--r--lua/startup/utils.lua22
1 files changed, 8 insertions, 14 deletions
diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua
index 4e8394b..8e56a46 100644
--- a/lua/startup/utils.lua
+++ b/lua/startup/utils.lua
@@ -384,7 +384,13 @@ end
---validate the settings
---@param options table the settings for a section
function U.validate_settings(options)
- -- NOTE: vim.validate
+ if not options.oldfiles_directory then options.oldfiles_directory = false end
+ if not options.fold_section then options.fold_section = false end
+ if not options.margin then options.margin = 5 end
+ if not options.title then options.title = "" end
+ if not options.default_color then options.default_color = "" end
+ if not options.highlights then options.highlights = "" end
+ if not options.oldfiles_amount then options.oldfiles_amount = 5 end
vim.validate({
type = {
options.type,
@@ -398,10 +404,6 @@ function U.validate_settings(options)
end,
'"mapping" "text" or "oldfiles"',
},
- oldfiles_directory = {
- options.oldfiles_directory,
- "boolean",
- },
align = {
options.align,
function(arg)
@@ -414,9 +416,6 @@ function U.validate_settings(options)
end,
'"center" "left" or "right"',
},
- fold_section = { options.fold_section, "boolean" },
- title = { options.title, "string" },
- margin = { options.margin, "number" },
content = {
options.content,
function(content)
@@ -434,13 +433,8 @@ function U.validate_settings(options)
end,
"table for type=mapping and table or function for type=text",
},
- default_color = { options.default_color, "string" },
- highlight = { options.highlight, "string" },
- oldfiles_amount = {
- options.oldfiles_amount,
- "number",
- },
})
+ return options
end
return U