diff options
author | HampusM <hampus@hampusmat.com> | 2022-09-18 11:39:25 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-09-18 11:39:25 +0200 |
commit | 3c238894c5b6f15c5f27cea8bd3785eb0f1ebf0f (patch) | |
tree | 68292df2b0cd698484d26057a4faf914e9ea6300 /lua/utility/git.lua | |
parent | d8fa264ac732286dcf9234bc40e60eeb7e230ca7 (diff) |
add config
Diffstat (limited to 'lua/utility/git.lua')
-rw-r--r-- | lua/utility/git.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/utility/git.lua b/lua/utility/git.lua new file mode 100644 index 0000000..b43ccc5 --- /dev/null +++ b/lua/utility/git.lua @@ -0,0 +1,29 @@ +require("utility.misc") + +function RepositoryRoot() + local current_file = GetCurrentFile() + + if current_file == "fzf" then + return "" + end + + local super_project_path = vim.fn.system("git -C " .. Dirname(current_file) + .. " rev-parse --show-superproject-working-tree") + + if vim.v.shell_error ~= 0 then + return "" + end + + if super_project_path then + return super_project_path + end + + local toplevel_path = vim.fn.system("git -C " .. Dirname(current_file) + .. " rev-parse --show-toplevel | tr -d '\n'") + + if vim.v.shell_error ~= 0 then + return "" + end + + return toplevel_path +end |