fix: refresh tree when interacting with buffers

This commit is contained in:
əlemi 2024-09-07 03:35:32 +02:00
parent c080514c3e
commit 0eeedead59
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 14 additions and 10 deletions

View file

@ -93,6 +93,7 @@ local function attach(name, buffer, content, nowait)
local filetype = vim.filetype.match({ buf = buffer }) local filetype = vim.filetype.match({ buf = buffer })
vim.api.nvim_set_option_value("filetype", filetype, { buf = buffer }) vim.api.nvim_set_option_value("filetype", filetype, { buf = buffer })
print(" ++ attached to buffer " .. name) print(" ++ attached to buffer " .. name)
require('codemp.window').update()
return controller return controller
end end
@ -106,6 +107,7 @@ local function detach(name)
vim.api.nvim_buf_delete(buffer, {}) vim.api.nvim_buf_delete(buffer, {})
print(" -- detached from buffer " .. name) print(" -- detached from buffer " .. name)
require('codemp.window').update()
end end
---@param buffer? integer if provided, sync given buffer id, otherwise sync current buf ---@param buffer? integer if provided, sync given buffer id, otherwise sync current buf
@ -135,6 +137,8 @@ local function create(buffer)
error("join a workspace first") error("join a workspace first")
end end
session.workspace:create_buffer(buffer):await() session.workspace:create_buffer(buffer):await()
print(" ++ created buffer " .. buffer)
require('codemp.window').update()
end end
return { return {

View file

@ -20,20 +20,20 @@ local M = {}
M.icon = function(config, node, state) M.icon = function(config, node, state)
local icon, highlight local icon, highlight
if node.type == "buffer" then if node.type == "buffer" then
icon = "- " if codemp_buffers.map_rev[node.name] ~= nil then
icon = "+ "
else
icon = "- "
end
highlight = highlights.FILE_ICON highlight = highlights.FILE_ICON
elseif node.type == "directory" then elseif node.type == "directory" then
icon = "= " icon = "= "
highlight = highlights.DIRECTORY_ICON highlight = highlights.DIRECTORY_ICON
elseif node.type == "root" then elseif node.type == "root" then
icon = "> " icon = "]| "
highlight = highlights.FILE_STATS_HEADER highlight = highlights.DIRECTORY_ICON
elseif node.type == "workspace" then elseif node.type == "workspace" then
if node:is_expanded() then icon = "= "
icon = "| "
else
icon = "+ "
end
highlight = highlights.SYMBOLIC_LINK_TARGET highlight = highlights.SYMBOLIC_LINK_TARGET
elseif node.type == "user" then elseif node.type == "user" then
icon = ":" icon = ":"
@ -49,7 +49,7 @@ end
M.name = function(config, node, state) M.name = function(config, node, state)
local highlight = config.highlight or highlights.FILE_NAME local highlight = config.highlight or highlights.FILE_NAME
if node.type == "root" then if node.type == "root" then
highlight = highlights.ROOT_NAME highlight = highlights.FLOAT_TITLE
elseif node.type == "workspace" then elseif node.type == "workspace" then
highlight = highlights.SYMBOLIC_LINK_TARGET highlight = highlights.SYMBOLIC_LINK_TARGET
end end
@ -74,7 +74,7 @@ M.users = function(config, node, state)
table.insert(out, { table.insert(out, {
text = " ", text = " ",
highlight = codemp_utils.color(user), highlight = codemp_utils.color(user),
align = "right", align = "end",
}) })
end end
end end