Public Access
improve highlight
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user