marleyvim/nvim/lua/lib/init.lua

22 lines
547 B
Lua

---@class lib
local M = {}
---Find the root of a project based on `vim.g.root_spec`. Defaults to
---`{ '.git' }` if unset.
---@return string?
function M.root()
local root_spec = vim.g.root_spec or { '.git' }
return vim.fs.root(0, root_spec)
end
---Require a file relative to the given prefix, to avoid repetition.
---@param prefix string The string to prefix to all req calls.
function M.local_require(prefix)
---@param mod string The module to require.
return function(mod)
return require(prefix .. '.' .. mod)
end
end
return M