feat(explorer): different hl group for broken links

This commit is contained in:
Folke Lemaitre 2025-02-04 20:04:17 +01:00
parent a3a77a97e7
commit 1989921466
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 6 additions and 2 deletions

View file

@ -11,6 +11,7 @@ Snacks.util.set_hl({
Totals = "NonText",
File = "", -- basename of a file path
Link = "Comment",
LinkBroken = "DiagnosticError",
Directory = "Directory", -- basename of a directory path
PathIgnored = "NonText", -- any ignored file or directory
PathHidden = "NonText", -- any hidden file or directory

View file

@ -98,10 +98,13 @@ function M.filename(item, picker)
end
ret[#ret + 1] = { " " }
if item.type == "link" then
local real = uv.fs_realpath(item.file) or uv.fs_readlink(item.file)
local real = uv.fs_realpath(item.file)
local broken = not real
real = real or uv.fs_readlink(item.file)
if real then
ret[#ret + 1] = { "-> ", "SnacksPickerDelim" }
ret[#ret + 1] = { Snacks.picker.util.truncpath(real, 20), "SnacksPickerLink" }
ret[#ret + 1] =
{ Snacks.picker.util.truncpath(real, 20), broken and "SnacksPickerLinkBroken" or "SnacksPickerLink" }
ret[#ret + 1] = { " " }
end
end