feat(lualine): make path trimming configurable by user

This commit is contained in:
Iordanis Petkakis 2024-04-25 20:29:44 +03:00 committed by Iordanis Petkakis
parent f086bcde25
commit 8e44ddccde

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)
@ -98,10 +99,12 @@ function M.pretty_path(opts)
end
local sep = package.config:sub(1, 1)
local parts = vim.split(path, "[\\/]")
local parts = vim.split(path, sep)
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