Move LSP config from lazy.on_event to direct execution

init.lua now requires lsp.lua on VimEnter, so the file no longer
needs its own lazy.on_event wrapper. This simplifies the code and
keeps the delay-loading decision in one place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-28 14:44:07 +08:00
parent 5d40b6c245
commit 7f754cd8ba

View File

@ -43,8 +43,8 @@ lazy.on_event("conform", "BufWritePre", "*", function()
end end
end) end)
-- mason + LSP 配置延迟到 VimEnter避免启动时加载 -- mason + LSP 配置
lazy.on_event("lsp", "VimEnter", "*", function() -- 由 init.lua 在 VimEnter 时 require此处直接执行
vim.cmd.packadd("nvim-lspconfig") vim.cmd.packadd("nvim-lspconfig")
require("mason").setup() require("mason").setup()
@ -73,7 +73,6 @@ lazy.on_event("lsp", "VimEnter", "*", function()
"dartls", "dartls",
"kotlin_lsp", "kotlin_lsp",
}) })
end)
-- LSP keymaps用 function 包装延迟 vim.lsp/vim.diagnostic 模块加载) -- LSP keymaps用 function 包装延迟 vim.lsp/vim.diagnostic 模块加载)
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, { desc = "Go to definition" }) vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, { desc = "Go to definition" })