Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filename): add filename_map option #1326

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading