refactor neovim: 調整plugin分類結構

This commit is contained in:
2025-04-30 12:13:26 +08:00
parent d313a3e650
commit afeac1bb77
15 changed files with 7 additions and 4 deletions

View File

@@ -0,0 +1,28 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
config = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
local wk = require("which-key")
-- 快捷鍵在這裡定義
wk.setup()
end,
},
}

View File

@@ -0,0 +1,73 @@
-- if true then return {} end -- 暫時停用
return {
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
event = "VeryLazy",
opts = function()
-- 選擇計數格式
local function selectionCount()
local mode = vim.fn.mode()
if not mode:find("[Vv]") then return "" end -- 僅在 Visual 模式下顯示
local starts = vim.fn.line("v")
local ends = vim.fn.line(".")
local lines = math.abs(ends - starts) + 1
local chars = vim.fn.wordcount().visual_chars or 0
return string.format("📏 %dL %dC", lines, chars)
end
-- 自定義 location 格式
local function customLocation()
local location = vim.api.nvim_eval_statusline("%l:%c", {}).str -- 獲取行和列
return "📍 " .. location -- 在字首添加 emoji
end
return {
options = {
icons_enabled = true,
theme = 'onedark',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
always_show_tabline = true,
globalstatus = false,
refresh = {
statusline = 100,
tabline = 100,
winbar = 100,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {{ selectionCount }, { customLocation },}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {{ customLocation }},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {'neo-tree', 'toggleterm'}
}
end,
-- config = function(_, opts)
-- require('lualine').setup(opts)
-- end,
},
}

View File

@@ -0,0 +1,7 @@
return {
'mvllow/modes.nvim',
tag = 'v0.2.1',
config = function()
require('modes').setup()
end
}

View File

@@ -0,0 +1,80 @@
-- if true then return {} end -- 暫時停用
return {
{
"folke/noice.nvim",
event = "VeryLazy",
opts = {
-- add any options here
},
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
"MunifTanjim/nui.nvim",
-- OPTIONAL:
-- `nvim-notify` is only needed, if you want to use the notification view.
-- If not available, we use `mini` as the fallback
"rcarriga/nvim-notify",
},
config = function(_, opts)
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
-- Optional: add any additional configuration here
views = {
cmdline_popup = {
border = {
style = "rounded", -- 邊框樣式,可選 "none", "single", "double", "rounded", "solid", "shadow"
padding = { 1, 4 }, -- 邊框內的填充(上、右、下、左)
},
win_options = {
winblend = 10, -- 增加透明度,模擬陰影效果
winhighlight = "NormalFloat:NormalFloat,FloatBorder:FloatBorder", -- 高亮設定
},
},
popupmenu = {
border = {
-- noice.nvim 支援以下邊框樣式:
-- * `"none"`:無邊框。
-- * `"single"`:單線邊框。
-- * `"double"`:雙線邊框。
-- * `"rounded"`:圓角邊框。
-- * `"solid"`:實心邊框。
-- * `"shadow"`:陰影效果。
style = "rounded", -- 這裡可以設定不同的樣式
pshadowadding = { 1, 1 }, -- 調整內部填充
},
},
},
})
end,
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = { "regex" }, -- 確保安裝 regex 支援
highlight = {
enable = true, -- 啟用高亮
},
})
end,
}
}

View File

