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 })
vim.api.nvim_set_option_value("filetype", filetype, { buf = buffer })
print(" ++ attached to buffer " .. name)
require('codemp.window').update()
return controller
end
@ -106,6 +107,7 @@ local function detach(name)
vim.api.nvim_buf_delete(buffer, {})
print(" -- detached from buffer " .. name)
require('codemp.window').update()
end
---@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")
end
session.workspace:create_buffer(buffer):await()
print(" ++ created buffer " .. buffer)
require('codemp.window').update()
end
return {

View file

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