mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 11:40:36 +00:00
feat(lua): add utility functions to detect Lua, OS, Python environment, TypeScript environment, Git root, and safe function invocation.
This commit is contained in:
15
lua/absolute/utils/safe-invoke.lua
Normal file
15
lua/absolute/utils/safe-invoke.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
function SafeInvoke(func)
|
||||
-- safely invoke a functions
|
||||
-- if the function returns an error, return an empty string
|
||||
-- otherwise return the result of the function
|
||||
|
||||
local ok, result = pcall(func)
|
||||
|
||||
if ok then
|
||||
return result
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
return SafeInvoke
|
||||
Reference in New Issue
Block a user