Compare commits
No commits in common. "46e72698247274a53bf7c8d313ed3c057ede3550" and "6b1cb2d7943564553940f0195b5bd01ae69a6490" have entirely different histories.
46e7269824
...
6b1cb2d794
@ -6,7 +6,7 @@ This is a personal Neovim configuration targeting **Neovim 0.12+**. It lives at
|
|||||||
|
|
||||||
- **Plugin manager**: Neovim 0.12+ built-in `vim.pack` (not lazy.nvim / packer). Plugins are declared in `lua/pack.lua` via `vim.pack.add({ urls }, { load = false })` and tracked in `nvim-pack-lock.json`.
|
- **Plugin manager**: Neovim 0.12+ built-in `vim.pack` (not lazy.nvim / packer). Plugins are declared in `lua/pack.lua` via `vim.pack.add({ urls }, { load = false })` and tracked in `nvim-pack-lock.json`.
|
||||||
- **Custom lazy-loading**: `lua/lazy.lua` is a ~35-line custom framework (unrelated to lazy.nvim). It provides `load()`, `on_event()`, `on_keys()`, `on_cmd()` and tracks loaded modules in `M._loaded`.
|
- **Custom lazy-loading**: `lua/lazy.lua` is a ~35-line custom framework (unrelated to lazy.nvim). It provides `load()`, `on_event()`, `on_keys()`, `on_cmd()` and tracks loaded modules in `M._loaded`.
|
||||||
- **Mini.nvim monorepo**: Most UI/functionality comes from the single `mini.nvim` package. Its submodules (starter, pick, extra, files, icons, notify, cmdline, completion, snippets, surround, clue, statusline, ai, cursorword, pairs) are configured individually in `lua/pack.lua` or on-demand.
|
- **Mini.nvim monorepo**: Most UI/functionality comes from the single `mini.nvim` package. Its submodules (starter, pick, extra, files, icons, notify, cmdline, completion, snippets, surround, ai, cursorword, pairs) are configured individually in `lua/pack.lua` or on-demand.
|
||||||
|
|
||||||
## File Loading Order
|
## File Loading Order
|
||||||
|
|
||||||
@ -52,15 +52,13 @@ When adding new plugins that should load lazily, use the custom framework in `lu
|
|||||||
|
|
||||||
| Trigger | Plugins / Modules |
|
| Trigger | Plugins / Modules |
|
||||||
|---------------|--------------------------------------|
|
|---------------|--------------------------------------|
|
||||||
| `VimEnter` | treesitter, lsp, icons, clue, statusline |
|
| `VimEnter` | treesitter, lsp, icons |
|
||||||
| `InsertEnter` | completion, snippets, pairs |
|
| `InsertEnter` | completion, snippets, pairs |
|
||||||
| `BufReadPost` | gitsigns, surround, ai, cursorword |
|
| `BufReadPost` | gitsigns, surround, ai, cursorword |
|
||||||
| `BufWritePre` | conform (format-on-save) |
|
| `BufWritePre` | conform (format-on-save) |
|
||||||
| Key press | pick, files, neogit, codediff, grugfar |
|
| Key press | pick, files, neogit, codediff, grugfar |
|
||||||
| Command | ex-colors (`:ExColors`) |
|
| Command | ex-colors (`:ExColors`) |
|
||||||
|
|
||||||
Note: `clue` is set up on `VimEnter` (not via `lazy.on_keys`) because `mini.clue` must register prefix keys itself as buffer-local triggers, which is incompatible with the wrapper-mapping approach. Its buffer triggers are re-asserted on `LspAttach` and inside gitsigns' `on_attach` via `MiniClue.ensure_buf_triggers()`.
|
|
||||||
|
|
||||||
## LSP & Formatting
|
## LSP & Formatting
|
||||||
|
|
||||||
- **LSP servers enabled**: html, cssls, gopls, vtsls, rust_analyzer, lua_ls, taplo, svelte, dartls, kotlin_lsp
|
- **LSP servers enabled**: html, cssls, gopls, vtsls, rust_analyzer, lua_ls, taplo, svelte, dartls, kotlin_lsp
|
||||||
|
|||||||
@ -78,20 +78,16 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
-- 使用 treesitter 的 foldexpr 进行语法感知的代码折叠。
|
-- 使用 treesitter 的 foldexpr 进行语法感知的代码折叠。
|
||||||
-- 在 FileType 事件中按 buffer 设置 window-local 选项:
|
-- 在 FileType 事件中按 buffer 设置 window-local 选项:
|
||||||
-- - window-local(vim.wo)而非全局(vim.o),每个 buffer 独立
|
-- - 仅对有 treesitter parser 的文件类型启用 expr 折叠
|
||||||
-- - 排除非代码 filetype(help/man/qf),保留它们的原生折叠行为
|
-- - window-local(vim.wo)而非全局(vim.o),避免污染 help/man/quickfix 等窗口
|
||||||
|
-- - 每个 buffer 独立设置,分屏与新窗口正确继承
|
||||||
--
|
--
|
||||||
-- foldmethod = "expr" 表示使用表达式(foldexpr)计算折叠范围。
|
-- foldmethod = "expr" 表示使用表达式(foldexpr)计算折叠范围。
|
||||||
-- foldexpr = "v:lua.vim.treesitter.foldexpr()" 是 Neovim 0.10+ 的内置函数,
|
-- foldexpr = "v:lua.vim.treesitter.foldexpr()" 是 Neovim 0.10+ 的内置函数,
|
||||||
-- 基于 treesitter 语法树计算折叠边界。无 parser 时返回 0(不折叠),不会报错。
|
-- 基于 treesitter 语法树计算折叠边界。无 parser 时返回 0(不折叠),不会报错。
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
group = group,
|
group = group,
|
||||||
callback = function(args)
|
callback = function()
|
||||||
-- 跳过非代码 filetype,保留它们的原生折叠行为
|
|
||||||
local excluded = { help = true, man = true, qf = true, terminal = true }
|
|
||||||
if excluded[vim.bo[args.buf].filetype] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
vim.wo.foldmethod = "expr"
|
vim.wo.foldmethod = "expr"
|
||||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||||
end,
|
end,
|
||||||
|
|||||||
184
lua/pack.lua
184
lua/pack.lua
@ -6,18 +6,13 @@
|
|||||||
--
|
--
|
||||||
-- 职责边界:
|
-- 职责边界:
|
||||||
-- - 声明插件安装(vim.pack.add)
|
-- - 声明插件安装(vim.pack.add)
|
||||||
-- - 直接 setup 通用/轻量插件(UI、编辑增强、补全、独立工具)
|
-- - 调度各插件的加载时机(lazy.on_event / lazy.on_keys / lazy.on_cmd)
|
||||||
-- - 功能域插件(git/lsp/pick/files/treesitter/starter)的配置与键位
|
-- - 直接初始化轻量插件(notify、cmdline)
|
||||||
-- 移至 lua/plugins/*.lua,由本文件 require 调度
|
-- - 具体的插件配置和键位移至 lua/plugins/*.lua
|
||||||
--
|
|
||||||
-- 拆分规则:
|
|
||||||
-- - 配置简单(纯 setup 或少量选项)→ 留在本文件
|
|
||||||
-- - 配置复杂(含多键位、自定义函数、交互逻辑)→ 移至 plugins/
|
|
||||||
--
|
--
|
||||||
-- 插件列表:
|
-- 插件列表:
|
||||||
-- mini.nvim - 单体插件集(starter、pick、extra、files、icons、
|
-- mini.nvim - 单体插件集(starter、pick、extra、files、icons、
|
||||||
-- notify、cmdline、completion、snippets、surround、
|
-- notify、cmdline、completion、snippets、surround)
|
||||||
-- clue、statusline)
|
|
||||||
-- friendly-snippets - 社区代码片段集合
|
-- friendly-snippets - 社区代码片段集合
|
||||||
-- nvim-treesitter - 语法树解析与高亮
|
-- nvim-treesitter - 语法树解析与高亮
|
||||||
-- nvim-lspconfig - LSP 客户端配置
|
-- nvim-lspconfig - LSP 客户端配置
|
||||||
@ -61,21 +56,19 @@ vim.pack.add({
|
|||||||
}, { load = false })
|
}, { load = false })
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
-- 功能域插件配置(lua/plugins/*.lua)
|
-- 加载各插件的配置模块(含键位映射)
|
||||||
|
-- 必须在 vim.pack.add 之后,确保插件路径已注册到 runtimepath
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
-- 加载各功能域插件的配置模块(含键位映射与自定义逻辑)。
|
|
||||||
-- 必须在 vim.pack.add 之后,确保插件路径已注册到 runtimepath。
|
|
||||||
require("plugins.git")
|
require("plugins.git")
|
||||||
require("plugins.pick")
|
require("plugins.pick")
|
||||||
require("plugins.files")
|
require("plugins.files")
|
||||||
require("plugins.starter")
|
require("plugins.starter")
|
||||||
|
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
-- UI 层:通知、命令行、图标
|
-- mini.notify — 通知消息(直接初始化)
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 替换默认的 vim.notify,提供美观的浮动通知窗口。
|
||||||
-- mini.notify — 替换默认 vim.notify,提供浮动通知窗口(直接初始化,轻量不阻塞)
|
-- 轻量,不阻塞启动。使用 pcall 保护首次启动。
|
||||||
-- 使用 pcall 保护首次启动(插件可能尚未下载完成)
|
|
||||||
local ok_notify, notify = pcall(require, "mini.notify")
|
local ok_notify, notify = pcall(require, "mini.notify")
|
||||||
if ok_notify then
|
if ok_notify then
|
||||||
notify.setup({
|
notify.setup({
|
||||||
@ -90,8 +83,10 @@ if ok_notify then
|
|||||||
lazy.track("notify")
|
lazy.track("notify")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- mini.cmdline — 增强命令行(首次按 : 时加载)
|
-- mini.cmdline — 增强命令行(首次按 : 时加载)
|
||||||
-- 使用 expr 映射:返回 ":" 让 Vim 继续处理
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 提供美观的命令行界面,使用 expr 映射:返回 ":" 让 Vim 继续处理。
|
||||||
vim.keymap.set("n", ":", function()
|
vim.keymap.set("n", ":", function()
|
||||||
-- 首次按下 : 时删除此映射,避免后续重复触发
|
-- 首次按下 : 时删除此映射,避免后续重复触发
|
||||||
vim.keymap.del("n", ":")
|
vim.keymap.del("n", ":")
|
||||||
@ -102,75 +97,42 @@ vim.keymap.set("n", ":", function()
|
|||||||
return ":"
|
return ":"
|
||||||
end, { expr = true, noremap = true })
|
end, { expr = true, noremap = true })
|
||||||
|
|
||||||
-- mini.icons — 文件类型图标(VimEnter 后延迟加载)
|
-- ---------------------------------------------------------------------------
|
||||||
-- 供 mini.pick、mini.files、mini.statusline 等使用
|
-- mini.icons — 图标支持(VimEnter 后延迟加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 提供文件类型图标,供 mini.pick、mini.files 等使用。
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
require("mini.icons").setup()
|
require("mini.icons").setup()
|
||||||
lazy.track("icons")
|
lazy.track("icons")
|
||||||
|
|
||||||
-- mini.statusline — 状态栏(依赖 mini.icons,故同处 VimEnter)
|
|
||||||
-- 最简配置:用内置 section 组合,自适应窗口宽度。
|
|
||||||
-- Git/diff 段回退到 gitsigns.nvim(已启用),无需 mini.git/mini.diff。
|
|
||||||
require("mini.statusline").setup({ use_icons = true })
|
|
||||||
|
|
||||||
-- 覆盖 section_git / section_diff / section_lsp 返回空串隐藏它们:
|
|
||||||
-- - section_git/diff:默认读 gitsigns buffer 变量显示分支和增删改数
|
|
||||||
-- - section_lsp:默认显示 ' +',加号数量 = attach 的 LSP client 数
|
|
||||||
-- combine_groups 会自动跳过空段,不留多余空格。
|
|
||||||
require("mini.statusline").section_git = function()
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
require("mini.statusline").section_diff = function()
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
require("mini.statusline").section_lsp = function()
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 覆盖 section_filename:原逻辑宽窗口返回 %F(绝对路径),
|
|
||||||
-- 这里改为宽窗口也用 %f(相对路径)。窄窗口降级到 %t(仅文件名)。
|
|
||||||
require("mini.statusline").section_filename = function(args)
|
|
||||||
local ms = require("mini.statusline")
|
|
||||||
if vim.bo.buftype == "terminal" or ms.is_truncated(args.trunc_width) then
|
|
||||||
return "%t%m%r"
|
|
||||||
end
|
|
||||||
return "%f%m%r"
|
|
||||||
end
|
|
||||||
lazy.track("statusline")
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
-- 编辑增强:括号配对、textobject、光标高亮、环绕操作
|
|
||||||
-- =============================================================================
|
|
||||||
|
|
||||||
-- mini.pairs — 自动括号配对(InsertEnter 懒加载)
|
-- mini.pairs — 自动括号配对(InsertEnter 懒加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
lazy.on_event("pairs", "InsertEnter", "*", function()
|
lazy.on_event("pairs", "InsertEnter", "*", function()
|
||||||
require("mini.pairs").setup()
|
require("mini.pairs").setup()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- mini.ai — 扩展 a/i textobject(BufReadPost 懒加载)
|
-- mini.ai — 扩展 a/i textobject(BufReadPost 懒加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
lazy.on_event("ai", "BufReadPost", "*", function()
|
lazy.on_event("ai", "BufReadPost", "*", function()
|
||||||
require("mini.ai").setup()
|
require("mini.ai").setup()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- mini.cursorword — 自动高亮光标下单词(BufReadPost 懒加载)
|
-- mini.cursorword — 自动高亮光标下单词(BufReadPost 懒加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
lazy.on_event("cursorword", "BufReadPost", "*", function()
|
lazy.on_event("cursorword", "BufReadPost", "*", function()
|
||||||
require("mini.cursorword").setup()
|
require("mini.cursorword").setup()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- mini.surround — 环绕文本操作(BufReadPost 懒加载)
|
-- ---------------------------------------------------------------------------
|
||||||
lazy.on_event("surround", "BufReadPost", "*", function()
|
-- mini.completion — 自动补全(InsertEnter 懒加载)
|
||||||
require("mini.surround").setup()
|
-- ---------------------------------------------------------------------------
|
||||||
end)
|
|
||||||
|
|
||||||
-- =============================================================================
|
|
||||||
-- 补全与代码片段(InsertEnter 懒加载)
|
|
||||||
-- =============================================================================
|
|
||||||
|
|
||||||
-- mini.completion — 自动补全引擎(LSP + Buffer)
|
|
||||||
lazy.on_event("completion", "InsertEnter", "*", function()
|
lazy.on_event("completion", "InsertEnter", "*", function()
|
||||||
require("mini.completion").setup({
|
require("mini.completion").setup({
|
||||||
lsp_completion = {
|
lsp_completion = {
|
||||||
@ -179,7 +141,9 @@ lazy.on_event("completion", "InsertEnter", "*", function()
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- mini.snippets — 代码片段引擎
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- mini.snippets — 代码片段(InsertEnter 懒加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
lazy.on_event("snippets", "InsertEnter", "*", function()
|
lazy.on_event("snippets", "InsertEnter", "*", function()
|
||||||
local MiniSnippets = require("mini.snippets")
|
local MiniSnippets = require("mini.snippets")
|
||||||
MiniSnippets.setup({
|
MiniSnippets.setup({
|
||||||
@ -190,9 +154,16 @@ lazy.on_event("snippets", "InsertEnter", "*", function()
|
|||||||
MiniSnippets.start_lsp_server({ match = false })
|
MiniSnippets.start_lsp_server({ match = false })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
-- 重型模块(VimEnter 延迟加载)
|
-- mini.surround — 环绕文本操作(BufReadPost 懒加载)
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
|
lazy.on_event("surround", "BufReadPost", "*", function()
|
||||||
|
require("mini.surround").setup()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 重型模块延迟加载(VimEnter 事件)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- treesitter 和 lsp 是启动时最耗时的模块,
|
-- treesitter 和 lsp 是启动时最耗时的模块,
|
||||||
-- 延迟到 VimEnter 事件触发后加载,让编辑器界面先渲染出来。
|
-- 延迟到 VimEnter 事件触发后加载,让编辑器界面先渲染出来。
|
||||||
lazy.on_event("treesitter", "VimEnter", "*", function()
|
lazy.on_event("treesitter", "VimEnter", "*", function()
|
||||||
@ -203,77 +174,10 @@ lazy.on_event("lsp", "VimEnter", "*", function()
|
|||||||
require("plugins.lsp")
|
require("plugins.lsp")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- =============================================================================
|
-- ---------------------------------------------------------------------------
|
||||||
-- mini.clue — 按键提示浮窗(VimEnter 后 setup)
|
|
||||||
-- =============================================================================
|
|
||||||
-- 按下前缀键(<Leader>/g/z/<C-w>/[/])后弹出浮窗,列出后续可用键及描述。
|
|
||||||
-- 类 which-key 但更轻量,且独立于 'timeoutlen'。
|
|
||||||
--
|
|
||||||
-- 不走 lazy.on_keys 懒加载:mini.clue 需自己把前缀键注册为 buffer-local
|
|
||||||
-- 触发器,与 on_keys 的"包装映射"机制互斥;且 setup 成本极低,无懒加载收益。
|
|
||||||
--
|
|
||||||
-- 时序要点(来自官方文档):触发器必须是 buffer 中最后创建的 buffer-local
|
|
||||||
-- 映射,否则会被后续 LSP/gitsigns 等的 buffer-local 映射"压住"而失灵。
|
|
||||||
-- 这里通过 VimEnter 延迟 setup(此时全局映射已全部就位),
|
|
||||||
-- 并在 LspAttach 中调用 ensure_buf_triggers 兜底。
|
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
|
||||||
once = true,
|
|
||||||
callback = function()
|
|
||||||
local ok_clue, miniclue = pcall(require, "mini.clue")
|
|
||||||
if not ok_clue then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
miniclue.setup({
|
|
||||||
triggers = {
|
|
||||||
{ mode = { "n", "x" }, keys = "<Leader>" },
|
|
||||||
{ mode = { "n", "x" }, keys = "g" },
|
|
||||||
{ mode = { "n", "x" }, keys = "z" },
|
|
||||||
{ mode = "n", keys = "<C-w>" },
|
|
||||||
{ mode = "n", keys = "[" },
|
|
||||||
{ mode = "n", keys = "]" },
|
|
||||||
},
|
|
||||||
clues = {
|
|
||||||
-- 内置前缀键描述生成器(g/z/窗口/方括号跳转)
|
|
||||||
miniclue.gen_clues.g(),
|
|
||||||
miniclue.gen_clues.z(),
|
|
||||||
miniclue.gen_clues.windows(),
|
|
||||||
miniclue.gen_clues.square_brackets(),
|
|
||||||
|
|
||||||
-- <Leader> 分组描述(与 keymaps.lua / plugins/*.lua 中的映射对齐)
|
|
||||||
{ mode = "n", keys = "<Leader>f", desc = "+文件" },
|
|
||||||
{ mode = "n", keys = "<Leader>g", desc = "+Git" },
|
|
||||||
{ mode = "n", keys = "<Leader>b", desc = "+Buffer" },
|
|
||||||
{ mode = "n", keys = "<Leader>c", desc = "+代码" },
|
|
||||||
{ mode = "n", keys = "<Leader>d", desc = "+诊断" },
|
|
||||||
{ mode = "n", keys = "<Leader>s", desc = "+搜索" },
|
|
||||||
{ mode = "n", keys = "<Leader>t", desc = "+标签/终端" },
|
|
||||||
{ mode = "n", keys = "<Leader>u", desc = "+用户" },
|
|
||||||
{ mode = "n", keys = "<Leader>y", desc = "+复制" },
|
|
||||||
},
|
|
||||||
window = {
|
|
||||||
delay = 300, -- 默认 1000ms 太慢,300ms 接近 which-key 体验
|
|
||||||
config = { border = "rounded" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- LSP attach 后重新确保触发器排在最后(LSP 可能创建 buffer-local 映射)
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
|
||||||
callback = function()
|
|
||||||
pcall(miniclue.ensure_buf_triggers)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
lazy.track("clue")
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- =============================================================================
|
|
||||||
-- 独立工具(按键/命令触发懒加载)
|
|
||||||
-- =============================================================================
|
|
||||||
|
|
||||||
-- grug-far.nvim — 搜索与替换(按键触发懒加载)
|
-- grug-far.nvim — 搜索与替换(按键触发懒加载)
|
||||||
-- 提供类似 VS Code 的查找替换界面,支持正则和文件过滤
|
-- ---------------------------------------------------------------------------
|
||||||
|
-- 提供类似 VS Code 的查找替换界面,支持正则和文件过滤。
|
||||||
local function load_grug_far()
|
local function load_grug_far()
|
||||||
vim.cmd.packadd("grug-far.nvim")
|
vim.cmd.packadd("grug-far.nvim")
|
||||||
require("grug-far").setup({ headerMaxWidth = 80 })
|
require("grug-far").setup({ headerMaxWidth = 80 })
|
||||||
@ -297,7 +201,9 @@ end
|
|||||||
-- Normal 和 Visual 模式共用同一个映射,通过 mode 表一次性注册
|
-- Normal 和 Visual 模式共用同一个映射,通过 mode 表一次性注册
|
||||||
lazy.on_keys("grugfar", "<leader>sr", { "n", "x" }, load_grug_far, open_grug_far, { desc = "搜索并替换" })
|
lazy.on_keys("grugfar", "<leader>sr", { "n", "x" }, load_grug_far, open_grug_far, { desc = "搜索并替换" })
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- ex-colors.nvim — colorscheme 提取与优化(命令触发懒加载)
|
-- ex-colors.nvim — colorscheme 提取与优化(命令触发懒加载)
|
||||||
|
-- ---------------------------------------------------------------------------
|
||||||
-- 仅在执行 :ExColors 时加载,不占用启动时间。
|
-- 仅在执行 :ExColors 时加载,不占用启动时间。
|
||||||
-- 生成的文件保存在 ~/.config/nvim/colors/ex-{colors_name}.lua
|
-- 生成的文件保存在 ~/.config/nvim/colors/ex-{colors_name}.lua
|
||||||
lazy.on_cmd("ex-colors", "ExColors", function()
|
lazy.on_cmd("ex-colors", "ExColors", function()
|
||||||
|
|||||||
@ -87,13 +87,6 @@ local function load_gitsigns()
|
|||||||
end, "Diff This ~")
|
end, "Diff This ~")
|
||||||
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "Gitsigns Select Hunk")
|
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "Gitsigns Select Hunk")
|
||||||
-- stylua: ignore end
|
-- stylua: ignore end
|
||||||
|
|
||||||
-- gitsigns 创建的 buffer-local 映射可能"压住" mini.clue 触发器,
|
|
||||||
-- 这里重新确保触发器排在最后(mini.clue 未加载时静默跳过)。
|
|
||||||
local ok_clue, miniclue = pcall(require, "mini.clue")
|
|
||||||
if ok_clue and miniclue.ensure_buf_triggers then
|
|
||||||
miniclue.ensure_buf_triggers()
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@ -136,23 +136,13 @@ end, { desc = "Buffer 列表" })
|
|||||||
-- 显示所有可用的文件类型列表,选择后设置当前 buffer 的 filetype。
|
-- 显示所有可用的文件类型列表,选择后设置当前 buffer 的 filetype。
|
||||||
lazy.on_keys("pick", "<leader>ft", "n", M.load_pick, function()
|
lazy.on_keys("pick", "<leader>ft", "n", M.load_pick, function()
|
||||||
local MiniPick = require("mini.pick")
|
local MiniPick = require("mini.pick")
|
||||||
-- mini.pick 会把 item 规范化后再传给 choose,不能直接用原始字符串。
|
|
||||||
-- 这里显式构造 { text = ft } 形态的 item,choose 中取 .text 拿到 filetype 字符串。
|
|
||||||
local filetypes = vim.fn.getcompletion("", "filetype")
|
local filetypes = vim.fn.getcompletion("", "filetype")
|
||||||
local items = vim.tbl_map(function(ft)
|
|
||||||
return { text = ft }
|
|
||||||
end, filetypes)
|
|
||||||
MiniPick.start({
|
MiniPick.start({
|
||||||
source = {
|
source = {
|
||||||
name = "Filetypes",
|
name = "Filetypes",
|
||||||
items = items,
|
items = filetypes,
|
||||||
choose = function(item)
|
choose = function(item)
|
||||||
-- choose 执行时 picker 浮窗仍是当前窗口,vim.bo 默认作用于 picker 自己的 buffer。
|
vim.bo.filetype = item
|
||||||
-- 必须用 picker_state.windows.target 拿到用户原本的窗口,在其 buffer 上设 filetype。
|
|
||||||
local state = MiniPick.get_picker_state()
|
|
||||||
local win = state and state.windows and state.windows.target
|
|
||||||
local target_buf = win and vim.api.nvim_win_get_buf(win) or 0
|
|
||||||
vim.bo[target_buf].filetype = item.text
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -116,10 +116,7 @@ local all_modules = {
|
|||||||
"notify",
|
"notify",
|
||||||
"cmdline",
|
"cmdline",
|
||||||
"icons",
|
"icons",
|
||||||
"clue",
|
|
||||||
"statusline",
|
|
||||||
"pick",
|
"pick",
|
||||||
"extra",
|
|
||||||
"files",
|
"files",
|
||||||
"surround",
|
"surround",
|
||||||
"completion",
|
"completion",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user