diff --git a/doc/diffview_defaults.txt b/doc/diffview_defaults.txt index 1ff1f7db..ab9b3e5a 100644 --- a/doc/diffview_defaults.txt +++ b/doc/diffview_defaults.txt @@ -14,6 +14,19 @@ DEFAULT CONFIG *diffview.defaults* folder_closed = "", folder_open = "", }, + status_icons = { + ["A"] = "A", -- added + ["?"] = "?", -- untracked + ["M"] = "M", -- modified + ["R"] = "R", -- renamed + ["C"] = "C", -- copied + ["T"] = "T", -- file type change + ["U"] = "U", -- updated but unmerged + ["X"] = "X", + ["D"] = "D", -- deleted + ["B"] = "B", + ["!"] = "!", -- untracked + }, signs = { fold_closed = "", fold_open = "", diff --git a/lua/diffview/config.lua b/lua/diffview/config.lua index f1f6d0f1..0680d181 100644 --- a/lua/diffview/config.lua +++ b/lua/diffview/config.lua @@ -48,6 +48,19 @@ M.defaults = { folder_closed = "", folder_open = "", }, + status_icons = { + ["A"] = "A", + ["?"] = "?", + ["M"] = "M", + ["R"] = "R", + ["C"] = "C", + ["T"] = "T", + ["U"] = "U", + ["X"] = "X", + ["D"] = "D", + ["B"] = "B", + ["!"] = "!", + }, signs = { fold_closed = "", fold_open = "", diff --git a/lua/diffview/hl.lua b/lua/diffview/hl.lua index 693dd358..e5aeb023 100644 --- a/lua/diffview/hl.lua +++ b/lua/diffview/hl.lua @@ -403,6 +403,13 @@ function M.get_git_hl(status) return git_status_hl_map[status] end + +--- @param status string +--- @return string +function M.get_status_icon(status) + return config._config.status_icons[status] or status +end + function M.get_colors() return { white = M.get_fg("Normal") or "White", diff --git a/lua/diffview/scene/views/diff/render.lua b/lua/diffview/scene/views/diff/render.lua index 3790a555..99006ca3 100644 --- a/lua/diffview/scene/views/diff/render.lua +++ b/lua/diffview/scene/views/diff/render.lua @@ -11,7 +11,7 @@ local function render_file(comp, show_path, depth) ---@type FileEntry local file = comp.context - comp:add_text(file.status .. " ", hl.get_git_hl(file.status)) + comp:add_text(hl.get_status_icon(file.status) .. " ", hl.get_git_hl(file.status)) if depth then comp:add_text(string.rep(" ", depth * 2 + 2)) @@ -91,7 +91,7 @@ local function render_file_tree_recurse(depth, comp) local ctx = comp.context --[[@as DirData ]] dir:add_text( - get_dir_status_text(ctx, conf.file_panel.tree_options) .. " ", + hl.get_status_icon(get_dir_status_text(ctx, conf.file_panel.tree_options)) .. " ", hl.get_git_hl(ctx.status) ) dir:add_text(string.rep(" ", depth * 2)) diff --git a/lua/diffview/scene/views/file_history/render.lua b/lua/diffview/scene/views/file_history/render.lua index 24b13970..607f982e 100644 --- a/lua/diffview/scene/views/file_history/render.lua +++ b/lua/diffview/scene/views/file_history/render.lua @@ -23,7 +23,7 @@ local function render_files(comp, files) ) else if file.status then - comp:add_text(file.status .. " ", hl.get_git_hl(file.status)) + comp:add_text(hl.get_status_icon(file.status) .. " ", hl.get_git_hl(file.status)) else comp:add_text("-" .. " ", "DiffviewNonText") end @@ -89,7 +89,7 @@ local function render_entries(panel, parent, entries, updating) end if entry.status then - comp:add_text(entry.status, hl.get_git_hl(entry.status)) + comp:add_text(hl.get_status_icon(entry.status), hl.get_git_hl(entry.status)) else comp:add_text("-", "DiffviewNonText") end