From 9cad30f1be7a50728be0de5432862e0ea204f3d8 Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Wed, 5 Aug 2020 23:10:30 +0200 Subject: [PATCH] Handle git deleted state. --- lua/lib/colors.lua | 2 ++ lua/lib/config.lua | 3 ++- lua/lib/renderer.lua | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/lib/colors.lua b/lua/lib/colors.lua index c68f5903..8252b7a4 100644 --- a/lua/lib/colors.lua +++ b/lua/lib/colors.lua @@ -40,6 +40,7 @@ local function get_hl_groups() ImageFile = { gui = 'bold', fg = colors.purple }, GitDirty = { fg = colors.dark_red }, + GitDeleted = { fg = colors.dark_red }, GitStaged = { fg = colors.green }, GitMerge = { fg = colors.orange }, GitRenamed = { fg = colors.purple }, @@ -60,6 +61,7 @@ local function get_links() FileRenamed = 'LuaTreeGitRenamed', FileMerge = 'LuaTreeGitMerge', FileStaged = 'LuaTreeGitStaged', + FileDeleted = 'LuaTreeGitDeleted', } end diff --git a/lua/lib/config.lua b/lua/lib/config.lua index ebc1d945..f91592a6 100644 --- a/lua/lib/config.lua +++ b/lua/lib/config.lua @@ -9,7 +9,8 @@ function M.get_icon_state() staged = "✓", unmerged = "", renamed = "➜", - untracked = "★" + untracked = "★", + deleted = "" }, folder_icons = { default = "", diff --git a/lua/lib/renderer.lua b/lua/lib/renderer.lua index 3dd82e93..26de5a24 100644 --- a/lua/lib/renderer.lua +++ b/lua/lib/renderer.lua @@ -71,6 +71,7 @@ if vim.g.lua_tree_git_hl == 1 then ["??"] = { { hl = "LuaTreeFileNew" } }, ["R "] = { { hl = "LuaTreeFileRenamed" } }, ["UU"] = { { hl = "LuaTreeFileMerge" } }, + [" D"] = { { hl = "LuaTreeFileDeleted" } }, dirty = { { hl = "LuaTreeFileDirty" } }, } get_git_hl = function(node) @@ -78,6 +79,11 @@ if vim.g.lua_tree_git_hl == 1 then if not git_status then return end local icons = git_hl[git_status] + + if icons == nil then + icons = git_hl.dirty + end + -- TODO: how would we determine hl color when multiple git status are active ? return icons[1].hl -- return icons[#icons].hl @@ -104,6 +110,7 @@ if icon_state.show_git_icon then ["??"] = { { icon = icon_state.icons.git_icons.untracked, hl = "LuaTreeGitNew" } }, ["R "] = { { icon = icon_state.icons.git_icons.renamed, hl = "LuaTreeGitRenamed" } }, ["UU"] = { { icon = icon_state.icons.git_icons.unmerged, hl = "LuaTreeGitMerge" } }, + [" D"] = { { icon = icon_state.icons.git_icons.deleted, hl = "LuaTreeGitDeleted" } }, dirty = { { icon = icon_state.icons.git_icons.unstaged, hl = "LuaTreeGitDirty" } }, } @@ -112,7 +119,7 @@ if icon_state.show_git_icon then if not git_status then return "" end local icon = "" - local icons = git_icon_state[git_status] + local icons = git_icon_state[git_status] or git_icon_state.dirty for _, v in ipairs(icons) do table.insert(hl, { v.hl, line, depth+icon_len+#icon, depth+icon_len+#icon+#v.icon }) icon = icon..v.icon.." "