refactor nvim: 將barbar整理出來,反正近期應該都不會再更換buffer模組了

This commit is contained in:
2025-05-23 14:50:27 +08:00
parent f9eab93f57
commit 14dc9c62c6
4 changed files with 0 additions and 1 deletions

View File

@@ -0,0 +1,53 @@
-- 查看說明:
-- nvim +"help bufferline" +only
return {
{
'akinsho/bufferline.nvim',
version = "*",
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
vim.opt.termguicolors = true
require("bufferline").setup{
options = {
mode = "buffers",
custom_filter = function(buf_number)
local buf_ft = vim.bo[buf_number].filetype
if buf_ft == "toggleterm" then
return false
end
return true
end,
click_callback = function(buf_number)
local buf_ft = vim.bo[buf_number].filetype
if buf_ft == "toggleterm" then
-- 如果是 toggleterm 的 Buffer阻止切換
print("Cannot switch to terminal buffer!")
return
end
-- 否則切換到目標 Buffer
vim.api.nvim_set_current_buf(buf_number)
end,
-- custom_filter = function(buf_number)
-- -- 過濾掉 toggleterm 的終端 Buffer
-- local buf_name = vim.fn.bufname(buf_number)
-- if buf_name:match("term://") then
-- return false
-- end
-- return true
-- end,
-- offsets = {
-- {
-- filetype = "neo-tree",
-- text = function()
-- return vim.fn.getcwd()
-- end,
-- highlight = "Directory",
-- text_align = "left"
-- }
-- }
}
}
end,
}
}

View File

@@ -0,0 +1,61 @@
return {
{
'nanozuki/tabby.nvim',
-- event = 'VimEnter', -- if you want lazy load, see below
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
vim.o.showtabline = 2 -- always show tabline
-- configs...
local theme = {
fill = 'TabLineFill',
-- Also you can do this: fill = { fg='#f2e9de', bg='#907aa9', style='italic' }
head = 'TabLine',
current_tab = 'TabLineSel',
tab = 'TabLine',
win = 'TabLine',
tail = 'TabLine',
}
require('tabby').setup({
line = function(line)
return {
{
{ '', hl = theme.head },
line.sep('', theme.head, theme.fill),
},
line.tabs().foreach(function(tab)
local hl = tab.is_current() and theme.current_tab or theme.tab
return {
line.sep('', hl, theme.fill),
tab.is_current() and '' or '󰆣',
tab.number(),
tab.name(),
tab.close_btn(''),
line.sep('', hl, theme.fill),
hl = hl,
margin = ' ',
}
end),
line.spacer(),
line.wins_in_tab(line.api.get_current_tab()).foreach(function(win)
return {
line.sep('', theme.win, theme.fill),
win.is_current() and '' or '',
win.buf_name(),
line.sep('', theme.win, theme.fill),
hl = theme.win,
margin = ' ',
}
end),
{
line.sep('', theme.tail, theme.fill),
{ '', hl = theme.tail },
},
hl = theme.fill,
}
end,
-- option = {}, -- setup modules' option,
})
end,
}
}