mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +00:00
fix(git): get_root should work for non file buffers
This commit is contained in:
parent
7a061de75f
commit
723d8eac84
1 changed files with 1 additions and 0 deletions
|
@ -17,6 +17,7 @@ function M.get_root(path)
|
||||||
path = path or 0
|
path = path or 0
|
||||||
path = type(path) == "number" and vim.api.nvim_buf_get_name(path) or path --[[@as string]]
|
path = type(path) == "number" and vim.api.nvim_buf_get_name(path) or path --[[@as string]]
|
||||||
path = vim.fs.normalize(path)
|
path = vim.fs.normalize(path)
|
||||||
|
path = path == "" and (vim.uv or vim.loop).cwd() or path
|
||||||
local git_root ---@type string?
|
local git_root ---@type string?
|
||||||
for dir in vim.fs.parents(path) do
|
for dir in vim.fs.parents(path) do
|
||||||
if vim.fn.isdirectory(dir .. "/.git") == 1 then
|
if vim.fn.isdirectory(dir .. "/.git") == 1 then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue