feat(lualine): make path trimming configurable by user (#3062)

* feat(lualine): make path trimming configurable by user

* fix: always split both forward/backward slashes

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
Iordanis Petkakis 2024-05-03 10:16:50 +03:00 committed by GitHub
parent 6004e8d4f6
commit b8475f5194
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,6 +79,7 @@ function M.pretty_path(opts)
directory_hl = "",
filename_hl = "Bold",
modified_sign = "",
length = 3,
}, opts or {})
return function(self)
@ -100,8 +101,10 @@ function M.pretty_path(opts)
local sep = package.config:sub(1, 1)
local parts = vim.split(path, "[\\/]")
if #parts > 3 then
parts = { parts[1], "", parts[#parts - 1], parts[#parts] }
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) }
end
if opts.modified_hl and vim.bo.modified then