Many things are working
This commit is contained in:
parent
c42f197307
commit
4582bd5469
20 changed files with 715 additions and 300 deletions
35
lua/util.lua
35
lua/util.lua
|
|
@ -63,6 +63,7 @@ function M.keymap(keymap)
|
|||
end
|
||||
end
|
||||
|
||||
-- spread({})({})
|
||||
function M.spread(template)
|
||||
local result = {}
|
||||
for key, value in pairs(template) do
|
||||
|
|
@ -77,6 +78,14 @@ function M.spread(template)
|
|||
end
|
||||
end
|
||||
|
||||
-- assign({}, {})
|
||||
function M.assign(obj, assign)
|
||||
for key, value in pairs(assign) do
|
||||
obj[key] = value
|
||||
end
|
||||
return obj
|
||||
end
|
||||
|
||||
function M.table_contains(table, element)
|
||||
for _, value in pairs(table) do
|
||||
if value == element then
|
||||
|
|
@ -109,4 +118,30 @@ function M.highlight(group, options)
|
|||
)
|
||||
end
|
||||
|
||||
function M.safeRequire(module, func, errorFunc)
|
||||
local ok, result = pcall(require, module)
|
||||
if ok then
|
||||
return func(result)
|
||||
elseif errorFunc then
|
||||
return errorFunc(result)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.fnFalse()
|
||||
return false
|
||||
end
|
||||
|
||||
function M.fnNil()
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.fnEmptyStr()
|
||||
return ""
|
||||
end
|
||||
|
||||
function M.fnZero()
|
||||
return 0
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue