Custom Component Function Does Not Render Custom git_status Symbols #1808
Answered
by
Leonie-Theobald
Leonie-Theobald
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
Leonie-Theobald
Jul 1, 2025
Replies: 1 comment
-
I found a solution with this setup. Still not sure whether this is the intended method but it works for me: require("neo-tree").setup({
default_component_configs = {
icon = {
-- override folder symbols
folder_closed = "■",
folder_open = "□",
folder_empty = "⛶",
},
},
filesystem = {
components = {
git_status_or_empty = function(config, node, state)
local git_status = require("neo-tree.sources.common.components")
.git_status(config, node, state).text
-- not part of git status
if git_status == nil then
return {
text = "-",
highlight = "NeoTreeDarkFont"
}
-- untracked
elseif git_status == "[?]" then
return {
text = "U",
highlight = "NeoTreeGitUntracked"
}
-- ignored
elseif git_status == "[!!]" then
return {
text = "I",
highlight = "NeoTreeGitIgnored"
}
-- unstaged or modified
elseif git_status == "[ M]" or git_status == "[M]" then
return {
text = "Z",
highlight = "NeoTreeGitUnstaged"
}
-- deleted
elseif git_status == "[D]" then
return {
text = "D",
highlight = "NeoTreeGitUnstaged"
}
-- staged
elseif git_status == "[A]" then
return {
text = "S",
highlight = "NeoTreeGitStaged"
}
-- partially staged and modified/unstaged
-- happens if a file is staged and then modified again
elseif git_status == "[MM]" then
return {
text = "5",
highlight = "NeoTreeGitUnstaged"
}
-- conflict
elseif git_status == "[C]" then
return {
text = "C",
highlight = "NeoTreeGitConflict"
}
-- missing git status symbol
else
return {
text = git_status,
highlight = "Normal"
}
end
end,
},
renderers = {
file = {
{ "git_status_or_empty" },
{ "name" },
},
},
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Leonie-Theobald
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a solution with this setup. Still not sure whether this is the intended method but it works for me: