Skip to content

Commit

Permalink
feat(filename): add filename_map option
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmandlik committed Nov 10, 2024
1 parent 2a5bae9 commit 42986cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down
1 change: 1 addition & 0 deletions doc/lualine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down
4 changes: 4 additions & 0 deletions lua/lualine/components/filename.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local default_options = {
newfile_status = false,
path = 0,
shorting_target = 40,
filename_map = nil
}

local function is_new_file()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 42986cc

Please sign in to comment.