refactor neovim: 調整chezmoi apply到nvim的結構

This commit is contained in:
2025-04-30 11:05:04 +08:00
parent 9240f60445
commit d8768c6363
26 changed files with 0 additions and 17 deletions

View File

@@ -0,0 +1,42 @@
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'},
},
}
-- 重定義 :q 命令為僅關閉當前 Buffer
vim.api.nvim_create_user_command('Q', function()
vim.cmd('BufferClose') -- 使用 barbar.nvim 的 BufferClose 呀命
end, {})
-- 重定義 :wq 命令為保存後僅關閉當前 Buffer
vim.api.nvim_create_user_command('WQ', function()
vim.cmd('write') -- 保存文件
vim.cmd('BufferClose') -- 使用 barbar.nvim 的 BufferClose 命令
end, {})
-- 設定快速鍵
-- vim.api.nvim_set_keymap('t', '<A-Esc>', [[<C-\><C-n>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-l>', '<cmd>BufferNext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-h>', '<cmd>BufferPrevious<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-RIGHT>', '<cmd>BufferNext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<A-LEFT>', '<cmd>BufferPrevious<CR>', { noremap = true, silent = true })
end,
},
}

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,
}
}