调整懒加载策略

This commit is contained in:
caprain 2026-04-17 20:42:48 +08:00
parent de992f1ac3
commit ea787c96f7
4 changed files with 30 additions and 28 deletions

View file

@ -105,10 +105,10 @@ vim.api.nvim_create_autocmd("FileType", {
end
-- 版本号匹配
vim.fn.matchadd("LogVersion", [[v\d\+\.\d\+\.\d\+]])
-- \V 表示 "very nomagic",即不使用正则特殊字符,直接匹配字面量
vim.fn.matchadd("LogDownloaded", [[\VDownloaded]])
-- \V 表示 "very nomagic"直接匹配字面量\c 表示不区分大小写,\S* 匹配零个或多个“非空白”字符
vim.fn.matchadd("LogDownloaded", [[\c\S*download\S*]])
vim.fn.matchadd("LogCompiling", [[\VCompiling]])
vim.fn.matchadd("LogFinished", [[\VFinished]])
vim.fn.matchadd("LogFinished", [[\c\S*finish\S*]])
end,
})

View file

@ -6,7 +6,7 @@ local P = {
-- 懒加载触发器
vim.api.nvim_create_autocmd({
"FileType",
"BufReadPost", "BufNewFile" -- 处理普通的文本文件时也能显示基础线条
}, {
callback = function()
PackUtils.load(P, function()
@ -32,7 +32,10 @@ vim.api.nvim_create_autocmd({
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
end)
require("ibl").setup({
indent = { highlight = highlight }
indent = { highlight = highlight },
exclude = {
filetypes = { "dashboard" },
},
})
end)
end

View file

@ -7,31 +7,29 @@ local P = {
-- 懒加载触发器
vim.api.nvim_create_autocmd({
"UIEnter", -- vim.schedule(function()
"FileType"
}, {
callback = function()
vim.schedule(function()
PackUtils.load(P, function()
-- 前往上下文开始处
vim.keymap.set("n", "[c", function()
require("treesitter-context").go_to_context(vim.v.count1)
end, { silent = true })
require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
multiwindow = true, -- 固定多个层级.
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to show for a single context
trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil,
zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
})
end)
PackUtils.load(P, function()
-- 前往上下文开始处
vim.keymap.set("n", "[c", function()
require("treesitter-context").go_to_context(vim.v.count1)
end, { silent = true })
require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
multiwindow = true, -- 固定多个层级.
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to show for a single context
trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil,
zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
})
end)
end
})

View file

@ -20,6 +20,7 @@ local ensure_installed = {
-- 在 FileType 确定时,检查、安装并启动
vim.api.nvim_create_autocmd("FileType", {
pattern = ensure_installed,
group = vim.api.nvim_create_augroup("NativeTreesitter", { clear = true }),
callback = function(args)
local buf = args.buf