Repository navigation
|
Hello, is it possible to separate the file icons from the selected icon, I like to have the git icons before the file icon, and I also would like the selected icon to be the first thing that appears, however right now the file icons and the selected icons are in the same item, so I can't put the git icons in the middle. Is there a way to do that? |
Replies: 1 comment 1 reply
|
Yes - the selection marker is baked into the built-in Custom components go in the source's local common = require("neo-tree.sources.common.components")
local function is_selected(node, state)
return state.selected and state.selected[node.id]
end
require("neo-tree").setup({
filesystem = {
components = {
-- the built-in icon, without the selection marker
icon = function(config, node, state)
local result = common.icon(config, node, state)
if is_selected(node, state) then
return result[2]
end
return result
end,
-- the selection marker on its own
selected = function(config, node, state)
if not is_selected(node, state) then
return {}
end
return { text = (config.text or "") .. " ", highlight = "NeoTreeSelected" }
end,
},
renderers = {
file = {
{ "indent" },
{ "selected" },
{ "git_status" },
{ "icon" },
{
"container",
content = {
{ "name", zindex = 10 },
{ "symlink_target", zindex = 10, highlight = "NeoTreeSymbolicLinkTarget" },
{ "clipboard", zindex = 10 },
{ "modified", zindex = 20, align = "right" },
{ "diagnostics", zindex = 20, align = "right" },
},
},
},
},
},
})That renders as Source, if you want it: |
Yes - the selection marker is baked into the built-in
iconcomponent (when a node is selected it returns{ marker, icon }), so you need to split it into two custom components and then order them however you like in the renderer.Custom components go in the source's
componentstable and override built-ins of the same name, so you can wrap the stockiconand strip the marker, and add a separateselectedcomponent: