mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 19:28:24 +00:00
feat(explorer): different hl group for broken links
This commit is contained in:
parent
a3a77a97e7
commit
1989921466
2 changed files with 6 additions and 2 deletions
|
@ -11,6 +11,7 @@ Snacks.util.set_hl({
|
||||||
Totals = "NonText",
|
Totals = "NonText",
|
||||||
File = "", -- basename of a file path
|
File = "", -- basename of a file path
|
||||||
Link = "Comment",
|
Link = "Comment",
|
||||||
|
LinkBroken = "DiagnosticError",
|
||||||
Directory = "Directory", -- basename of a directory path
|
Directory = "Directory", -- basename of a directory path
|
||||||
PathIgnored = "NonText", -- any ignored file or directory
|
PathIgnored = "NonText", -- any ignored file or directory
|
||||||
PathHidden = "NonText", -- any hidden file or directory
|
PathHidden = "NonText", -- any hidden file or directory
|
||||||
|
|
|
@ -98,10 +98,13 @@ function M.filename(item, picker)
|
||||||
end
|
end
|
||||||
ret[#ret + 1] = { " " }
|
ret[#ret + 1] = { " " }
|
||||||
if item.type == "link" then
|
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
|
if real then
|
||||||
ret[#ret + 1] = { "-> ", "SnacksPickerDelim" }
|
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] = { " " }
|
ret[#ret + 1] = { " " }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue