diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 1ec2cd19..3e3cdb9a 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -75,7 +75,7 @@ function M.pretty_path(opts) if path == "" then return "" end - local root = Util.root.get() + local root = Util.root.get({ normalize = true }) local cwd = Util.root.cwd() if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then @@ -111,7 +111,7 @@ function M.root_dir(opts) local function get() local cwd = Util.root.cwd() - local root = Util.root.get() + local root = Util.root.get({ normalize = true }) local name = vim.fs.basename(root) if root == cwd then diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 519546e1..a6deb240 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -141,10 +141,16 @@ end -- * lsp root_dir -- * root pattern of filename of the current buffer -- * root pattern of cwd +---@param opts {normalize?:boolean} ---@return string -function M.get() +function M.get(opts) + opts = opts or {} local roots = M.detect({ all = false }) - return roots[1] and roots[1].paths[1] or vim.loop.cwd() + local ret = roots[1] and roots[1].paths[1] or vim.loop.cwd() + if opts.normalize then + return ret + end + return Util.is_win() and ret:gsub("/", "\\") or ret end ---@param opts? {hl_last?: string}