feat(get-git-root.lua): add Lua function to get the root directory of a Git project using 'git rev-parse --show-toplevel' command

This commit is contained in:
David Ibia
2024-03-03 12:02:38 +01:00
parent c8b30a453e
commit 2bace8525a

View File

@@ -0,0 +1,10 @@
function GetProjectRoot()
local git_root = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
if git_root == nil then
return vim.fn.getcwd()
else
return git_root
end
end
return GetProjectRoot