fix(git): get_root should work for non file buffers

This commit is contained in:
Folke Lemaitre 2024-11-20 20:02:19 +01:00
parent 7a061de75f
commit 723d8eac84
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -17,6 +17,7 @@ function M.get_root(path)
path = path or 0
path = type(path) == "number" and vim.api.nvim_buf_get_name(path) or path --[[@as string]]
path = vim.fs.normalize(path)
path = path == "" and (vim.uv or vim.loop).cwd() or path
local git_root ---@type string?
for dir in vim.fs.parents(path) do
if vim.fn.isdirectory(dir .. "/.git") == 1 then