mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-26 10:48:45 +02:00
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:
parent
6004e8d4f6
commit
b8475f5194
1 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue