Skip to content
Open
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
13 changes: 13 additions & 0 deletions doc/diffview_defaults.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
13 changes: 13 additions & 0 deletions lua/diffview/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
7 changes: 7 additions & 0 deletions lua/diffview/hl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lua/diffview/scene/views/diff/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions lua/diffview/scene/views/file_history/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down