fix(pack): install missing plugins asynchronously without startup updates

This commit is contained in:
2026-05-30 16:18:17 +08:00
parent fb057c44f0
commit 8b1b23ff8f
2 changed files with 100 additions and 28 deletions
+32 -25
View File
@@ -1,16 +1,39 @@
local M = {}
function M.setup()
local ok_configs, ts_configs = pcall(require, "nvim-treesitter.configs")
if not ok_configs then
local ok_ts, ts = pcall(require, "nvim-treesitter")
if not ok_ts then
vim.schedule(function()
vim.notify("nvim-treesitter is not available yet. Run :lua vim.pack.update() and restart.",
vim.notify("nvim-treesitter is not ready yet. Wait for background plugin install and restart Neovim.",
vim.log.levels.WARN)
end)
return
end
ts_configs.setup({
local move_config = {
goto_next_start = {
["]f"] = "@function.outer",
["]c"] = "@class.outer",
["]a"] = "@parameter.inner",
},
goto_next_end = {
["]F"] = "@function.outer",
["]C"] = "@class.outer",
["]A"] = "@parameter.inner",
},
goto_previous_start = {
["[f"] = "@function.outer",
["[c"] = "@class.outer",
["[a"] = "@parameter.inner",
},
goto_previous_end = {
["[F"] = "@function.outer",
["[C"] = "@class.outer",
["[A"] = "@parameter.inner",
},
}
ts.setup({
ensure_installed = {
"bash",
"c",
@@ -51,26 +74,10 @@ function M.setup()
textobjects = {
move = {
enable = true,
goto_next_start = {
["]f"] = "@function.outer",
["]c"] = "@class.outer",
["]a"] = "@parameter.inner",
},
goto_next_end = {
["]F"] = "@function.outer",
["]C"] = "@class.outer",
["]A"] = "@parameter.inner",
},
goto_previous_start = {
["[f"] = "@function.outer",
["[c"] = "@class.outer",
["[a"] = "@parameter.inner",
},
goto_previous_end = {
["[F"] = "@function.outer",
["[C"] = "@class.outer",
["[A"] = "@parameter.inner",
},
goto_next_start = move_config.goto_next_start,
goto_next_end = move_config.goto_next_end,
goto_previous_start = move_config.goto_previous_start,
goto_previous_end = move_config.goto_previous_end,
},
},
})
@@ -84,7 +91,7 @@ function M.setup()
if name:find("goto") == 1 then
move[name] = function(query, ...)
if vim.wo.diff then
local config = ts_configs.get_module("textobjects.move")[name]
local config = move_config[name]
for key, textobject in pairs(config or {}) do
if query == textobject and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)