mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
feat(neotree): more sections with more info
This commit is contained in:
parent
9eb057eeac
commit
3f4414dd25
3 changed files with 61 additions and 14 deletions
|
@ -65,6 +65,19 @@ local function new_workspace(name, owned, expanded)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@param key string
|
||||||
|
---@param value string
|
||||||
|
---@return Item
|
||||||
|
local function new_entry(key, value)
|
||||||
|
return {
|
||||||
|
id = "codemp-entry-" .. key .. "-" .. value,
|
||||||
|
name = key .. ": " .. value,
|
||||||
|
type = "entry",
|
||||||
|
extra = {},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local function new_root(name)
|
local function new_root(name)
|
||||||
return {
|
return {
|
||||||
id = "codemp-tree-" .. name,
|
id = "codemp-tree-" .. name,
|
||||||
|
@ -75,6 +88,16 @@ local function new_root(name)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function new_button(name)
|
||||||
|
return {
|
||||||
|
id = "codemp-button-" .. name,
|
||||||
|
name = name,
|
||||||
|
type = "button",
|
||||||
|
extra = {},
|
||||||
|
children = {}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
---@return Item
|
---@return Item
|
||||||
local function spacer()
|
local function spacer()
|
||||||
return {
|
return {
|
||||||
|
@ -120,17 +143,22 @@ M.update_state = function(state)
|
||||||
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, ws_section)
|
||||||
else
|
|
||||||
table.insert(root, spacer())
|
table.insert(root, spacer())
|
||||||
table.insert(root, new_root("[connect]"))
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
if codemp.client == nil then
|
||||||
|
table.insert(root, spacer())
|
||||||
|
table.insert(root, new_button("[connect]"))
|
||||||
end
|
end
|
||||||
|
|
||||||
renderer.show_nodes(root, state)
|
renderer.show_nodes(root, state)
|
||||||
|
for _, node in ipairs(state.tree:get_nodes()) do
|
||||||
if codemp.workspace ~= nil then
|
node:expand()
|
||||||
for _, node in ipairs(state.tree:get_nodes()) do
|
|
||||||
node:expand()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,25 @@ M.icon = function(config, node, state)
|
||||||
icon = "= "
|
icon = "= "
|
||||||
highlight = highlights.DIRECTORY_ICON
|
highlight = highlights.DIRECTORY_ICON
|
||||||
elseif node.type == "root" then
|
elseif node.type == "root" then
|
||||||
icon = "> "
|
if node:is_expanded() then
|
||||||
|
icon = "> "
|
||||||
|
else
|
||||||
|
icon = "- "
|
||||||
|
end
|
||||||
highlight = highlights.DIRECTORY_ICON
|
highlight = highlights.DIRECTORY_ICON
|
||||||
elseif node.type == "workspace" then
|
elseif node.type == "workspace" then
|
||||||
icon = "= "
|
icon = "* "
|
||||||
highlight = highlights.SYMBOLIC_LINK_TARGET
|
if node.extra.owned then
|
||||||
|
highlight = highlights.GIT_STAGED
|
||||||
|
else
|
||||||
|
highlight = highlights.DIRECTORY_ICON
|
||||||
|
end
|
||||||
elseif node.type == "user" then
|
elseif node.type == "user" then
|
||||||
icon = ":"
|
icon = ":"
|
||||||
highlight = codemp_utils.color(node.name)
|
highlight = codemp_utils.color(node.name)
|
||||||
|
elseif node.type == "entry" then
|
||||||
|
icon = "$"
|
||||||
|
highlight = highlight.GIT_STAGED
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -50,12 +61,11 @@ M.name = function(config, node, state)
|
||||||
local highlight = config.highlight or highlights.FILE_NAME
|
local highlight = config.highlight or highlights.FILE_NAME
|
||||||
local text = node.name
|
local text = node.name
|
||||||
if node.type == "title" then
|
if node.type == "title" then
|
||||||
text = ":: " .. node.name .. " ::"
|
text = " :: " .. node.name .. " :: "
|
||||||
highlight = highlights.PREVIEW
|
highlight = highlights.PREVIEW
|
||||||
elseif node.type == "root" then
|
elseif node.type == "root" or node.type == "button" then
|
||||||
|
text = " " .. node.name .. " "
|
||||||
highlight = highlights.FLOAT_TITLE
|
highlight = highlights.FLOAT_TITLE
|
||||||
elseif node.type == "workspace" then
|
|
||||||
highlight = highlights.SYMBOLIC_LINK_TARGET
|
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
text = text,
|
text = text,
|
||||||
|
|
|
@ -42,6 +42,15 @@ M.default_config = {
|
||||||
{ "spacer" },
|
{ "spacer" },
|
||||||
{ "users" },
|
{ "users" },
|
||||||
},
|
},
|
||||||
|
entry = {
|
||||||
|
{ "indent" },
|
||||||
|
{ "icon" },
|
||||||
|
{ "name" },
|
||||||
|
},
|
||||||
|
button = {
|
||||||
|
{ "indent" },
|
||||||
|
{ "name" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue