From 8e44ddccde80f0b10cbc44839e6cbd6e0fcb278c Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis Date: Thu, 25 Apr 2024 20:29:44 +0300 Subject: [PATCH] feat(lualine): make path trimming configurable by user --- lua/lazyvim/util/lualine.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index db4600f4..64367d66 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -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