Public Access
improve highlight
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
-- git highlighting for the mini.files
|
-- a module for git highlighting for the mini.files
|
||||||
-- unfortunately this is a mountain of code...
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
@@ -38,6 +36,9 @@ local function is_conflict(status)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function status_priority(status)
|
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
|
if #status < 2 then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@@ -55,20 +56,17 @@ local function status_priority(status)
|
|||||||
local index_status = status:sub(1, 1)
|
local index_status = status:sub(1, 1)
|
||||||
local worktree_status = status:sub(2, 2)
|
local worktree_status = status:sub(2, 2)
|
||||||
|
|
||||||
if index_status == "M" then
|
|
||||||
return 7
|
|
||||||
end
|
|
||||||
if index_status == "D" or worktree_status == "D" then
|
if index_status == "D" or worktree_status == "D" then
|
||||||
return 5
|
return 4
|
||||||
end
|
end
|
||||||
if index_status == "A" then
|
if index_status == "A" then
|
||||||
return 4
|
return 2
|
||||||
end
|
end
|
||||||
if index_status == "R" or index_status == "C" then
|
if index_status == "R" or index_status == "C" then
|
||||||
return 3
|
return 3
|
||||||
end
|
end
|
||||||
if worktree_status == "M" then
|
if index_status == "M" or worktree_status == "M" then
|
||||||
return 6
|
return 3
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -305,9 +303,17 @@ function M.filter(fs_entry)
|
|||||||
return fs_entry.name ~= ".git"
|
return fs_entry.name ~= ".git"
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.highlight(fs_entry)
|
local function get_entry_status(fs_entry)
|
||||||
local data = get_status_data(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)
|
return status_highlight(status)
|
||||||
or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile")
|
or (fs_entry.fs_type == "directory" and "MiniFilesDirectory" or "MiniFilesFile")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user