From 9a01804f2fb6c71dba21dbefc5d7611c945ef9e0 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Sep 2026 15:20:36 +0200 Subject: [PATCH] improve highlight --- .../lua/romanzy/custom/mini_files_git.lua | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/nvim/.config/nvim/lua/romanzy/custom/mini_files_git.lua b/nvim/.config/nvim/lua/romanzy/custom/mini_files_git.lua index e47df07..93591bb 100644 --- a/nvim/.config/nvim/lua/romanzy/custom/mini_files_git.lua +++ b/nvim/.config/nvim/lua/romanzy/custom/mini_files_git.lua @@ -1,6 +1,4 @@ --- git highlighting for the mini.files --- unfortunately this is a mountain of code... - +-- a module for git highlighting for the mini.files local M = {} local uv = vim.uv or vim.loop @@ -38,6 +36,9 @@ local function is_conflict(status) end local function status_priority(status) + -- Folder aggregation follows the Zed-inspired order create < edit < + -- delete. `subtree_status()` uses the greatest priority, so deletion + -- must outrank every create or edit status. if #status < 2 then return 0 end @@ -55,20 +56,17 @@ local function status_priority(status) local index_status = status:sub(1, 1) local worktree_status = status:sub(2, 2) - if index_status == "M" then - return 7 - end if index_status == "D" or worktree_status == "D" then - return 5 + return 4 end if index_status == "A" then - return 4 + return 2 end if index_status == "R" or index_status == "C" then return 3 end - if worktree_status == "M" then - return 6 + if index_status == "M" or worktree_status == "M" then + return 3 end return 0 @@ -305,9 +303,17 @@ function M.filter(fs_entry) return fs_entry.name ~= ".git" end -function M.highlight(fs_entry) +local function get_entry_status(fs_entry) local data = get_status_data(fs_entry) - local status = data == nil and nil or lookup_status(data, fs_entry) + if data == nil then + return nil + end + + return lookup_status(data, fs_entry) +end + +function M.highlight(fs_entry) + local status = get_entry_status(fs_entry) return status_highlight(status) or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile") end