chore: get git root using more advanced methods (#146)
This commit is contained in:
parent
480e35720d
commit
380a7254ae
@ -864,8 +864,8 @@ end
|
|||||||
local function get_project_root()
|
local function get_project_root()
|
||||||
local current_file = fn.expand("%:p")
|
local current_file = fn.expand("%:p")
|
||||||
local current_dir = fn.fnamemodify(current_file, ":h")
|
local current_dir = fn.fnamemodify(current_file, ":h")
|
||||||
local git_root = fn.systemlist("git -C " .. fn.shellescape(current_dir) .. " rev-parse --show-toplevel")
|
local git_root = vim.fs.root(current_file, { ".git" })
|
||||||
return (#git_root == 1 and git_root[1]) or current_dir
|
return git_root ~= nil and git_root or current_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param sidebar avante.Sidebar
|
---@param sidebar avante.Sidebar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user