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 = "",
|
directory_hl = "",
|
||||||
filename_hl = "Bold",
|
filename_hl = "Bold",
|
||||||
modified_sign = "",
|
modified_sign = "",
|
||||||
|
length = 3,
|
||||||
}, opts or {})
|
}, opts or {})
|
||||||
|
|
||||||
return function(self)
|
return function(self)
|
||||||
|
@ -100,8 +101,10 @@ function M.pretty_path(opts)
|
||||||
local sep = package.config:sub(1, 1)
|
local sep = package.config:sub(1, 1)
|
||||||
local parts = vim.split(path, "[\\/]")
|
local parts = vim.split(path, "[\\/]")
|
||||||
|
|
||||||
if #parts > 3 then
|
if opts.length == 0 then
|
||||||
parts = { parts[1], "…", parts[#parts - 1], parts[#parts] }
|
parts = parts
|
||||||
|
elseif #parts > opts.length then
|
||||||
|
parts = { parts[1], "…", table.concat({ unpack(parts, #parts - opts.length + 2, #parts) }, sep) }
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.modified_hl and vim.bo.modified then
|
if opts.modified_hl and vim.bo.modified then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue