From 42986ccd08ae51371ffcc23171dd5b357b04eb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Mandl=C3=ADk?= Date: Sun, 10 Nov 2024 20:32:47 +0100 Subject: [PATCH] feat(filename): add filename_map option --- README.md | 1 + doc/lualine.txt | 1 + lua/lualine/components/filename.lua | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 4c0399871..3916143f8 100644 --- a/README.md +++ b/README.md @@ -644,6 +644,7 @@ sections = { -- 2: Absolute path -- 3: Absolute path, with tilde as the home directory -- 4: Filename and parent dir, with tilde as the home directory + filename_map = nil -- Add custom transformation to displayed filename shorting_target = 40, -- Shortens path to leave 40 spaces in the window -- for other components. (terrible name, any suggestions?) diff --git a/doc/lualine.txt b/doc/lualine.txt index ccc6ebede..0efdaf939 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -671,6 +671,7 @@ Component specific options These are options that are available on -- 2: Absolute path -- 3: Absolute path, with tilde as the home directory -- 4: Filename and parent dir, with tilde as the home directory + filename_map = nil -- Add custom transformation to displayed filename shorting_target = 40, -- Shortens path to leave 40 spaces in the window -- for other components. (terrible name, any suggestions?) diff --git a/lua/lualine/components/filename.lua b/lua/lualine/components/filename.lua index 22fd964a6..d7806c0ee 100644 --- a/lua/lualine/components/filename.lua +++ b/lua/lualine/components/filename.lua @@ -17,6 +17,7 @@ local default_options = { newfile_status = false, path = 0, shorting_target = 40, + filename_map = nil } local function is_new_file() @@ -98,6 +99,9 @@ M.update_status = function(self) end data = modules.utils.stl_escape(data) + if self.options.filename_map then + data = self.options.filename_map(data) + end local symbols = {} if self.options.file_status then