From df3f04602ec7ce261d2fed3519d6bd9c558c5e64 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sat, 31 May 2025 14:53:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20nvim:=20=E4=BF=AE=E6=AD=A3=E5=88=87?= =?UTF-8?q?=E6=8F=9Bwinbar=E6=99=82=E6=9C=83=E9=80=A0=E6=88=90barbar?= =?UTF-8?q?=E5=88=86=E9=A0=81=E8=B7=91=E6=8E=89=E7=9A=84=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exact_plugins/exact_components/barbar.lua | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/dot_config/nvim/exact_lua/exact_plugins/exact_components/barbar.lua b/dot_config/nvim/exact_lua/exact_plugins/exact_components/barbar.lua index 0fe6ac2..26943c0 100644 --- a/dot_config/nvim/exact_lua/exact_plugins/exact_components/barbar.lua +++ b/dot_config/nvim/exact_lua/exact_plugins/exact_components/barbar.lua @@ -21,7 +21,10 @@ return { -- separator = {left = '', right = ''}, }, sidebar_filetypes = { - ['neo-tree'] = {event = 'BufWipeout'}, + ['neo-tree'] = { + event = 'BufWipeout' + -- event = 'BufWinEnter' + }, undotree = { text = 'undotree', align = 'center', -- *optionally* specify an alignment (either 'left', 'center', or 'right') @@ -46,6 +49,31 @@ return { -- } require('barbar').setup(opts) + vim.api.nvim_create_autocmd("BufEnter", { + pattern = "*", + callback = function() + local ft = vim.bo.filetype + if ft == "neo-tree" then + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + if vim.bo[buf].filetype == "neo-tree" then + local width = vim.api.nvim_win_get_width(win) + require("barbar.api").set_offset(width, "") + break + end + end + end + end, + }) + vim.api.nvim_create_autocmd("BufLeave", { + pattern = "*", + callback = function() + if vim.bo.filetype == "neo-tree" then + require("barbar.api").set_offset(0) + end + end, + }) + -- 重定義 :q 命令為僅關閉當前 Buffer vim.api.nvim_create_user_command('Q', function() vim.cmd('BufferClose') -- 使用 barbar.nvim 的 BufferClose 呀命