添加对字符相关插件

This commit is contained in:
caprain 2026-04-13 16:33:11 +08:00
parent bbc8152ed9
commit 51ee1aebf5
18 changed files with 200 additions and 162 deletions

View file

@ -0,0 +1,22 @@
-- === 对字符自动补全另一半 ===
if vim.g.vscode then return end
local P = {
name = "nvim-autopairs", -- 仓库名
}
-- 懒加载触发器
vim.api.nvim_create_autocmd({
"InsertEnter", "CmdlineEnter", -- 补全/命令行
}, {
callback = function()
PackUtils.load(P, function()
require('nvim-autopairs').setup({
-- 在写markdown时禁用括号补全
disable_filetype = { "markdown" },
-- can use treesitter to check for a pair.
check_ts = true,
})
end)
end
})

View file

@ -3,7 +3,6 @@ if vim.g.vscode then return end
local P = {
name = "blink.cmp",
module = "blink.cmp",
deps = { "friendly-snippets" },
-- build_cmd = "cargo build --release",
}
@ -14,8 +13,8 @@ vim.api.nvim_create_autocmd({ "InsertEnter", "CmdlineEnter", "LspAttach" }, {
once = true,
callback = function()
-- 调用引擎的 load 方法,把 setup 逻辑作为匿名函数传进去
PackUtils.load(P, function(plugin)
plugin.setup({
PackUtils.load(P, function()
require("blink.cmp").setup({
fuzzy = {
prebuilt_binaries = {
force_version = 'v*',

View file

@ -9,7 +9,6 @@ if vim.g.vscode then return end
local P = {
name = "bufferline.nvim",
module = "bufferline",
deps = { "nvim-web-devicons" }, -- 确保图标库先加载
}
@ -17,7 +16,7 @@ local P = {
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
once = true,
callback = function()
PackUtils.load(P, function(plugin)
PackUtils.load(P, function()
-- 在缓冲区之间移动
map:cmd('tn', 'BufferLineCyclePrev')
map:cmd('ti', 'BufferLineCycleNext')
@ -30,7 +29,7 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
map:cmd('tN', 'BufferLineCloseLeft')
map:cmd('tI', 'BufferLineCloseRight')
map:cmd('tQ', 'BufferLineCloseOthers')
plugin.setup({
require("bufferline").setup({
options = {
modified_icon = "",
buffer_close_icon = "×",

View file

@ -2,7 +2,6 @@ if vim.g.vscode then return end
local P = {
name = "code_runner.nvim",
module = "code_runner",
deps = {},
}
@ -27,8 +26,8 @@ for _, entry in ipairs(mappings) do
if vim.bo.modified then vim.cmd("wall") end
-- 只有命令中包含 "RunCode" 时,才加载代码运行器插件
if string.find(entry.cmd, "RunCode") then
PackUtils.load(P, function(plugin)
plugin.setup({
PackUtils.load(P, function()
require("code_runner").setup({
-- project = {
-- ["~/sixsixsix"] = {
-- name = "sixsixsix",

View file

@ -3,7 +3,6 @@ if vim.g.vscode then return end
local P = {
name = "conform.nvim",
module = "conform",
deps = {
"mason.nvim",
"mason-registry",
@ -43,8 +42,8 @@ end
-- 快捷键纯懒加载:只在按下快捷键时激活
vim.keymap.set({ "n", "v" }, "<leader>f", function()
PackUtils.load(P, function(plugin)
plugin.setup({ -- At a minimum, you will need to set up some formatters by filetype
PackUtils.load(P, function()
require("conform").setup({ -- At a minimum, you will need to set up some formatters by filetype
formatters_by_ft = formatters_by_ft
})
end)

View file

@ -2,7 +2,6 @@
local P = {
name = "indent-blankline.nvim", -- 仓库名
module = "ibl", -- require模块名
}
-- 懒加载触发器
@ -11,7 +10,7 @@ vim.api.nvim_create_autocmd({
}, {
callback = function()
vim.schedule(function()
PackUtils.load(P, function(plugin)
PackUtils.load(P, function()
local highlight = {
"RainbowBlue",
"RainbowViolet",
@ -33,7 +32,7 @@ vim.api.nvim_create_autocmd({
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
end)
plugin.setup({
require("ibl").setup({
indent = { highlight = highlight }
})
end)

View file

@ -13,7 +13,6 @@ end
-- 2. 插件配置清单
local P = {
name = "nvim-lspconfig",
module = "lspconfig",
deps = { "mason.nvim", "mason-lspconfig.nvim", "inlay-hints.nvim" },
}

38
lua/pack/configs/mini.lua Normal file
View file

@ -0,0 +1,38 @@
-- === mini ===
local P = {
name = "mini.nvim", -- 仓库名
}
-- 懒加载触发器
vim.api.nvim_create_autocmd({
"UIEnter", -- vim.schedule(function()
}, {
callback = function()
vim.schedule(function()
PackUtils.load(P, function()
require('mini.surround').setup {
mappings = {
add = 's', -- Add surrounding
delete = 'sd', -- Delete surrounding
find = 'sf', -- Find surrounding (to the right)
find_left = 'sF', -- Find surrounding (to the left)
highlight = 'sh', -- Highlight surrounding
replace = 'cs', -- Replace surrounding/change sround
update_n_lines = 'sn', -- Update `n_lines`
},
}
end)
end)
end
})
-- 懒加载触发器
-- vim.api.nvim_create_autocmd({
-- "InsertEnter", "CmdlineEnter", -- 补全/命令行
-- }, {
-- callback = function()
-- PackUtils.load(P, function()
-- require('mini.pairs').setup {}
-- end)
-- end
-- })

View file

@ -3,17 +3,12 @@ if vim.g.vscode then return end
local P = {
name = "noice.nvim",
module = "noice",
deps = { "nui.nvim" },
}
-- 复刻 "VeryLazy" 策略
vim.api.nvim_create_autocmd("UIEnter", {
callback = function()
-- vim.schedule 的作用是:别卡住界面的渲染,等 UI 画完了、闲下来了,再偷偷加载
vim.schedule(function()
PackUtils.load(P, function(plugin)
plugin.setup({
-- 比其他插件更早启动才能捕获错误、警告等信息,这里不配置懒加载
PackUtils.load(P, function()
require("noice").setup({
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
@ -44,6 +39,3 @@ vim.api.nvim_create_autocmd("UIEnter", {
},
})
end)
end)
end
})

View file

@ -2,8 +2,6 @@ if vim.g.vscode then return end
local P = {
name = "peek.nvim",
module = "peek",
deps = {},
-- 编译命令:需要环境中安装了 deno
build_cmd = { "deno", "task", "--quiet", "build:fast" },
}
@ -12,8 +10,8 @@ PackUtils.setup_listener(P.name, P.build_cmd)
-- 2. 封装加载逻辑
local function load_peek()
PackUtils.load(P, function(plugin)
plugin.setup({
PackUtils.load(P, function()
require("peek").setup({
port = 9000,
app = { "zen", "-private-window" },
-- app = { "firefox-esr", "-private-window" },

View file

@ -3,11 +3,10 @@ if vim.g.vscode then return end
local P = {
name = "snacks.nvim",
module = "snacks",
}
PackUtils.load(P, function(plugin)
plugin.setup({
PackUtils.load(P, function()
require("snacks").setup({
image = {},
lazygit = {},
notifier = {}, -- 替代了folke/noice.nvim插件的rcarriga/nvim-notify依赖

View file

@ -2,7 +2,6 @@ if vim.g.vscode then return end
local P = {
name = "nvim-treesitter",
module = "nvim-treesitter",
build_cmd = ":TSUpdate",
}

View file

@ -3,13 +3,12 @@ if vim.g.vscode then return end
local P = {
name = "tv.nvim", -- 仓库名
module = "tv", -- require模块名
}
local function load_plugin()
PackUtils.load(P, function(plugin)
local h = plugin.handlers
plugin.setup({
PackUtils.load(P, function()
local h = require("tv").handlers
require("tv").setup({
channels = {
["git-files"] = {
handlers = {

View file

@ -9,7 +9,6 @@ vim.o.foldenable = true
local P = {
name = "nvim-ufo", -- 仓库名
module = "ufo", -- require模块名
deps = { "promise-async" },
}
@ -19,7 +18,7 @@ vim.api.nvim_create_autocmd({
}, {
callback = function()
vim.schedule(function()
PackUtils.load(P, function(plugin)
PackUtils.load(P, function()
-- Option 2: nvim lsp as LSP client
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
@ -32,9 +31,9 @@ vim.api.nvim_create_autocmd({
capabilities = capabilities,
})
end
plugin.setup({})
require("ufo").setup({})
-- Option 3: treesitter as a main provider instead
-- plugin.setup({
-- require("ufo").setup({
-- provider_selector = function()
-- return { "treesitter", "indent" }
-- end

View file

@ -11,15 +11,14 @@ vim.g.loaded_netrwPlugin = 1
local P = {
name = "yazi.nvim",
module = "yazi",
deps = { "plenary.nvim" },
}
-- 快捷键触发懒加载
vim.keymap.set({ "n", "v" }, "tt", function()
-- 核心:直接调用引擎,把配置逻辑传进去
PackUtils.load(P, function(plugin)
plugin.setup({
PackUtils.load(P, function()
require("yazi").setup({
open_for_directories = false,
keymaps = { show_help = "<f1>" },
})

View file

@ -28,6 +28,10 @@ local specs = {
"https://github.com/MunifTanjim/nui.nvim",
-- snacks.lua 图片预览、lazygit、lsp_references模糊查找
"https://github.com/folke/snacks.nvim",
-- mini.lua 各种对字符的surround包裹{} [] ''
"https://github.com/echasnovski/mini.nvim",
-- autopairs.lua 对字符自动补全另一半
"https://github.com/windwp/nvim-autopairs",
-- tv.lua 模糊查找television
"https://github.com/alexpasmantier/tv.nvim",
-- coderunner.lua 运行代码
@ -263,20 +267,23 @@ end
-- 全方位防崩加载引擎
function PackUtils.load(P, config_fn)
-- 自动纠错插件名和依赖名
P.name = PackUtils.get_name(P.name)
if P.deps then
for i, dep in ipairs(P.deps) do
P.deps[i] = PackUtils.get_name(dep)
end
end
if PackUtils.disabled_plugins[P.name] then return end
if PackUtils.is_initialized[P.name] then return end
-- 检查插件是否存在于磁盘,如果找不到,说明它正在后台被 vim.pack 异步克隆下载,直接静默退出
if not PackUtils.get_root(P.name) then return end
-- 走到这里,说明插件绝对在硬盘上了,执行常规准备工作
PackUtils.check_health(P.name, P.build_cmd)
-- 强制将主插件挂载到 runtimepath
pcall(vim.cmd.packadd, P.name)
-- 保护依赖加载 (防止 dependencies 里的插件没下载)
if P.deps then
for _, dep in ipairs(P.deps) do
local dep_ok = pcall(vim.cmd.packadd, dep)
@ -286,22 +293,11 @@ function PackUtils.load(P, config_fn)
end
end
-- 保护 require (防止插件文件夹还没下载完)
local req_ok, plugin = pcall(require, P.module)
-- 如果失败,说明插件还没下载好或者路径不对,优雅退出
if not req_ok then
-- 经过上面强制挂载后还是失败,且硬盘上确实有这个文件夹,那绝对是 module 填错了
if PackUtils.get_root(P.name) then
vim.notify("Error: Plugin [" .. P.name .. "] module not found", vim.log.levels.ERROR)
end
return
end
-- 保护 Setup 执行:使用 pcall 包裹传进来的匿名函数,防止 setup 里的参数写错导致崩溃
-- 保护 Setup 执行:自由地 require如有拼写错误这里的 pcall 会完美捕获并报错
if config_fn then
local setup_ok, err = pcall(config_fn, plugin)
local setup_ok, err = pcall(config_fn)
if not setup_ok then
vim.notify("Error: " .. P.name .. " setup failed: " .. tostring(err), vim.log.levels.ERROR)
vim.notify("Error: " .. P.name .. " setup failed: \n" .. tostring(err), vim.log.levels.ERROR)
return
end
end

View file

@ -40,6 +40,10 @@
"rev": "b03fb0f20bc1d43daf558cda981a2be22e73ac42",
"src": "https://github.com/williamboman/mason.nvim"
},
"mini.nvim": {
"rev": "c67822c53e8e282fe863343e88aa0a8ca3534059",
"src": "https://github.com/echasnovski/mini.nvim"
},
"noice.nvim": {
"rev": "7bfd942445fb63089b59f97ca487d605e715f155",
"src": "https://github.com/folke/noice.nvim"
@ -48,6 +52,10 @@
"rev": "de740991c12411b663994b2860f1a4fd0937c130",
"src": "https://github.com/MunifTanjim/nui.nvim"
},
"nvim-autopairs": {
"rev": "59bce2eef357189c3305e25bc6dd2d138c1683f5",
"src": "https://github.com/windwp/nvim-autopairs"
},
"nvim-lspconfig": {
"rev": "bedca8b426b2fee0ccac596d167d71bbe971253f",
"src": "https://github.com/neovim/nvim-lspconfig"

View file

@ -22,18 +22,17 @@
"if vim.g.vscode then return end",
"",
"local P = {",
"\tname = \"${2:<++>}\", -- 仓库名",
"\tmodule = \"${3:<++>}\", -- require模块名",
"\tdeps = { ${4} },",
"\tbuild_cmd = ${5:nil},",
"\tname = \"${2:<++>}\",",
"\tdeps = { ${3} },",
"\tbuild_cmd = ${4:nil},",
"}",
"",
"${6}-- 注册构建监听器",
"${5}-- 注册构建监听器",
"PackUtils.setup_listener(P.name, P.build_cmd)",
"",
"-- 懒加载触发器",
"vim.api.nvim_create_autocmd({",
"\t${7}-- \"InsertEnter\", \"CmdlineEnter\", -- 补全/命令行",
"\t${6}-- \"InsertEnter\", \"CmdlineEnter\", -- 补全/命令行",
"\t-- \"BufReadPost\", \"BufNewFile\", -- 界面/语法类",
"\t-- \"LspAttach\", -- LSP 相关",
"\t-- \"FileType\", -- 确定文件类型",
@ -41,20 +40,16 @@
"\t-- \"UIEnter\", -- vim.schedule(function()",
"}, {",
"\tcallback = function()",
"\t\tPackUtils.load(P, function(plugin)",
"\t\t\tplugin.setup({",
"\t\t\t\t$8",
"\t\t\t})",
"\t\tPackUtils.load(P, function()",
"\t\t\t$7",
"\t\tend)",
"\tend",
"})",
"-- vim.keymap.set({ \"n\", \"v\" }, \"${9:<++>}\", function()",
"-- \tPackUtils.load(P, function(plugin)",
"-- \t\tplugin.setup({",
"-- \t\t\t$10",
"-- \t\t})",
"-- vim.keymap.set({ \"n\", \"v\" }, \"${8:<++>}\", function()",
"-- \tPackUtils.load(P, function()",
"-- \t\t$9",
"-- \tend)",
"-- \tvim.cmd(\"${11:Command}\")",
"-- \tvim.cmd(\"${10:Command}\")",
"-- end, { desc = \"${0:描述}\" })"
],
"description": "Neovim Native Package Loader (Pure Config)"