* feat(#2415): add :NvimTreeHiTest * feat(#2415): split out appearance diagnostics
This commit is contained in:
parent
8cbb1db8e9
commit
b278fc25ae
@ -10,6 +10,7 @@ CONTENTS *nvim-tree*
|
|||||||
2.1 Quickstart: Setup |nvim-tree-quickstart-setup|
|
2.1 Quickstart: Setup |nvim-tree-quickstart-setup|
|
||||||
2.2 Quickstart: Help |nvim-tree-quickstart-help|
|
2.2 Quickstart: Help |nvim-tree-quickstart-help|
|
||||||
2.3 Quickstart: Custom Mappings |nvim-tree-quickstart-custom-mappings|
|
2.3 Quickstart: Custom Mappings |nvim-tree-quickstart-custom-mappings|
|
||||||
|
2.4 Quickstart: Highlight |nvim-tree-quickstart-highlight|
|
||||||
3. Commands |nvim-tree-commands|
|
3. Commands |nvim-tree-commands|
|
||||||
4. Setup |nvim-tree-setup|
|
4. Setup |nvim-tree-setup|
|
||||||
5. Opts |nvim-tree-opts|
|
5. Opts |nvim-tree-opts|
|
||||||
@ -43,6 +44,7 @@ CONTENTS *nvim-tree*
|
|||||||
6.7 API Marks |nvim-tree-api.marks|
|
6.7 API Marks |nvim-tree-api.marks|
|
||||||
6.8 API Config |nvim-tree-api.config|
|
6.8 API Config |nvim-tree-api.config|
|
||||||
6.9 API Commands |nvim-tree-api.commands|
|
6.9 API Commands |nvim-tree-api.commands|
|
||||||
|
6.10 API Diagnostics |nvim-tree-api.diagnostics|
|
||||||
7. Mappings |nvim-tree-mappings|
|
7. Mappings |nvim-tree-mappings|
|
||||||
7.1 Mappings: Default |nvim-tree-mappings-default|
|
7.1 Mappings: Default |nvim-tree-mappings-default|
|
||||||
8. Highlight |nvim-tree-highlight|
|
8. Highlight |nvim-tree-highlight|
|
||||||
@ -230,6 +232,16 @@ via |nvim-tree.on_attach| e.g. >
|
|||||||
---
|
---
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
==============================================================================
|
||||||
|
2.4 QUICKSTART: HIGHLIGHT *nvim-tree-quickstart-highlight*
|
||||||
|
|
||||||
|
Run |:NvimTreeHiTest| to show all the highlights that nvim-tree uses.
|
||||||
|
|
||||||
|
They can be customised before or after setup is called and will be immediately
|
||||||
|
applied at runtime.
|
||||||
|
|
||||||
|
See |nvim-tree-highlight| for details.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
3. COMMANDS *nvim-tree-commands*
|
3. COMMANDS *nvim-tree-commands*
|
||||||
|
|
||||||
@ -324,6 +336,14 @@ via |nvim-tree.on_attach| e.g. >
|
|||||||
|
|
||||||
Calls: `api.tree.collapse_all(true)`
|
Calls: `api.tree.collapse_all(true)`
|
||||||
|
|
||||||
|
*:NvimTreeHiTest*
|
||||||
|
|
||||||
|
Show nvim-tree highlight groups similar to `:so $VIMRUNTIME/syntax/hitest.vim`
|
||||||
|
|
||||||
|
See |nvim-tree-api.diagnostics.hi_test()|
|
||||||
|
|
||||||
|
Calls: `api.diagnostics.hi_test()`
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. SETUP *nvim-tree-setup*
|
4. SETUP *nvim-tree-setup*
|
||||||
|
|
||||||
@ -2077,7 +2097,7 @@ config.mappings.get_keymap_default()
|
|||||||
(table) as per |nvim_buf_get_keymap()|
|
(table) as per |nvim_buf_get_keymap()|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6.8 API COMMANDS *nvim-tree-api.commands*
|
6.9 API COMMANDS *nvim-tree-api.commands*
|
||||||
|
|
||||||
commands.get() *nvim-tree-api.commands.get()*
|
commands.get() *nvim-tree-api.commands.get()*
|
||||||
Retrieve all commands, see |nvim-tree-commands|
|
Retrieve all commands, see |nvim-tree-commands|
|
||||||
@ -2088,6 +2108,15 @@ commands.get() *nvim-tree-api.commands.get()*
|
|||||||
• {command} (function)
|
• {command} (function)
|
||||||
• {opts} (table)
|
• {opts} (table)
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
6.10 DIAGNOSTICS *nvim-tree-api.diagnostics*
|
||||||
|
|
||||||
|
diagnostics.hi_test() *nvim-tree-api.diagnostics.hi_test()*
|
||||||
|
Open a new buffer displaying all nvim-tree highlight groups, their link
|
||||||
|
chain and concrete definition.
|
||||||
|
|
||||||
|
Similar to `:so $VIMRUNTIME/syntax/hitest.vim` as per |:highlight|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. MAPPINGS *nvim-tree-mappings*
|
7. MAPPINGS *nvim-tree-mappings*
|
||||||
|
|
||||||
@ -2253,7 +2282,9 @@ Example |:highlight| >
|
|||||||
It is recommended to enable 'termguicolors' for the more pleasant 24-bit
|
It is recommended to enable 'termguicolors' for the more pleasant 24-bit
|
||||||
colours.
|
colours.
|
||||||
|
|
||||||
To view the active highlight groups run `:so $VIMRUNTIME/syntax/hitest.vim`
|
To view the nvim-tree highlight groups run |:NvimTreeHiTest|
|
||||||
|
|
||||||
|
To view all active highlight groups run `:so $VIMRUNTIME/syntax/hitest.vim`
|
||||||
as per |:highlight|
|
as per |:highlight|
|
||||||
|
|
||||||
The `*HL` groups are additive as per |nvim-tree-opts-renderer| precedence.
|
The `*HL` groups are additive as per |nvim-tree-opts-renderer| precedence.
|
||||||
|
|||||||
@ -2,6 +2,7 @@ local lib = require "nvim-tree.lib"
|
|||||||
local view = require "nvim-tree.view"
|
local view = require "nvim-tree.view"
|
||||||
local utils = require "nvim-tree.utils"
|
local utils = require "nvim-tree.utils"
|
||||||
local actions = require "nvim-tree.actions"
|
local actions = require "nvim-tree.actions"
|
||||||
|
local appearance_diagnostics = require "nvim-tree.appearance.diagnostics"
|
||||||
local events = require "nvim-tree.events"
|
local events = require "nvim-tree.events"
|
||||||
local help = require "nvim-tree.help"
|
local help = require "nvim-tree.help"
|
||||||
local live_filter = require "nvim-tree.live-filter"
|
local live_filter = require "nvim-tree.live-filter"
|
||||||
@ -39,6 +40,7 @@ local Api = {
|
|||||||
mappings = {},
|
mappings = {},
|
||||||
},
|
},
|
||||||
commands = {},
|
commands = {},
|
||||||
|
diagnostics = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Do nothing when setup not called.
|
--- Do nothing when setup not called.
|
||||||
@ -245,6 +247,8 @@ Api.config.mappings.get_keymap = wrap(keymap.get_keymap)
|
|||||||
Api.config.mappings.get_keymap_default = wrap(keymap.get_keymap_default)
|
Api.config.mappings.get_keymap_default = wrap(keymap.get_keymap_default)
|
||||||
Api.config.mappings.default_on_attach = keymap.default_on_attach
|
Api.config.mappings.default_on_attach = keymap.default_on_attach
|
||||||
|
|
||||||
|
Api.diagnostics.hi_test = wrap(appearance_diagnostics.hi_test)
|
||||||
|
|
||||||
Api.commands.get = wrap(function()
|
Api.commands.get = wrap(function()
|
||||||
return require("nvim-tree.commands").get()
|
return require("nvim-tree.commands").get()
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -1,199 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
-- directly defined groups, please keep these to an absolute minimum
|
|
||||||
local DEFAULT_DEFS = {
|
|
||||||
|
|
||||||
NvimTreeFolderIcon = "guifg=#8094b4 ctermfg=Blue",
|
|
||||||
NvimTreeWindowPicker = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=Cyan",
|
|
||||||
}
|
|
||||||
|
|
||||||
-- nvim-tree default highlight group links, please attempt to keep in order with help
|
|
||||||
local DEFAULT_LINKS = {
|
|
||||||
|
|
||||||
-- Standard
|
|
||||||
NvimTreeNormal = "Normal",
|
|
||||||
NvimTreeNormalFloat = "NormalFloat",
|
|
||||||
NvimTreeNormalNC = "NvimTreeNormal",
|
|
||||||
|
|
||||||
NvimTreeLineNr = "LineNr",
|
|
||||||
NvimTreeWinSeparator = "WinSeparator",
|
|
||||||
NvimTreeEndOfBuffer = "EndOfBuffer",
|
|
||||||
NvimTreePopup = "Normal",
|
|
||||||
NvimTreeSignColumn = "NvimTreeNormal",
|
|
||||||
|
|
||||||
NvimTreeCursorColumn = "CursorColumn",
|
|
||||||
NvimTreeCursorLine = "CursorLine",
|
|
||||||
NvimTreeCursorLineNr = "CursorLineNr",
|
|
||||||
|
|
||||||
NvimTreeStatusLine = "StatusLine",
|
|
||||||
NvimTreeStatusLineNC = "StatusLineNC",
|
|
||||||
|
|
||||||
-- File Text
|
|
||||||
NvimTreeExecFile = "SpellCap",
|
|
||||||
NvimTreeImageFile = "SpellCap",
|
|
||||||
NvimTreeSpecialFile = "SpellCap",
|
|
||||||
NvimTreeSymlink = "SpellCap",
|
|
||||||
|
|
||||||
-- Folder Text
|
|
||||||
NvimTreeRootFolder = "Title",
|
|
||||||
NvimTreeFolderName = "Directory",
|
|
||||||
NvimTreeEmptyFolderName = "Directory",
|
|
||||||
NvimTreeOpenedFolderName = "Directory",
|
|
||||||
NvimTreeSymlinkFolderName = "Directory",
|
|
||||||
|
|
||||||
-- File Icons
|
|
||||||
NvimTreeFileIcon = "NvimTreeNormal",
|
|
||||||
NvimTreeSymlinkIcon = "NvimTreeNormal",
|
|
||||||
|
|
||||||
-- Folder Icons
|
|
||||||
NvimTreeOpenedFolderIcon = "NvimTreeFolderIcon",
|
|
||||||
NvimTreeClosedFolderIcon = "NvimTreeFolderIcon",
|
|
||||||
NvimTreeFolderArrowClosed = "NvimTreeIndentMarker",
|
|
||||||
NvimTreeFolderArrowOpen = "NvimTreeIndentMarker",
|
|
||||||
|
|
||||||
-- Indent
|
|
||||||
NvimTreeIndentMarker = "NvimTreeFolderIcon",
|
|
||||||
|
|
||||||
-- LiveFilter
|
|
||||||
NvimTreeLiveFilterPrefix = "PreProc",
|
|
||||||
NvimTreeLiveFilterValue = "ModeMsg",
|
|
||||||
|
|
||||||
-- Clipboard
|
|
||||||
NvimTreeCutHL = "SpellBad",
|
|
||||||
NvimTreeCopiedHL = "SpellRare",
|
|
||||||
|
|
||||||
-- Bookmark
|
|
||||||
NvimTreeBookmarkIcon = "NvimTreeFolderIcon",
|
|
||||||
NvimTreeBookmarkHL = "SpellLocal",
|
|
||||||
|
|
||||||
-- Modified
|
|
||||||
NvimTreeModifiedIcon = "Type",
|
|
||||||
NvimTreeModifiedFileHL = "NvimTreeModifiedIcon",
|
|
||||||
NvimTreeModifiedFolderHL = "NvimTreeModifiedFileHL",
|
|
||||||
|
|
||||||
-- Opened
|
|
||||||
NvimTreeOpenedHL = "Special",
|
|
||||||
|
|
||||||
-- Git Icon
|
|
||||||
NvimTreeGitDeletedIcon = "Statement",
|
|
||||||
NvimTreeGitDirtyIcon = "Statement",
|
|
||||||
NvimTreeGitIgnoredIcon = "Comment",
|
|
||||||
NvimTreeGitMergeIcon = "Constant",
|
|
||||||
NvimTreeGitNewIcon = "PreProc",
|
|
||||||
NvimTreeGitRenamedIcon = "PreProc",
|
|
||||||
NvimTreeGitStagedIcon = "Constant",
|
|
||||||
|
|
||||||
-- Git File Highlight
|
|
||||||
NvimTreeGitFileDeletedHL = "NvimTreeGitDeletedIcon",
|
|
||||||
NvimTreeGitFileDirtyHL = "NvimTreeGitDirtyIcon",
|
|
||||||
NvimTreeGitFileIgnoredHL = "NvimTreeGitIgnoredIcon",
|
|
||||||
NvimTreeGitFileMergeHL = "NvimTreeGitMergeIcon",
|
|
||||||
NvimTreeGitFileNewHL = "NvimTreeGitNewIcon",
|
|
||||||
NvimTreeGitFileRenamedHL = "NvimTreeGitRenamedIcon",
|
|
||||||
NvimTreeGitFileStagedHL = "NvimTreeGitStagedIcon",
|
|
||||||
|
|
||||||
-- Git Folder Highlight
|
|
||||||
NvimTreeGitFolderDeletedHL = "NvimTreeGitFileDeletedHL",
|
|
||||||
NvimTreeGitFolderDirtyHL = "NvimTreeGitFileDirtyHL",
|
|
||||||
NvimTreeGitFolderIgnoredHL = "NvimTreeGitFileIgnoredHL",
|
|
||||||
NvimTreeGitFolderMergeHL = "NvimTreeGitFileMergeHL",
|
|
||||||
NvimTreeGitFolderNewHL = "NvimTreeGitFileNewHL",
|
|
||||||
NvimTreeGitFolderRenamedHL = "NvimTreeGitFileRenamedHL",
|
|
||||||
NvimTreeGitFolderStagedHL = "NvimTreeGitFileStagedHL",
|
|
||||||
|
|
||||||
-- Diagnostics Icon
|
|
||||||
NvimTreeDiagnosticErrorIcon = "DiagnosticError",
|
|
||||||
NvimTreeDiagnosticWarnIcon = "DiagnosticWarn",
|
|
||||||
NvimTreeDiagnosticInfoIcon = "DiagnosticInfo",
|
|
||||||
NvimTreeDiagnosticHintIcon = "DiagnosticHint",
|
|
||||||
|
|
||||||
-- Diagnostics File Highlight
|
|
||||||
NvimTreeDiagnosticErrorFileHL = "DiagnosticUnderlineError",
|
|
||||||
NvimTreeDiagnosticWarnFileHL = "DiagnosticUnderlineWarn",
|
|
||||||
NvimTreeDiagnosticInfoFileHL = "DiagnosticUnderlineInfo",
|
|
||||||
NvimTreeDiagnosticHintFileHL = "DiagnosticUnderlineHint",
|
|
||||||
|
|
||||||
-- Diagnostics Folder Highlight
|
|
||||||
NvimTreeDiagnosticErrorFolderHL = "NvimTreeDiagnosticErrorFileHL",
|
|
||||||
NvimTreeDiagnosticWarnFolderHL = "NvimTreeDiagnosticWarnFileHL",
|
|
||||||
NvimTreeDiagnosticInfoFolderHL = "NvimTreeDiagnosticInfoFileHL",
|
|
||||||
NvimTreeDiagnosticHintFolderHL = "NvimTreeDiagnosticHintFileHL",
|
|
||||||
}
|
|
||||||
|
|
||||||
-- nvim-tree highlight groups to legacy
|
|
||||||
local LEGACY_LINKS = {
|
|
||||||
NvimTreeModifiedIcon = "NvimTreeModifiedFile",
|
|
||||||
|
|
||||||
NvimTreeOpenedHL = "NvimTreeOpenedFile",
|
|
||||||
|
|
||||||
NvimTreeBookmarkIcon = "NvimTreeBookmark",
|
|
||||||
|
|
||||||
NvimTreeGitDeletedIcon = "NvimTreeGitDeleted",
|
|
||||||
NvimTreeGitDirtyIcon = "NvimTreeGitDirty",
|
|
||||||
NvimTreeGitIgnoredIcon = "NvimTreeGitIgnored",
|
|
||||||
NvimTreeGitMergeIcon = "NvimTreeGitMerge",
|
|
||||||
NvimTreeGitNewIcon = "NvimTreeGitNew",
|
|
||||||
NvimTreeGitRenamedIcon = "NvimTreeGitRenamed",
|
|
||||||
NvimTreeGitStagedIcon = "NvimTreeGitStaged",
|
|
||||||
|
|
||||||
NvimTreeGitFileDeletedHL = "NvimTreeFileDeleted",
|
|
||||||
NvimTreeGitFileDirtyHL = "NvimTreeFileDirty",
|
|
||||||
NvimTreeGitFileIgnoredHL = "NvimTreeFileIgnored",
|
|
||||||
NvimTreeGitFileMergeHL = "NvimTreeFileMerge",
|
|
||||||
NvimTreeGitFileNewHL = "NvimTreeFileNew",
|
|
||||||
NvimTreeGitFileRenamedHL = "NvimTreeFileRenamed",
|
|
||||||
NvimTreeGitFileStagedHL = "NvimTreeFileStaged",
|
|
||||||
|
|
||||||
NvimTreeGitFolderDeletedHL = "NvimTreeFolderDeleted",
|
|
||||||
NvimTreeGitFolderDirtyHL = "NvimTreeFolderDirty",
|
|
||||||
NvimTreeGitFolderIgnoredHL = "NvimTreeFolderIgnored",
|
|
||||||
NvimTreeGitFolderMergeHL = "NvimTreeFolderMerge",
|
|
||||||
NvimTreeGitFolderNewHL = "NvimTreeFolderNew",
|
|
||||||
NvimTreeGitFolderRenamedHL = "NvimTreeFolderRenamed",
|
|
||||||
NvimTreeGitFolderStagedHL = "NvimTreeFolderStaged",
|
|
||||||
|
|
||||||
NvimTreeDiagnosticErrorIcon = "NvimTreeLspDiagnosticsError",
|
|
||||||
NvimTreeDiagnosticWarnIcon = "NvimTreeLspDiagnosticsWarning",
|
|
||||||
NvimTreeDiagnosticInfoIcon = "NvimTreeLspDiagnosticsInformation",
|
|
||||||
NvimTreeDiagnosticHintIcon = "NvimTreeLspDiagnosticsHint",
|
|
||||||
|
|
||||||
NvimTreeDiagnosticErrorFileHL = "NvimTreeLspDiagnosticsErrorText",
|
|
||||||
NvimTreeDiagnosticWarnFileHL = "NvimTreeLspDiagnosticsWarningText",
|
|
||||||
NvimTreeDiagnosticInfoFileHL = "NvimTreeLspDiagnosticsInformationText",
|
|
||||||
NvimTreeDiagnosticHintFileHL = "NvimTreeLspDiagnosticsHintText",
|
|
||||||
|
|
||||||
NvimTreeDiagnosticErrorFolderHL = "NvimTreeLspDiagnosticsErrorFolderText",
|
|
||||||
NvimTreeDiagnosticWarnFolderHL = "NvimTreeLspDiagnosticsWarningFolderText",
|
|
||||||
NvimTreeDiagnosticInfoFolderHL = "NvimTreeLspDiagnosticsInformationFolderText",
|
|
||||||
NvimTreeDiagnosticHintFolderHL = "NvimTreeLspDiagnosticsHintFolderText",
|
|
||||||
}
|
|
||||||
|
|
||||||
function M.setup()
|
|
||||||
-- non-linked
|
|
||||||
for k, d in pairs(DEFAULT_DEFS) do
|
|
||||||
vim.api.nvim_command("hi def " .. k .. " " .. d)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- hard link override when legacy only is present
|
|
||||||
for from, to in pairs(LEGACY_LINKS) do
|
|
||||||
local hl_from
|
|
||||||
local hl_to
|
|
||||||
if vim.fn.has "nvim-0.9" == 1 then
|
|
||||||
hl_from = vim.api.nvim_get_hl(0, { name = from })
|
|
||||||
hl_to = vim.api.nvim_get_hl(0, { name = to })
|
|
||||||
else
|
|
||||||
hl_from = vim.api.nvim__get_hl_defs(0)[from] or {}
|
|
||||||
hl_to = vim.api.nvim__get_hl_defs(0)[to] or {}
|
|
||||||
end
|
|
||||||
if vim.tbl_isempty(hl_from) and not vim.tbl_isempty(hl_to) then
|
|
||||||
vim.api.nvim_command("hi link " .. from .. " " .. to)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- default links
|
|
||||||
for from, to in pairs(DEFAULT_LINKS) do
|
|
||||||
vim.api.nvim_command("hi def link " .. from .. " " .. to)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
80
lua/nvim-tree/appearance/diagnostics.lua
Normal file
80
lua/nvim-tree/appearance/diagnostics.lua
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
local appearance = require "nvim-tree.appearance"
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@class HighlightDisplay for :NvimTreeHiTest
|
||||||
|
---@field group string nvim-tree highlight group name
|
||||||
|
---@field links string link chain to a concretely defined group
|
||||||
|
---@field def string :hi concrete definition after following any links
|
||||||
|
local HighlightDisplay = {}
|
||||||
|
|
||||||
|
---@param group string nvim-tree highlight group
|
||||||
|
---@return HighlightDisplay
|
||||||
|
function HighlightDisplay:new(group)
|
||||||
|
local o = {}
|
||||||
|
setmetatable(o, self)
|
||||||
|
self.__index = self
|
||||||
|
|
||||||
|
o.group = group
|
||||||
|
local concrete = o.group
|
||||||
|
|
||||||
|
-- maybe follow links
|
||||||
|
local links = {}
|
||||||
|
local link = vim.api.nvim_get_hl(0, { name = o.group }).link
|
||||||
|
while link do
|
||||||
|
table.insert(links, link)
|
||||||
|
concrete = link
|
||||||
|
link = vim.api.nvim_get_hl(0, { name = link }).link
|
||||||
|
end
|
||||||
|
o.links = table.concat(links, " ")
|
||||||
|
|
||||||
|
-- concrete definition
|
||||||
|
local ok, res = pcall(vim.api.nvim_cmd, { cmd = "highlight", args = { concrete } }, { output = true })
|
||||||
|
if ok and type(res) == "string" then
|
||||||
|
o.def = res:gsub(".*xxx *", "")
|
||||||
|
else
|
||||||
|
o.def = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
||||||
|
function HighlightDisplay:render(bufnr, fmt, l)
|
||||||
|
local text = string.format(fmt, self.group, self.links, self.def)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, l, -1, true, { text })
|
||||||
|
vim.api.nvim_buf_add_highlight(bufnr, -1, self.group, l, 0, #self.group)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Run a test similar to :so $VIMRUNTIME/syntax/hitest.vim
|
||||||
|
---Display all nvim-tree highlight groups, their link chain and actual definition
|
||||||
|
function M.hi_test()
|
||||||
|
local displays = {}
|
||||||
|
local max_group_len = 0
|
||||||
|
local max_links_len = 0
|
||||||
|
|
||||||
|
-- build all highlight groups, name only
|
||||||
|
for _, highlight_group in ipairs(appearance.HIGHLIGHT_GROUPS) do
|
||||||
|
local display = HighlightDisplay:new(highlight_group.group)
|
||||||
|
table.insert(displays, display)
|
||||||
|
max_group_len = math.max(max_group_len, #display.group)
|
||||||
|
max_links_len = math.max(max_links_len, #display.links)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- create a buffer
|
||||||
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
|
|
||||||
|
-- render and highlight
|
||||||
|
local l = 0
|
||||||
|
local fmt = string.format("%%-%d.%ds %%-%d.%ds %%s", max_group_len, max_group_len, max_links_len, max_links_len)
|
||||||
|
for _, display in ipairs(displays) do
|
||||||
|
display:render(bufnr, fmt, l)
|
||||||
|
l = l + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- finalise and focus the buffer
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
|
||||||
|
vim.cmd.buffer(bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
202
lua/nvim-tree/appearance/init.lua
Normal file
202
lua/nvim-tree/appearance/init.lua
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- All highlight groups: linked or directly defined.
|
||||||
|
-- Please add new groups to help and preserve order.
|
||||||
|
-- Please avoid directly defined groups to preserve accessibility for TUI.
|
||||||
|
M.HIGHLIGHT_GROUPS = {
|
||||||
|
|
||||||
|
-- Standard
|
||||||
|
{ group = "NvimTreeNormal", link = "Normal" },
|
||||||
|
{ group = "NvimTreeNormalFloat", link = "NormalFloat" },
|
||||||
|
{ group = "NvimTreeNormalNC", link = "NvimTreeNormal" },
|
||||||
|
|
||||||
|
{ group = "NvimTreeLineNr", link = "LineNr" },
|
||||||
|
{ group = "NvimTreeWinSeparator", link = "WinSeparator" },
|
||||||
|
{ group = "NvimTreeEndOfBuffer", link = "EndOfBuffer" },
|
||||||
|
{ group = "NvimTreePopup", link = "Normal" },
|
||||||
|
{ group = "NvimTreeSignColumn", link = "NvimTreeNormal" },
|
||||||
|
|
||||||
|
{ group = "NvimTreeCursorColumn", link = "CursorColumn" },
|
||||||
|
{ group = "NvimTreeCursorLine", link = "CursorLine" },
|
||||||
|
{ group = "NvimTreeCursorLineNr", link = "CursorLineNr" },
|
||||||
|
|
||||||
|
{ group = "NvimTreeStatusLine", link = "StatusLine" },
|
||||||
|
{ group = "NvimTreeStatusLineNC", link = "StatusLineNC" },
|
||||||
|
|
||||||
|
-- File Text
|
||||||
|
{ group = "NvimTreeExecFile", link = "SpellCap" },
|
||||||
|
{ group = "NvimTreeImageFile", link = "SpellCap" },
|
||||||
|
{ group = "NvimTreeSpecialFile", link = "SpellCap" },
|
||||||
|
{ group = "NvimTreeSymlink", link = "SpellCap" },
|
||||||
|
|
||||||
|
-- Folder Text
|
||||||
|
{ group = "NvimTreeRootFolder", link = "Title" },
|
||||||
|
{ group = "NvimTreeFolderName", link = "Directory" },
|
||||||
|
{ group = "NvimTreeEmptyFolderName", link = "Directory" },
|
||||||
|
{ group = "NvimTreeOpenedFolderName", link = "Directory" },
|
||||||
|
{ group = "NvimTreeSymlinkFolderName", link = "Directory" },
|
||||||
|
|
||||||
|
-- File Icons
|
||||||
|
{ group = "NvimTreeFileIcon", link = "NvimTreeNormal" },
|
||||||
|
{ group = "NvimTreeSymlinkIcon", link = "NvimTreeNormal" },
|
||||||
|
|
||||||
|
-- Folder Icons
|
||||||
|
{ group = "NvimTreeFolderIcon", def = "guifg=#8094b4 ctermfg=Blue" },
|
||||||
|
{ group = "NvimTreeOpenedFolderIcon", link = "NvimTreeFolderIcon" },
|
||||||
|
{ group = "NvimTreeClosedFolderIcon", link = "NvimTreeFolderIcon" },
|
||||||
|
{ group = "NvimTreeFolderArrowClosed", link = "NvimTreeIndentMarker" },
|
||||||
|
{ group = "NvimTreeFolderArrowOpen", link = "NvimTreeIndentMarker" },
|
||||||
|
|
||||||
|
-- Indent
|
||||||
|
{ group = "NvimTreeIndentMarker", link = "NvimTreeFolderIcon" },
|
||||||
|
|
||||||
|
-- Picker
|
||||||
|
{ group = "NvimTreeWindowPicker", def = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=Cyan" },
|
||||||
|
|
||||||
|
-- LiveFilter
|
||||||
|
{ group = "NvimTreeLiveFilterPrefix", link = "PreProc" },
|
||||||
|
{ group = "NvimTreeLiveFilterValue", link = "ModeMsg" },
|
||||||
|
|
||||||
|
-- Clipboard
|
||||||
|
{ group = "NvimTreeCutHL", link = "SpellBad" },
|
||||||
|
{ group = "NvimTreeCopiedHL", link = "SpellRare" },
|
||||||
|
|
||||||
|
-- Bookmark
|
||||||
|
{ group = "NvimTreeBookmarkIcon", link = "NvimTreeFolderIcon" },
|
||||||
|
{ group = "NvimTreeBookmarkHL", link = "SpellLocal" },
|
||||||
|
|
||||||
|
-- Modified
|
||||||
|
{ group = "NvimTreeModifiedIcon", link = "Type" },
|
||||||
|
{ group = "NvimTreeModifiedFileHL", link = "NvimTreeModifiedIcon" },
|
||||||
|
{ group = "NvimTreeModifiedFolderHL", link = "NvimTreeModifiedFileHL" },
|
||||||
|
|
||||||
|
-- Opened
|
||||||
|
{ group = "NvimTreeOpenedHL", link = "Special" },
|
||||||
|
|
||||||
|
-- Git Icon
|
||||||
|
{ group = "NvimTreeGitDeletedIcon", link = "Statement" },
|
||||||
|
{ group = "NvimTreeGitDirtyIcon", link = "Statement" },
|
||||||
|
{ group = "NvimTreeGitIgnoredIcon", link = "Comment" },
|
||||||
|
{ group = "NvimTreeGitMergeIcon", link = "Constant" },
|
||||||
|
{ group = "NvimTreeGitNewIcon", link = "PreProc" },
|
||||||
|
{ group = "NvimTreeGitRenamedIcon", link = "PreProc" },
|
||||||
|
{ group = "NvimTreeGitStagedIcon", link = "Constant" },
|
||||||
|
|
||||||
|
-- Git File Highlight
|
||||||
|
{ group = "NvimTreeGitFileDeletedHL", link = "NvimTreeGitDeletedIcon" },
|
||||||
|
{ group = "NvimTreeGitFileDirtyHL", link = "NvimTreeGitDirtyIcon" },
|
||||||
|
{ group = "NvimTreeGitFileIgnoredHL", link = "NvimTreeGitIgnoredIcon" },
|
||||||
|
{ group = "NvimTreeGitFileMergeHL", link = "NvimTreeGitMergeIcon" },
|
||||||
|
{ group = "NvimTreeGitFileNewHL", link = "NvimTreeGitNewIcon" },
|
||||||
|
{ group = "NvimTreeGitFileRenamedHL", link = "NvimTreeGitRenamedIcon" },
|
||||||
|
{ group = "NvimTreeGitFileStagedHL", link = "NvimTreeGitStagedIcon" },
|
||||||
|
|
||||||
|
-- Git Folder Highlight
|
||||||
|
{ group = "NvimTreeGitFolderDeletedHL", link = "NvimTreeGitFileDeletedHL" },
|
||||||
|
{ group = "NvimTreeGitFolderDirtyHL", link = "NvimTreeGitFileDirtyHL" },
|
||||||
|
{ group = "NvimTreeGitFolderIgnoredHL", link = "NvimTreeGitFileIgnoredHL" },
|
||||||
|
{ group = "NvimTreeGitFolderMergeHL", link = "NvimTreeGitFileMergeHL" },
|
||||||
|
{ group = "NvimTreeGitFolderNewHL", link = "NvimTreeGitFileNewHL" },
|
||||||
|
{ group = "NvimTreeGitFolderRenamedHL", link = "NvimTreeGitFileRenamedHL" },
|
||||||
|
{ group = "NvimTreeGitFolderStagedHL", link = "NvimTreeGitFileStagedHL" },
|
||||||
|
|
||||||
|
-- Diagnostics Icon
|
||||||
|
{ group = "NvimTreeDiagnosticErrorIcon", link = "DiagnosticError" },
|
||||||
|
{ group = "NvimTreeDiagnosticWarnIcon", link = "DiagnosticWarn" },
|
||||||
|
{ group = "NvimTreeDiagnosticInfoIcon", link = "DiagnosticInfo" },
|
||||||
|
{ group = "NvimTreeDiagnosticHintIcon", link = "DiagnosticHint" },
|
||||||
|
|
||||||
|
-- Diagnostics File Highlight
|
||||||
|
{ group = "NvimTreeDiagnosticErrorFileHL", link = "DiagnosticUnderlineError" },
|
||||||
|
{ group = "NvimTreeDiagnosticWarnFileHL", link = "DiagnosticUnderlineWarn" },
|
||||||
|
{ group = "NvimTreeDiagnosticInfoFileHL", link = "DiagnosticUnderlineInfo" },
|
||||||
|
{ group = "NvimTreeDiagnosticHintFileHL", link = "DiagnosticUnderlineHint" },
|
||||||
|
|
||||||
|
-- Diagnostics Folder Highlight
|
||||||
|
{ group = "NvimTreeDiagnosticErrorFolderHL", link = "NvimTreeDiagnosticErrorFileHL" },
|
||||||
|
{ group = "NvimTreeDiagnosticWarnFolderHL", link = "NvimTreeDiagnosticWarnFileHL" },
|
||||||
|
{ group = "NvimTreeDiagnosticInfoFolderHL", link = "NvimTreeDiagnosticInfoFileHL" },
|
||||||
|
{ group = "NvimTreeDiagnosticHintFolderHL", link = "NvimTreeDiagnosticHintFileHL" },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- nvim-tree highlight groups to legacy
|
||||||
|
M.LEGACY_LINKS = {
|
||||||
|
NvimTreeModifiedIcon = "NvimTreeModifiedFile",
|
||||||
|
|
||||||
|
NvimTreeOpenedHL = "NvimTreeOpenedFile",
|
||||||
|
|
||||||
|
NvimTreeBookmarkIcon = "NvimTreeBookmark",
|
||||||
|
|
||||||
|
NvimTreeGitDeletedIcon = "NvimTreeGitDeleted",
|
||||||
|
NvimTreeGitDirtyIcon = "NvimTreeGitDirty",
|
||||||
|
NvimTreeGitIgnoredIcon = "NvimTreeGitIgnored",
|
||||||
|
NvimTreeGitMergeIcon = "NvimTreeGitMerge",
|
||||||
|
NvimTreeGitNewIcon = "NvimTreeGitNew",
|
||||||
|
NvimTreeGitRenamedIcon = "NvimTreeGitRenamed",
|
||||||
|
NvimTreeGitStagedIcon = "NvimTreeGitStaged",
|
||||||
|
|
||||||
|
NvimTreeGitFileDeletedHL = "NvimTreeFileDeleted",
|
||||||
|
NvimTreeGitFileDirtyHL = "NvimTreeFileDirty",
|
||||||
|
NvimTreeGitFileIgnoredHL = "NvimTreeFileIgnored",
|
||||||
|
NvimTreeGitFileMergeHL = "NvimTreeFileMerge",
|
||||||
|
NvimTreeGitFileNewHL = "NvimTreeFileNew",
|
||||||
|
NvimTreeGitFileRenamedHL = "NvimTreeFileRenamed",
|
||||||
|
NvimTreeGitFileStagedHL = "NvimTreeFileStaged",
|
||||||
|
|
||||||
|
NvimTreeGitFolderDeletedHL = "NvimTreeFolderDeleted",
|
||||||
|
NvimTreeGitFolderDirtyHL = "NvimTreeFolderDirty",
|
||||||
|
NvimTreeGitFolderIgnoredHL = "NvimTreeFolderIgnored",
|
||||||
|
NvimTreeGitFolderMergeHL = "NvimTreeFolderMerge",
|
||||||
|
NvimTreeGitFolderNewHL = "NvimTreeFolderNew",
|
||||||
|
NvimTreeGitFolderRenamedHL = "NvimTreeFolderRenamed",
|
||||||
|
NvimTreeGitFolderStagedHL = "NvimTreeFolderStaged",
|
||||||
|
|
||||||
|
NvimTreeDiagnosticErrorIcon = "NvimTreeLspDiagnosticsError",
|
||||||
|
NvimTreeDiagnosticWarnIcon = "NvimTreeLspDiagnosticsWarning",
|
||||||
|
NvimTreeDiagnosticInfoIcon = "NvimTreeLspDiagnosticsInformation",
|
||||||
|
NvimTreeDiagnosticHintIcon = "NvimTreeLspDiagnosticsHint",
|
||||||
|
|
||||||
|
NvimTreeDiagnosticErrorFileHL = "NvimTreeLspDiagnosticsErrorText",
|
||||||
|
NvimTreeDiagnosticWarnFileHL = "NvimTreeLspDiagnosticsWarningText",
|
||||||
|
NvimTreeDiagnosticInfoFileHL = "NvimTreeLspDiagnosticsInformationText",
|
||||||
|
NvimTreeDiagnosticHintFileHL = "NvimTreeLspDiagnosticsHintText",
|
||||||
|
|
||||||
|
NvimTreeDiagnosticErrorFolderHL = "NvimTreeLspDiagnosticsErrorFolderText",
|
||||||
|
NvimTreeDiagnosticWarnFolderHL = "NvimTreeLspDiagnosticsWarningFolderText",
|
||||||
|
NvimTreeDiagnosticInfoFolderHL = "NvimTreeLspDiagnosticsInformationFolderText",
|
||||||
|
NvimTreeDiagnosticHintFolderHL = "NvimTreeLspDiagnosticsHintFolderText",
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
-- non-linked
|
||||||
|
for _, g in ipairs(M.HIGHLIGHT_GROUPS) do
|
||||||
|
if g.def then
|
||||||
|
vim.api.nvim_command("hi def " .. g.group .. " " .. g.def)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hard link override when legacy only is present
|
||||||
|
for from, to in pairs(M.LEGACY_LINKS) do
|
||||||
|
local hl_from
|
||||||
|
local hl_to
|
||||||
|
if vim.fn.has "nvim-0.9" == 1 then
|
||||||
|
hl_from = vim.api.nvim_get_hl(0, { name = from })
|
||||||
|
hl_to = vim.api.nvim_get_hl(0, { name = to })
|
||||||
|
else
|
||||||
|
hl_from = vim.api.nvim__get_hl_defs(0)[from] or {}
|
||||||
|
hl_to = vim.api.nvim__get_hl_defs(0)[to] or {}
|
||||||
|
end
|
||||||
|
if vim.tbl_isempty(hl_from) and not vim.tbl_isempty(hl_to) then
|
||||||
|
vim.api.nvim_command("hi link " .. from .. " " .. to)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- default links
|
||||||
|
for _, g in ipairs(M.HIGHLIGHT_GROUPS) do
|
||||||
|
if g.link then
|
||||||
|
vim.api.nvim_command("hi def link " .. g.group .. " " .. g.link)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@ -134,6 +134,13 @@ local CMDS = {
|
|||||||
api.tree.collapse_all(true)
|
api.tree.collapse_all(true)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name = "NvimTreeHiTest",
|
||||||
|
opts = {
|
||||||
|
desc = "nvim-tree: highlight test",
|
||||||
|
},
|
||||||
|
command = api.diagnostics.hi_test,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.get()
|
function M.get()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user