mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 11:40:36 +00:00
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:
10
lua/absolute/utils/get-git-root.lua
Normal file
10
lua/absolute/utils/get-git-root.lua
Normal 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
|
||||||
Reference in New Issue
Block a user