nvim/lua/treesitter.lua
xfy 077ec08dc1 Add lazy loading for all plugins
- Create lua/lazy.lua helper with load/on_event/on_keys
- Rewrite pack.lua: lazy load all mini modules + fugitive
- Defer treesitter.install() with vim.defer_fn
- Defer mason + LSP config to VimEnter
- Move mini.pick keymaps from keymaps.lua to pack.lua
- Keep mini.notify and mini.cmdline eager (startup needed)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 11:04:08 +08:00

53 lines
953 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local treesitter = require("nvim-treesitter")
local ensure_installed = {
"lua",
"vim",
"vimdoc",
-- Web
"javascript",
"typescript",
"tsx",
"jsdoc",
"json",
"html",
"css",
"yaml",
-- Backend
"c",
"rust",
"toml",
"go",
"gomod",
"gosum",
"gowork",
-- Infra
"dockerfile",
"make",
}
-- 延迟安装 parser避免启动时阻塞
vim.defer_fn(function()
treesitter.install(ensure_installed)
end, 100)
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
callback = function(args)
local buf = args.buf
local ft = vim.bo[buf].filetype
local lang = vim.treesitter.language.get_lang(ft)
if not lang then
return
end
local ok_add = pcall(vim.treesitter.language.add, lang)
if not ok_add then
return
end
pcall(vim.treesitter.start, buf, lang)
end,
})