* feat(#2197): add git folder highlight groups * feat(#2197): add diagnostics folder highlight groups
This commit is contained in:
committed by
GitHub
parent
8f48426c88
commit
b7f6600bc2
@@ -2180,28 +2180,43 @@ Git Icon: >
|
|||||||
NvimTreeGitRenamed
|
NvimTreeGitRenamed
|
||||||
NvimTreeGitNew
|
NvimTreeGitNew
|
||||||
NvimTreeGitDeleted
|
NvimTreeGitDeleted
|
||||||
NvimTreeGitIgnored Comment
|
NvimTreeGitIgnored Comment
|
||||||
<
|
<
|
||||||
Git Text: >
|
Git File Text: >
|
||||||
NvimTreeFileDirty NvimTreeGitDirty
|
NvimTreeFileDirty NvimTreeGitDirty
|
||||||
NvimTreeFileStaged NvimTreeGitStaged
|
NvimTreeFileStaged NvimTreeGitStaged
|
||||||
NvimTreeFileMerge NvimTreeGitMerge
|
NvimTreeFileMerge NvimTreeGitMerge
|
||||||
NvimTreeFileRenamed NvimTreeGitRenamed
|
NvimTreeFileRenamed NvimTreeGitRenamed
|
||||||
NvimTreeFileNew NvimTreeGitNew
|
NvimTreeFileNew NvimTreeGitNew
|
||||||
NvimTreeFileDeleted NvimTreeGitDeleted
|
NvimTreeFileDeleted NvimTreeGitDeleted
|
||||||
NvimTreeFileIgnored NvimTreeGitIgnored
|
NvimTreeFileIgnored NvimTreeGitIgnored
|
||||||
|
<
|
||||||
|
Git Folder Text: >
|
||||||
|
NvimTreeFolderDirty NvimTreeFileDirty
|
||||||
|
NvimTreeFolderStaged NvimTreeFileStaged
|
||||||
|
NvimTreeFolderMerge NvimTreeFileMerge
|
||||||
|
NvimTreeFolderRenamed NvimTreeFileRenamed
|
||||||
|
NvimTreeFolderNew NvimTreeFileNew
|
||||||
|
NvimTreeFolderDeleted NvimTreeFileDeleted
|
||||||
|
NvimTreeFolderIgnored NvimTreeFileIgnored
|
||||||
<
|
<
|
||||||
Diagnostics Icon: >
|
Diagnostics Icon: >
|
||||||
NvimTreeLspDiagnosticsError DiagnosticError
|
NvimTreeLspDiagnosticsError DiagnosticError
|
||||||
NvimTreeLspDiagnosticsWarning DiagnosticWarn
|
NvimTreeLspDiagnosticsWarning DiagnosticWarn
|
||||||
NvimTreeLspDiagnosticsInformation DiagnosticInfo
|
NvimTreeLspDiagnosticsInformation DiagnosticInfo
|
||||||
NvimTreeLspDiagnosticsHint DiagnosticHint
|
NvimTreeLspDiagnosticsHint DiagnosticHint
|
||||||
<
|
<
|
||||||
Diagnostics Text: >
|
Diagnostics File Text: >
|
||||||
NvimTreeLspDiagnosticsErrorText NvimTreeLspDiagnosticsError
|
NvimTreeLspDiagnosticsErrorText NvimTreeLspDiagnosticsError
|
||||||
NvimTreeLspDiagnosticsWarningText NvimTreeLspDiagnosticsWarning
|
NvimTreeLspDiagnosticsWarningText NvimTreeLspDiagnosticsWarning
|
||||||
NvimTreeLspDiagnosticsInfoText NvimTreeLspDiagnosticsInformation
|
NvimTreeLspDiagnosticsInfoText NvimTreeLspDiagnosticsInformation
|
||||||
NvimTreeLspDiagnosticsHintText NvimTreeLspDiagnosticsHint
|
NvimTreeLspDiagnosticsHintText NvimTreeLspDiagnosticsHint
|
||||||
|
<
|
||||||
|
Diagnostics Folder Text: >
|
||||||
|
NvimTreeLspDiagnosticsErrorFolderText NvimTreeLspDiagnosticsErrorText
|
||||||
|
NvimTreeLspDiagnosticsWarningFolderText NvimTreeLspDiagnosticsWarningText
|
||||||
|
NvimTreeLspDiagnosticsInfoFolderText NvimTreeLspDiagnosticsInfoText
|
||||||
|
NvimTreeLspDiagnosticsHintFolderText NvimTreeLspDiagnosticsHintText
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. EVENTS *nvim-tree-events*
|
9. EVENTS *nvim-tree-events*
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ local function get_links()
|
|||||||
FileStaged = "NvimTreeGitStaged",
|
FileStaged = "NvimTreeGitStaged",
|
||||||
FileDeleted = "NvimTreeGitDeleted",
|
FileDeleted = "NvimTreeGitDeleted",
|
||||||
FileIgnored = "NvimTreeGitIgnored",
|
FileIgnored = "NvimTreeGitIgnored",
|
||||||
|
FolderDirty = "NvimTreeFileDirty",
|
||||||
|
FolderNew = "NvimTreeFileNew",
|
||||||
|
FolderRenamed = "NvimTreeFileRenamed",
|
||||||
|
FolderMerge = "NvimTreeFileMerge",
|
||||||
|
FolderStaged = "NvimTreeFileStaged",
|
||||||
|
FolderDeleted = "NvimTreeFileDeleted",
|
||||||
|
FolderIgnored = "NvimTreeFileIgnored",
|
||||||
LspDiagnosticsError = "DiagnosticError",
|
LspDiagnosticsError = "DiagnosticError",
|
||||||
LspDiagnosticsWarning = "DiagnosticWarn",
|
LspDiagnosticsWarning = "DiagnosticWarn",
|
||||||
LspDiagnosticsInformation = "DiagnosticInfo",
|
LspDiagnosticsInformation = "DiagnosticInfo",
|
||||||
@@ -90,6 +97,10 @@ local function get_links()
|
|||||||
LspDiagnosticsWarningText = "NvimTreeLspDiagnosticsWarning",
|
LspDiagnosticsWarningText = "NvimTreeLspDiagnosticsWarning",
|
||||||
LspDiagnosticsInformationText = "NvimTreeLspDiagnosticsInformation",
|
LspDiagnosticsInformationText = "NvimTreeLspDiagnosticsInformation",
|
||||||
LspDiagnosticsHintText = "NvimTreeLspDiagnosticsHintFile",
|
LspDiagnosticsHintText = "NvimTreeLspDiagnosticsHintFile",
|
||||||
|
LspDiagnosticsErrorFolderText = "NvimTreeLspDiagnosticsErrorText",
|
||||||
|
LspDiagnosticsWarningFolderText = "NvimTreeLspDiagnosticsWarningText",
|
||||||
|
LspDiagnosticsInformationFolderText = "NvimTreeLspDiagnosticsInformationText",
|
||||||
|
LspDiagnosticsHintFolderText = "NvimTreeLspDiagnosticsHintFileText",
|
||||||
Popup = "Normal",
|
Popup = "Normal",
|
||||||
GitIgnored = "Comment",
|
GitIgnored = "Comment",
|
||||||
StatusLine = "StatusLine",
|
StatusLine = "StatusLine",
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local H = {}
|
local HS_FILE = {}
|
||||||
local I = {}
|
local HS_FOLDER = {}
|
||||||
|
local ICON = {}
|
||||||
|
|
||||||
---diagnostics text highlight group if there is a status
|
---diagnostics text highlight group if there is a status
|
||||||
---@param node table
|
---@param node table
|
||||||
---@return string|nil highlight
|
---@return string|nil highlight
|
||||||
function M.get_highlight(node)
|
function M.get_highlight(node)
|
||||||
if M.config.diagnostics.enable and M.config.renderer.highlight_diagnostics then
|
if node and M.config.diagnostics.enable and M.config.renderer.highlight_diagnostics then
|
||||||
return H[node.diag_status]
|
if node.nodes then
|
||||||
|
return HS_FOLDER[node.diag_status]
|
||||||
|
else
|
||||||
|
return HS_FILE[node.diag_status]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -16,8 +21,8 @@ end
|
|||||||
---@param node table
|
---@param node table
|
||||||
---@return HighlightedString|nil modified icon
|
---@return HighlightedString|nil modified icon
|
||||||
function M.get_icon(node)
|
function M.get_icon(node)
|
||||||
if M.config.diagnostics.enable and M.config.renderer.icons.show.diagnostics then
|
if node and M.config.diagnostics.enable and M.config.renderer.icons.show.diagnostics then
|
||||||
return I[node.diag_status]
|
return ICON[node.diag_status]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,30 +32,35 @@ function M.setup(opts)
|
|||||||
renderer = opts.renderer,
|
renderer = opts.renderer,
|
||||||
}
|
}
|
||||||
|
|
||||||
H[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorText"
|
HS_FILE[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorText"
|
||||||
H[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningText"
|
HS_FILE[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningText"
|
||||||
H[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoText"
|
HS_FILE[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoText"
|
||||||
H[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintText"
|
HS_FILE[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintText"
|
||||||
|
|
||||||
I[vim.diagnostic.severity.ERROR] = {
|
HS_FOLDER[vim.diagnostic.severity.ERROR] = "NvimTreeLspDiagnosticsErrorFolderText"
|
||||||
|
HS_FOLDER[vim.diagnostic.severity.WARN] = "NvimTreeLspDiagnosticsWarningFolderText"
|
||||||
|
HS_FOLDER[vim.diagnostic.severity.INFO] = "NvimTreeLspDiagnosticsInfoFolderText"
|
||||||
|
HS_FOLDER[vim.diagnostic.severity.HINT] = "NvimTreeLspDiagnosticsHintFolderText"
|
||||||
|
|
||||||
|
ICON[vim.diagnostic.severity.ERROR] = {
|
||||||
str = M.config.diagnostics.icons.error,
|
str = M.config.diagnostics.icons.error,
|
||||||
hl = "NvimTreeLspDiagnosticsError",
|
hl = "NvimTreeLspDiagnosticsError",
|
||||||
}
|
}
|
||||||
|
|
||||||
I[vim.diagnostic.severity.WARN] = {
|
ICON[vim.diagnostic.severity.WARN] = {
|
||||||
str = M.config.diagnostics.icons.warning,
|
str = M.config.diagnostics.icons.warning,
|
||||||
hl = "NvimTreeLspDiagnosticsWarning",
|
hl = "NvimTreeLspDiagnosticsWarning",
|
||||||
}
|
}
|
||||||
I[vim.diagnostic.severity.INFO] = {
|
ICON[vim.diagnostic.severity.INFO] = {
|
||||||
str = M.config.diagnostics.icons.info,
|
str = M.config.diagnostics.icons.info,
|
||||||
hl = "NvimTreeLspDiagnosticsInfo",
|
hl = "NvimTreeLspDiagnosticsInfo",
|
||||||
}
|
}
|
||||||
I[vim.diagnostic.severity.HINT] = {
|
ICON[vim.diagnostic.severity.HINT] = {
|
||||||
str = M.config.diagnostics.icons.hint,
|
str = M.config.diagnostics.icons.hint,
|
||||||
hl = "NvimTreeLspDiagnosticsHint",
|
hl = "NvimTreeLspDiagnosticsHint",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, i in ipairs(I) do
|
for _, i in ipairs(ICON) do
|
||||||
vim.fn.sign_define(i.hl, { text = i.str, texthl = i.hl })
|
vim.fn.sign_define(i.hl, { text = i.str, texthl = i.hl })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,6 +49,48 @@ local function build_icons_table(i)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function build_hl_table()
|
||||||
|
local file = {
|
||||||
|
["M "] = "NvimTreeFileStaged",
|
||||||
|
["C "] = "NvimTreeFileStaged",
|
||||||
|
["AA"] = "NvimTreeFileStaged",
|
||||||
|
["AD"] = "NvimTreeFileStaged",
|
||||||
|
["MD"] = "NvimTreeFileStaged",
|
||||||
|
["T "] = "NvimTreeFileStaged",
|
||||||
|
["TT"] = "NvimTreeFileStaged",
|
||||||
|
[" M"] = "NvimTreeFileDirty",
|
||||||
|
["CM"] = "NvimTreeFileDirty",
|
||||||
|
[" C"] = "NvimTreeFileDirty",
|
||||||
|
[" T"] = "NvimTreeFileDirty",
|
||||||
|
["MM"] = "NvimTreeFileDirty",
|
||||||
|
["AM"] = "NvimTreeFileDirty",
|
||||||
|
dirty = "NvimTreeFileDirty",
|
||||||
|
["A "] = "NvimTreeFileNew",
|
||||||
|
["??"] = "NvimTreeFileNew",
|
||||||
|
["AU"] = "NvimTreeFileMerge",
|
||||||
|
["UU"] = "NvimTreeFileMerge",
|
||||||
|
["UD"] = "NvimTreeFileMerge",
|
||||||
|
["DU"] = "NvimTreeFileMerge",
|
||||||
|
["UA"] = "NvimTreeFileMerge",
|
||||||
|
[" D"] = "NvimTreeFileDeleted",
|
||||||
|
["DD"] = "NvimTreeFileDeleted",
|
||||||
|
["RD"] = "NvimTreeFileDeleted",
|
||||||
|
["D "] = "NvimTreeFileDeleted",
|
||||||
|
["R "] = "NvimTreeFileRenamed",
|
||||||
|
["RM"] = "NvimTreeFileRenamed",
|
||||||
|
[" R"] = "NvimTreeFileRenamed",
|
||||||
|
["!!"] = "NvimTreeFileIgnored",
|
||||||
|
[" A"] = "none",
|
||||||
|
}
|
||||||
|
|
||||||
|
local folder = {}
|
||||||
|
for k, v in pairs(file) do
|
||||||
|
folder[k] = v:gsub("File", "Folder")
|
||||||
|
end
|
||||||
|
|
||||||
|
return file, folder
|
||||||
|
end
|
||||||
|
|
||||||
local function nil_() end
|
local function nil_() end
|
||||||
|
|
||||||
local function warn_status(git_status)
|
local function warn_status(git_status)
|
||||||
@@ -101,39 +143,6 @@ local function get_icons_(node)
|
|||||||
return iconss
|
return iconss
|
||||||
end
|
end
|
||||||
|
|
||||||
local git_hl = {
|
|
||||||
["M "] = "NvimTreeFileStaged",
|
|
||||||
["C "] = "NvimTreeFileStaged",
|
|
||||||
["AA"] = "NvimTreeFileStaged",
|
|
||||||
["AD"] = "NvimTreeFileStaged",
|
|
||||||
["MD"] = "NvimTreeFileStaged",
|
|
||||||
["T "] = "NvimTreeFileStaged",
|
|
||||||
["TT"] = "NvimTreeFileStaged",
|
|
||||||
[" M"] = "NvimTreeFileDirty",
|
|
||||||
["CM"] = "NvimTreeFileDirty",
|
|
||||||
[" C"] = "NvimTreeFileDirty",
|
|
||||||
[" T"] = "NvimTreeFileDirty",
|
|
||||||
["MM"] = "NvimTreeFileDirty",
|
|
||||||
["AM"] = "NvimTreeFileDirty",
|
|
||||||
dirty = "NvimTreeFileDirty",
|
|
||||||
["A "] = "NvimTreeFileNew",
|
|
||||||
["??"] = "NvimTreeFileNew",
|
|
||||||
["AU"] = "NvimTreeFileMerge",
|
|
||||||
["UU"] = "NvimTreeFileMerge",
|
|
||||||
["UD"] = "NvimTreeFileMerge",
|
|
||||||
["DU"] = "NvimTreeFileMerge",
|
|
||||||
["UA"] = "NvimTreeFileMerge",
|
|
||||||
[" D"] = "NvimTreeFileDeleted",
|
|
||||||
["DD"] = "NvimTreeFileDeleted",
|
|
||||||
["RD"] = "NvimTreeFileDeleted",
|
|
||||||
["D "] = "NvimTreeFileDeleted",
|
|
||||||
["R "] = "NvimTreeFileRenamed",
|
|
||||||
["RM"] = "NvimTreeFileRenamed",
|
|
||||||
[" R"] = "NvimTreeFileRenamed",
|
|
||||||
["!!"] = "NvimTreeFileIgnored",
|
|
||||||
[" A"] = "none",
|
|
||||||
}
|
|
||||||
|
|
||||||
function M.setup_signs(i)
|
function M.setup_signs(i)
|
||||||
vim.fn.sign_define("NvimTreeGitDirty", { text = i.unstaged, texthl = "NvimTreeGitDirty" })
|
vim.fn.sign_define("NvimTreeGitDirty", { text = i.unstaged, texthl = "NvimTreeGitDirty" })
|
||||||
vim.fn.sign_define("NvimTreeGitStaged", { text = i.staged, texthl = "NvimTreeGitStaged" })
|
vim.fn.sign_define("NvimTreeGitStaged", { text = i.staged, texthl = "NvimTreeGitStaged" })
|
||||||
@@ -150,7 +159,11 @@ local function get_highlight_(node)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
return git_hl[git_status[1]]
|
if node.nodes then
|
||||||
|
return M.folder_hl[git_status[1]]
|
||||||
|
else
|
||||||
|
return M.file_hl[git_status[1]]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
@@ -158,6 +171,8 @@ function M.setup(opts)
|
|||||||
|
|
||||||
M.git_icons = build_icons_table(opts.renderer.icons.glyphs.git)
|
M.git_icons = build_icons_table(opts.renderer.icons.glyphs.git)
|
||||||
|
|
||||||
|
M.file_hl, M.folder_hl = build_hl_table()
|
||||||
|
|
||||||
if opts.renderer.icons.git_placement == "signcolumn" then
|
if opts.renderer.icons.git_placement == "signcolumn" then
|
||||||
M.setup_signs(opts.renderer.icons.glyphs.git)
|
M.setup_signs(opts.renderer.icons.glyphs.git)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user