feat: add highlight group for orphaned links (#502)

* feat: add highlight for orphan links

Closes #501

* feat: add OilOrphanLinkTarget highlight group

---------

Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
This commit is contained in:
Foo-x 2024-11-23 01:17:50 +09:00 committed by GitHub
parent 5fa528f552
commit 740b8fd425
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -619,9 +619,15 @@ OilSocket *hl-OilSocke
OilLink *hl-OilLink*
Soft links in an oil buffer
OilOrphanLink *hl-OilOrphanLink*
Orphaned soft links in an oil buffer
OilLinkTarget *hl-OilLinkTarget*
The target of a soft link
OilOrphanLinkTarget *hl-OilOrphanLinkTarget*
The target of an orphaned soft link
OilFile *hl-OilFile*
Normal files in an oil buffer

View file

@ -816,11 +816,21 @@ M._get_highlights = function()
link = nil,
desc = "Soft links in an oil buffer",
},
{
name = "OilOrphanLink",
link = nil,
desc = "Orphaned soft links in an oil buffer",
},
{
name = "OilLinkTarget",
link = "Comment",
desc = "The target of a soft link",
},
{
name = "OilOrphanLinkTarget",
link = "DiagnosticError",
desc = "The target of an orphaned soft link",
},
{
name = "OilFile",
link = nil,

View file

@ -728,10 +728,11 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter)
end
end
end
local is_orphan = not (meta and meta.link_stat)
table.insert(cols, { name, "OilLink" })
table.insert(cols, { name, is_orphan and "OilOrphanLink" or "OilLink" })
if link_text then
table.insert(cols, { link_text, "OilLinkTarget" })
table.insert(cols, { link_text, is_orphan and "OilOrphanLinkTarget" or "OilLinkTarget" })
end
else
table.insert(cols, { name, "OilFile" })