fix lag with dart lsp

This commit is contained in:
yaso 2026-06-26 12:50:23 +02:00
parent 9297612e84
commit 8b5c66896f
7 changed files with 75 additions and 6 deletions

View file

@ -107,7 +107,16 @@ return {
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback()
end
fallback()
end,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = true })
@ -117,10 +126,18 @@ return {
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
{ name = "nvim_lsp", keyword_length = 1 },
{ name = "luasnip", keyword_length = 1 },
{
name = "buffer",
keyword_length = 2,
-- Limit indexing to only the active visible buffer to stop lag on Enter
option = {
get_bufnrs = function()
return { vim.api.nvim_get_current_buf() }
end
}
}, -- Triggers after typing 2 characters of a local word
{ name = "path" },
}),
})