From 1d4157e68128373609385452d594b3bdf77b0fc0 Mon Sep 17 00:00:00 2001 From: Jamie Davies Date: Thu, 7 Nov 2024 15:26:17 +0000 Subject: [PATCH] fix(lualine): apply highlight groups correctly to truncated pretty_paths (#4379) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This is a small fix to the path truncating in `LazyVim.lualine.pretty_path()` to make the filename highlighting actually apply to only the filename, rather than the filename and all path elements after the inserted ellipsis (`…`). This keeps it consistent with the behaviour exhibited when the path isn't truncated, and is what I think most users would expect the behaviour to be. ## Screenshots Before this fix: image ``` nvim/…/nvim/lua/plugins/lazyvim/ui.lua └──┬──┘└──────────────┬──────────────┘ directory_hl filename_hl ``` After this fix: image ``` nvim/…/nvim/lua/plugins/lazyvim/ui.lua └──────────────┬───────────────┘└─┬──┘ directory_hl filename_hl ``` ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- 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 6284504a..4c8c28a8 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -106,7 +106,7 @@ function M.pretty_path(opts) if opts.length == 0 then parts = parts elseif #parts > opts.length then - parts = { parts[1], "…", table.concat({ unpack(parts, #parts - opts.length + 2, #parts) }, sep) } + parts = { parts[1], "…", unpack(parts, #parts - opts.length + 2, #parts) } end if opts.modified_hl and vim.bo.modified then