@@ -0,0 +1,77 @@
return {
-- { "psliwka/vim-smoothie" },
{ "karb94/neoscroll.nvim",
cond = function()
-- 如果是在 GUI如 NeoVide、Goneovim則不啟用插件
if vim.g.neovide or vim.fn.has("goneovim") == 1 or vim.fn.has("gui_running") == 1 then
return false
end
-- 獲取 TERM 環境變數
local term = vim.fn.getenv("TERM")
-- 檢查是否是常見的文字終端
local is_terminal = term and (term:match("xterm") or term:match("screen") or term:match("tmux") or term:match("linux"))
-- 如果是文字終端,則啟用插件
return is_terminal ~= nil
end,
opts = {
mappings = { -- Keys to be mapped to their corresponding default scrolling animation
'<C-u>', '<C-d>',
'<C-b>', '<C-f>',
'<C-y>', '<C-e>',
'zt', 'zz', 'zb',
},
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
duration_multiplier = 1.0, -- Global duration multiplier
easing = 'linear', -- Default easing function
pre_hook = nil, -- Function to run before the scrolling animation starts
post_hook = nil, -- Function to run after the scrolling animation ends
performance_mode = false, -- Disable "Performance Mode" on all buffers.
ignored_events = { -- Events ignored while scrolling
'WinScrolled', 'CursorMoved'
},
},
config = function(_, opts)
-- 傳遞 opts 給插件的 setup 函數
require("neoscroll").setup(opts)
-- 增加對<PageUp>與<PageDown>的支持
local scroll_up = function()
require("neoscroll").scroll(-vim.wo.scroll, { move_cursor = true, duration = 100 })
end
local scroll_down = function()
require("neoscroll").scroll(vim.wo.scroll, { move_cursor = true, duration = 100 })
end
-- Normal 模式
vim.keymap.set("n", "<PageUp>", scroll_up, { silent = true })
vim.keymap.set("n", "<PageDown>", scroll_down, { silent = true })
-- Insert 模式
vim.keymap.set("i", "<PageUp>", function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
scroll_up()
vim.api.nvim_feedkeys("i", "n", true)
end, { silent = true })
vim.keymap.set("i", "<PageDown>", function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
scroll_down()
vim.api.nvim_feedkeys("i", "n", true)
end, { silent = true })
end
-- config = function()
-- require("neoscroll").setup({
-- mappings = { "<C-u>", "<C-d>", "<C-b>", "<C-f>", "<C-y>", "<C-e>" },
-- hide_cursor = true, -- Hide cursor while scrolling
-- stop_eof = true, -- Stop at <EOF> when scrolling downwards
-- respect_scrolloff = true, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
-- cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll anymore
-- pre_hook = nil, -- Function to run before the scrolling animation starts
-- post_hook = nil, -- Function to run after the scrolling animation ends
-- })
-- end
}
}

View File

@@ -0,0 +1,157 @@
if true then return {} end -- 先停用
return {
{ "petertriho/nvim-scrollbar",
cond = true,
config = function()
require("scrollbar").setup({
show = true,
show_in_active_only = false,
set_highlights = true,
folds = 1000, -- handle folds, set to number to disable folds if no. of lines in buffer exceeds this
max_lines = false, -- disables if no. of lines in buffer exceeds this
hide_if_all_visible = false, -- Hides everything if all lines are visible
throttle_ms = 100,
handle = {
text = " ",
blend = 30, -- Integer between 0 and 100. 0 for fully opaque and 100 to full transparent. Defaults to 30.
color = nil,
color_nr = nil, -- cterm
highlight = "CursorColumn",
hide_if_all_visible = true, -- Hides handle if all lines are visible
},
marks = {
Cursor = {
text = "",
priority = 0,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "Normal",
},
Search = {
text = { "-", "=" },
priority = 1,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "Search",
},
Error = {
text = { "-", "=" },
priority = 2,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "DiagnosticVirtualTextError",
},
Warn = {
text = { "-", "=" },
priority = 3,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "DiagnosticVirtualTextWarn",
},
Info = {
text = { "-", "=" },
priority = 4,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "DiagnosticVirtualTextInfo",
},
Hint = {
text = { "-", "=" },
priority = 5,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "DiagnosticVirtualTextHint",
},
Misc = {
text = { "-", "=" },
priority = 6,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "Normal",
},
GitAdd = {
text = "",
priority = 7,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "GitSignsAdd",
},
GitChange = {
text = "",
priority = 7,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "GitSignsChange",
},
GitDelete = {
text = "",
priority = 7,
gui = nil,
color = nil,
cterm = nil,
color_nr = nil, -- cterm
highlight = "GitSignsDelete",
},
},
excluded_buftypes = {
"terminal",
},
excluded_filetypes = {
"dropbar_menu",
"dropbar_menu_fzf",
"DressingInput",
"cmp_docs",
"cmp_menu",
"noice",
"prompt",
"TelescopePrompt",
},
autocmd = {
render = {
"BufWinEnter",
"TabEnter",
"TermEnter",
"WinEnter",
"CmdwinLeave",
"TextChanged",
"VimResized",
"WinScrolled",
},
clear = {
"BufWinLeave",
"TabLeave",
"TermLeave",
"WinLeave",
},
},
handlers = {
cursor = true,
diagnostic = true,
gitsigns = false, -- Requires gitsigns
handle = true,
search = false, -- Requires hlslens
ale = false, -- Requires ALE
},
})
end
},
}