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

@ -40,6 +40,9 @@ return {
},
lsp = {
capabilities = require("cmp_nvim_lsp").default_capabilities(),
on_attach = function(client, bufnr)
client.server_capabilities.semanticTokensProvider = nil
end,
settings = {
showTodos = true,
completeFunctionCalls = true,

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" },
}),
})

View file

@ -14,7 +14,21 @@ return {
{
'windwp/nvim-autopairs',
event = "InsertEnter",
config = true
config = function()
local autopairs = require("nvim-autopairs")
autopairs.setup({
check_ts = true,
ts_config = {
lua = { "string" },
dart = { "string_literal" }
}
})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local pcall_cmp, cmp = pcall(require, "cmp")
if pcall_cmp then
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end
end
},
}

View file

@ -13,6 +13,13 @@ return {
ts.setup({
install_dir = vim.fn.stdpath("data") .. "/site",
auto_install = true,
highlight = {
enable = true,
},
indent = {
enable = true,
disable = { "dart" },
},
})
-- 2. Bulk Install Parsers (Asynchronous)
ts.install(supported_languages)