Added base setup
This commit is contained in:
41
lua/util/init.lua
Normal file
41
lua/util/init.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
local M = {}
|
||||
|
||||
function M.packer_deferred()
|
||||
vim.cmd([[do User PackerDefered]])
|
||||
end
|
||||
|
||||
function M.require(mod)
|
||||
return M.try(require, mod)
|
||||
end
|
||||
|
||||
function M.try(fn, ...)
|
||||
local args = { ... }
|
||||
|
||||
return xpcall(function()
|
||||
return fn(unpack(args))
|
||||
end, function(err)
|
||||
local lines = {}
|
||||
table.insert(lines, err)
|
||||
table.insert(lines, debug.traceback("", 3))
|
||||
|
||||
M.error(table.concat(lines, "\n"))
|
||||
return err
|
||||
end)
|
||||
end
|
||||
function M.t(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
function M.warn(msg, name)
|
||||
vim.notify(msg, vim.log.levels.WARN, { title = name or "init.lua" })
|
||||
end
|
||||
|
||||
function M.error(msg, name)
|
||||
vim.notify(msg, vim.log.levels.ERROR, { title = name or "init.lua" })
|
||||
end
|
||||
|
||||
function M.info(msg, name)
|
||||
vim.notify(msg, vim.log.levels.INFO, { title = name or "init.lua" })
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user