Skip to content

Commit

Permalink
feat: hidden highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored and stevearc committed Nov 22, 2024
1 parent 740b8fd commit ceba770
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
25 changes: 25 additions & 0 deletions lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ M._get_highlights = function()
link = "Directory",
desc = "Directory names in an oil buffer",
},
{
name = "OilDirHidden",
link = "Comment",
desc = "Hidden directory names in an oil buffer",
},
{
name = "OilDirIcon",
link = "OilDir",
Expand All @@ -811,6 +816,11 @@ M._get_highlights = function()
link = "Keyword",
desc = "Socket files in an oil buffer",
},
{
name = "OilSocketHidden",
link = "Comment",
desc = "Hidden socket files in an oil buffer",
},
{
name = "OilLink",
link = nil,
Expand All @@ -821,6 +831,11 @@ M._get_highlights = function()
link = nil,
desc = "Orphaned soft links in an oil buffer",
},
{
name = "OilLinkHidden",
link = "Comment",
desc = "Hidden soft links in an oil buffer",
},
{
name = "OilLinkTarget",
link = "Comment",
Expand All @@ -831,11 +846,21 @@ M._get_highlights = function()
link = "DiagnosticError",
desc = "The target of an orphaned soft link",
},
{
name = "OilLinkTargetHidden",
link = "Comment",
desc = "The target of a hidden soft link",
},
{
name = "OilFile",
link = nil,
desc = "Normal files in an oil buffer",
},
{
name = "OilFileHidden",
link = "Comment",
desc = "Hidden normal files in an oil buffer",
},
{
name = "OilCreate",
link = "DiagnosticInfo",
Expand Down
18 changes: 13 additions & 5 deletions lua/oil/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,11 @@ end
M.format_entry_cols = function(entry, column_defs, col_width, adapter)
local name = entry[FIELD_NAME]
local meta = entry[FIELD_META]
local hidden = config.view_options.is_hidden_file(name)
local hl_suffix = ""
if hidden then
hl_suffix = "Hidden"
end
if meta and meta.display_name then
name = meta.display_name
end
Expand All @@ -711,9 +716,9 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter)
-- Always add the entry name at the end
local entry_type = entry[FIELD_TYPE]
if entry_type == "directory" then
table.insert(cols, { name .. "/", "OilDir" })
table.insert(cols, { name .. "/", "OilDir" .. hl_suffix })
elseif entry_type == "socket" then
table.insert(cols, { name, "OilSocket" })
table.insert(cols, { name, "OilSocket" .. hl_suffix })
elseif entry_type == "link" then
local link_text
if meta then
Expand All @@ -730,12 +735,15 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter)
end
local is_orphan = not (meta and meta.link_stat)

table.insert(cols, { name, is_orphan and "OilOrphanLink" or "OilLink" })
table.insert(cols, { name, (is_orphan and "OilOrphanLink" or "OilLink") .. hl_suffix })
if link_text then
table.insert(cols, { link_text, is_orphan and "OilOrphanLinkTarget" or "OilLinkTarget" })
table.insert(
cols,
{ link_text, (is_orphan and "OilOrphanLinkTarget" or "OilLinkTarget") .. hl_suffix }
)
end
else
table.insert(cols, { name, "OilFile" })
table.insert(cols, { name, "OilFile" .. hl_suffix })
end
return cols
end
Expand Down

0 comments on commit ceba770

Please sign in to comment.