diff options
author | max397574 <[email protected]> | 2021-10-31 09:46:40 +0100 |
---|---|---|
committer | max397574 <[email protected]> | 2021-10-31 09:46:40 +0100 |
commit | a7de92fea82ea9dcd24af435b9b56c652fd36362 (patch) | |
tree | 191dfbed925731b7b82963346ab1371f645b9942 | |
parent | fb23b120f2f5f6b817e258171ea34c46fed7f05f (diff) |
feat(utils): ✨added validation
-rw-r--r-- | lua/startup/utils.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua index 5bb4376..b8b7a82 100644 --- a/lua/startup/utils.lua +++ b/lua/startup/utils.lua @@ -232,4 +232,56 @@ function U.set_buf_options() vim.cmd [[setlocal nonu nornu]] end +function U.validate_settings(options) + -- NOTE: vim.validate + vim.validate { + type = { + options.type, + function(arg) + for _, v in ipairs { "mapping", "oldfiles", "text" } do + if v == arg then + return true + end + end + return false + end, + '"mapping" "text" or "oldfiles"', + }, + oldfiles_directory = { + options.oldfiles_directory, + "boolean", + }, + align = { + options.align, + function(arg) + for _, v in ipairs { "right", "left", "center" } do + if v == arg then + return true + end + end + return false + end, + '"center" "left" or "right"', + }, + fold_section = { options.fold_section, "boolean" }, + title = { options.title, "string" }, + margin = { options.margin, "number" }, + command = { options.command, "string" }, + content = {options.content, + function(content) + if options.type =="text" and (type(content)== "table" or type(content == "function")) then + return true + elseif options.type == "mapping" and type(content) == "table" then + return true + end + end}, + default_color = { options.default_color, "string" }, + highlight = { options.highlight, "string" }, + oldfiles_amount = { + options.oldfiles_amount, + "number", + }, + } +end + return U |