spacevim/bundle/nvim-tree.lua/lua/nvim-tree/renderer/components/git.lua
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

159 lines
4.5 KiB
Lua

local _icons = require "nvim-tree.renderer.icon-config"
local utils = require "nvim-tree.utils"
local M = {}
local function build_icons_table()
local i = M.icon_state.icons.git_icons
return {
["M "] = { { icon = i.staged, hl = "NvimTreeGitStaged" } },
[" M"] = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
["C "] = { { icon = i.staged, hl = "NvimTreeGitStaged" } },
[" C"] = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
["CM"] = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
[" T"] = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
["T "] = { { icon = i.staged, hl = "NvimTreeGitStaged" } },
["MM"] = {
{ icon = i.staged, hl = "NvimTreeGitStaged" },
{ icon = i.unstaged, hl = "NvimTreeGitDirty" },
},
["MD"] = {
{ icon = i.staged, hl = "NvimTreeGitStaged" },
},
["A "] = {
{ icon = i.staged, hl = "NvimTreeGitStaged" },
},
["AD"] = {
{ icon = i.staged, hl = "NvimTreeGitStaged" },
},
[" A"] = {
{ icon = i.untracked, hl = "NvimTreeGitNew" },
},
-- not sure about this one
["AA"] = {
{ icon = i.unmerged, hl = "NvimTreeGitMerge" },
{ icon = i.untracked, hl = "NvimTreeGitNew" },
},
["AU"] = {
{ icon = i.unmerged, hl = "NvimTreeGitMerge" },
{ icon = i.untracked, hl = "NvimTreeGitNew" },
},
["AM"] = {
{ icon = i.staged, hl = "NvimTreeGitStaged" },
{ icon = i.unstaged, hl = "NvimTreeGitDirty" },
},
["??"] = { { icon = i.untracked, hl = "NvimTreeGitNew" } },
["R "] = { { icon = i.renamed, hl = "NvimTreeGitRenamed" } },
[" R"] = { { icon = i.renamed, hl = "NvimTreeGitRenamed" } },
["RM"] = {
{ icon = i.unstaged, hl = "NvimTreeGitDirty" },
{ icon = i.renamed, hl = "NvimTreeGitRenamed" },
},
["UU"] = { { icon = i.unmerged, hl = "NvimTreeGitMerge" } },
["UD"] = { { icon = i.unmerged, hl = "NvimTreeGitMerge" } },
["UA"] = { { icon = i.unmerged, hl = "NvimTreeGitMerge" } },
[" D"] = { { icon = i.deleted, hl = "NvimTreeGitDeleted" } },
["D "] = { { icon = i.deleted, hl = "NvimTreeGitDeleted" } },
["RD"] = { { icon = i.deleted, hl = "NvimTreeGitDeleted" } },
["DD"] = { { icon = i.deleted, hl = "NvimTreeGitDeleted" } },
["DU"] = {
{ icon = i.deleted, hl = "NvimTreeGitDeleted" },
{ icon = i.unmerged, hl = "NvimTreeGitMerge" },
},
["!!"] = { { icon = i.ignored, hl = "NvimTreeGitIgnored" } },
dirty = { { icon = i.unstaged, hl = "NvimTreeGitDirty" } },
}
end
local function nil_() end
local function warn_status(git_status)
utils.warn(
'Unrecognized git state "'
.. git_status
.. '". Please open up an issue on https://github.com/kyazdani42/nvim-tree.lua/issues with this message.'
)
end
local function get_icons_(node)
local git_status = node.git_status
if not git_status then
return nil
end
local icons = M.git_icons[git_status]
if not icons then
if vim.g.nvim_tree_git_hl ~= 1 then
warn_status(git_status)
end
return nil
end
return icons
end
local git_hl = {
["M "] = "NvimTreeFileStaged",
["C "] = "NvimTreeFileStaged",
["AA"] = "NvimTreeFileStaged",
["AD"] = "NvimTreeFileStaged",
["MD"] = "NvimTreeFileStaged",
["T "] = "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",
["!!"] = "NvimTreeGitIgnored",
[" A"] = "none",
}
local function get_highlight_(node)
local git_status = node.git_status
if not git_status then
return
end
return git_hl[git_status]
end
M.get_icons = nil_
M.get_highlight = nil_
M.icon_state = _icons.get_config()
M.git_icons = build_icons_table()
function M.reload()
M.icon_state = _icons.get_config()
M.git_icons = build_icons_table()
if M.icon_state.show_git_icon then
M.get_icons = get_icons_
else
M.get_icons = nil_
end
if vim.g.nvim_tree_git_hl == 1 then
M.get_highlight = get_highlight_
else
M.get_highlight = nil_
end
end
return M