From 0eeedead598524db1529f8d417114939c0153b35 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 7 Sep 2024 03:35:32 +0200 Subject: [PATCH] fix: refresh tree when interacting with buffers --- lua/codemp/buffers.lua | 4 ++++ lua/codemp/neo-tree/components.lua | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index 8f83527..57a961a 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -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 { diff --git a/lua/codemp/neo-tree/components.lua b/lua/codemp/neo-tree/components.lua index ebad9c0..e7498b7 100644 --- a/lua/codemp/neo-tree/components.lua +++ b/lua/codemp/neo-tree/components.lua @@ -20,20 +20,20 @@ local M = {} M.icon = function(config, node, state) local icon, highlight if node.type == "buffer" then - icon = "- " + 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