From 1810d4442283151ea0b44807a52ea9ed6e15d5ef Mon Sep 17 00:00:00 2001 From: Vladimir Shvets Date: Sat, 30 Nov 2024 02:02:41 +0700 Subject: [PATCH 1/2] fix(lualine): pretty path normalization on windows with mixed cased paths --- lua/lazyvim/util/lualine.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index b6722968..076fe766 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -101,9 +101,20 @@ function M.pretty_path(opts) local root = LazyVim.root.get({ normalize = true }) local cwd = LazyVim.root.cwd() - if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then + -- original path is preserved to provide user with expected result of pretty_path, not a normalized one, + -- which might be confusing + local norm_path = path + + if LazyVim.is_win() then + -- in case any of the provided paths involved mixed case, an additional normalization step for windows + norm_path = norm_path:lower() + root = root:lower() + cwd = cwd:lower() + end + + if opts.relative == "cwd" and norm_path:find(cwd, 1, true) == 1 then path = path:sub(#cwd + 2) - elseif path:find(root, 1, true) == 1 then + elseif norm_path:find(root, 1, true) == 1 then path = path:sub(#root + 2) end From 004fed1e520d64e67e3d504d1f399f2567c26a0a Mon Sep 17 00:00:00 2001 From: Vladimir Shvets Date: Sat, 30 Nov 2024 02:30:06 +0700 Subject: [PATCH 2/2] removed hanging space at the end of the comment --- lua/lazyvim/util/lualine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 076fe766..24143c3a 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -101,7 +101,7 @@ function M.pretty_path(opts) local root = LazyVim.root.get({ normalize = true }) local cwd = LazyVim.root.cwd() - -- original path is preserved to provide user with expected result of pretty_path, not a normalized one, + -- original path is preserved to provide user with expected result of pretty_path, not a normalized one, -- which might be confusing local norm_path = path