nvim: 大整理tab buffer架構與功能
This commit is contained in:
32
dot_config/exact_nvim/exact_lua/exact_plugins/tab/barbar.lua
Normal file
32
dot_config/exact_nvim/exact_lua/exact_plugins/tab/barbar.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
-- if true then return {} end -- 停用
|
||||
|
||||
return {
|
||||
{'romgrk/barbar.nvim',
|
||||
version = '^1.0.0', -- optional: only update when a new 1.x version is released
|
||||
dependencies = {
|
||||
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status
|
||||
'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
|
||||
},
|
||||
init = function() vim.g.barbar_auto_setup = false end,
|
||||
-- opts = {
|
||||
-- -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
|
||||
-- -- animation = false,
|
||||
-- -- insert_at_start = true,
|
||||
-- -- …etc.
|
||||
-- },
|
||||
config = function(_, opts)
|
||||
require'bufferline'.setup {
|
||||
-- animation = false, -- 禁用動畫效果
|
||||
sidebar_filetypes = {
|
||||
['neo-tree'] = {event = 'BufWipeout'},
|
||||
},
|
||||
}
|
||||
|
||||
-- 設定快速鍵
|
||||
-- vim.api.nvim_set_keymap('t', '<A-Esc>', [[<C-\><C-n>]], { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-]>', '<cmd>BufferNext<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-[>', '<cmd>BufferPrevious<CR>', { noremap = true, silent = true })
|
||||
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
if true then return {} end -- 停用
|
||||
|
||||
-- 查看說明:
|
||||
-- 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,
|
||||
}
|
||||
}
|
||||
63
dot_config/exact_nvim/exact_lua/exact_plugins/tab/tabby.lua
Normal file
63
dot_config/exact_nvim/exact_lua/exact_plugins/tab/tabby.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
if true then return {} end -- 因為barbar會與tabby衝突,停用
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user