fix(neotree): now everything sits under codemp title

This commit is contained in:
əlemi 2024-09-07 04:37:49 +02:00
parent f5a66f8ba7
commit 134a1b6f00
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -110,16 +110,14 @@ end
M.update_state = function(state)
---@type Item[]
local root = {
{
id = "codemp",
name = "codemp",
type = "title",
extra = {},
}
id = "codemp",
name = "codemp",
type = "title",
extra = {},
children = {},
}
if codemp.workspace ~= nil then
table.insert(root, spacer())
local ws_section = new_root("session #" .. codemp.workspace.name)
for i, path in ipairs(codemp.workspace:filetree()) do
table.insert(ws_section.children, new_item(codemp.workspace.name, path))
@ -131,30 +129,31 @@ M.update_state = function(state)
end
table.insert(ws_section.children, spacer())
table.insert(ws_section.children, usr_section)
table.insert(root, ws_section)
table.insert(root.children, spacer())
table.insert(root.children, ws_section)
end
if codemp.client ~= nil then
table.insert(root, spacer())
local ws_section = new_root("workspaces")
for _, ws in ipairs(codemp.available) do
table.insert(ws_section.children, new_workspace(ws.name, ws.owned))
end
table.insert(root, ws_section)
table.insert(root.children, spacer())
table.insert(root.children, ws_section)
table.insert(root, spacer())
local status_section = new_root("client")
table.insert(status_section.children, new_entry("id", codemp.client.id))
table.insert(status_section.children, new_entry("name", codemp.client.username))
table.insert(root, status_section)
table.insert(root.children, spacer())
table.insert(root.children, status_section)
end
if codemp.client == nil then
table.insert(root, spacer())
table.insert(root, new_button("[connect]"))
table.insert(root.children, spacer())
table.insert(root.children, new_button("[connect]"))
end
renderer.show_nodes(root, state)
renderer.show_nodes({ root }, state)
for _, node in ipairs(state.tree:get_nodes()) do
node:expand()
end