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