fix(lualine): apply highlight groups correctly to truncated pretty_paths (#4379)

## 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:

<img width="320" alt="image"
src="https://github.com/user-attachments/assets/d708a140-2b23-457a-a296-dd411d29d268">

```
   nvim/…/nvim/lua/plugins/lazyvim/ui.lua
   └──┬──┘└──────────────┬──────────────┘
directory_hl        filename_hl
```

After this fix:

<img width="319" alt="image"
src="https://github.com/user-attachments/assets/e9d13fdd-79a8-4e3d-942a-58d0e2bb8bca">

```
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.
This commit is contained in:
Jamie Davies 2024-11-07 15:26:17 +00:00 committed by GitHub
parent aa53cd47c4
commit 1d4157e681
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -106,7 +106,7 @@ function M.pretty_path(opts)
if opts.length == 0 then if opts.length == 0 then
parts = parts parts = parts
elseif #parts > opts.length then 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 end
if opts.modified_hl and vim.bo.modified then if opts.modified_hl and vim.bo.modified then