I just figured out cmp-nvim-lsp is causing some lags / delay when closing telescope or some UI components.
I tried to disable all of my plugins, and the only one I need to disable for the lags to disappear is cmp-nvim-lsp. So with all of my plugins except cmp-nvim-lsp I have no lags / delay.
NVIM v0.9.0-dev-620+g19591e991
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
local cmp = require("cmp")
if not cmp then
return
end
local luasnip = require("luasnip")
if not luasnip then
return
end
local lspkind = require("lspkind")
if not lspkind then
return
end
local luasnip_vscode_loader = require("luasnip/loaders/from_vscode")
if not luasnip_vscode_loader then
return
end
luasnip_vscode_loader.lazy_load()
local check_backspace = function()
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
cmp.setup({
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.recently_used,
require("clangd_extensions.cmp_scores"),
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable,
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = lspkind.cmp_format({
mode = "symbol", -- show only symbol annotations
maxwidth = 50,
before = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
}),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
experimental = {
ghost_text = false,
native_menu = false,
},
})
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
local fn = vim.fn
-- Automatically install packer
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
--luacheck: ignore PACKER_BOOTSTRAP
PACKER_BOOTSTRAP = fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
print("Installing packer close and reopen Neovim...")
vim.cmd([[packadd packer.nvim]])
end
-- Autocommand that reloads neovim whenever you save the packer.lua file
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost packer.lua source <afile> | PackerSync
augroup end
]])
local packer = require("packer")
-- Have packer use a popup window
packer.init({
display = {
open_fn = function()
return require("packer.util").float({ border = "rounded" })
end,
},
})
return packer.startup(function(use)
-- Package manager
use("wbthomason/packer.nvim")
-- Performance
use("lewis6991/impatient.nvim")
-- Lsp & Dap Managers
use("williamboman/mason.nvim")
use({ "jayp0521/mason-nvim-dap.nvim" })
use("williamboman/mason-lspconfig.nvim")
-- Colorscheme
use({ "catppuccin/nvim", as = "catppuccin" })
-- File explorer
use({ "kyazdani42/nvim-tree.lua", requires = { { "kyazdani42/nvim-web-devicons" } }, tag = "nightly" })
-- Buffer and status lines
use({ "nvim-lualine/lualine.nvim", requires = { { "nvim-tree/nvim-web-devicons" } } })
-- Fidget
use("j-hui/fidget.nvim")
use({
"utilyre/barbecue.nvim",
branch = "dev", -- omit this if you only want stable updates ]]
requires = {
"neovim/nvim-lspconfig",
"smiteshp/nvim-navic",
"nvim-tree/nvim-web-devicons", -- optional dependency
},
after = { "catppuccin", "nvim-web-devicons" }, -- keep this if you're using NvChad
})
-- Treesitter
use({
"nvim-treesitter/nvim-treesitter",
requires = {
{ "windwp/nvim-ts-autotag" },
{ "nvim-treesitter/nvim-treesitter-textobjects" },
{ "p00f/nvim-ts-rainbow" },
},
run = ":TSUpdate",
})
-- Telescope
use({ "nvim-telescope/telescope.nvim", requires = { { "nvim-lua/plenary.nvim" } } })
use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" })
-- UI
use("stevearc/dressing.nvim")
--Formatter
use("jayp0521/mason-null-ls.nvim")
use("jose-elias-alvarez/null-ls.nvim")
use({
"ThePrimeagen/refactoring.nvim",
requires = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" },
},
ft = { "lua", "python " },
})
-- Easy jump
use({ "phaazon/hop.nvim", branch = "v2" })
-- Http client
use({ "rest-nvim/rest.nvim", requires = { { "nvim-lua/plenary.nvim" } } })
-- Terminal toggle
use({ "akinsho/toggleterm.nvim", tag = "*" })
-- Auto close pairs
use("windwp/nvim-autopairs")
-- Surround
use("kylechui/nvim-surround")
-- Comments
use("numToStr/Comment.nvim")
use("JoosepAlviste/nvim-ts-context-commentstring")
-- Debugger
use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } })
use("theHamsta/nvim-dap-virtual-text")
-- Rust tools
use({
"simrat39/rust-tools.nvim",
requires = { { "nvim-lua/plenary.nvim" } },
})
-- Python
use({ "luk400/vim-jukit" })
-- Clang extensions
use("p00f/clangd_extensions.nvim")
-- Git
use("lewis6991/gitsigns.nvim")
use("sindrets/diffview.nvim")
use("tpope/vim-fugitive")
-- Completion
use("hrsh7th/nvim-cmp")
use("hrsh7th/cmp-buffer")
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-cmdline")
use("saadparwaiz1/cmp_luasnip")
use("hrsh7th/cmp-nvim-lsp")
use("hrsh7th/cmp-nvim-lua")
use("rafamadriz/friendly-snippets")
use({ "L3MON4D3/LuaSnip", tag = "v1.*" })
use("onsails/lspkind.nvim")
-- LSP
use({
"ray-x/lsp_signature.nvim",
})
use("neovim/nvim-lspconfig")
use({ "b0o/schemastore.nvim", ft = { "json" } })
use("jose-elias-alvarez/typescript.nvim")
use("lvimuser/lsp-inlayhints.nvim")
-- Utils
use("lukas-reineke/indent-blankline.nvim")
use("abecodes/tabout.nvim")
use("max397574/better-escape.nvim")
use({ "ellisonleao/glow.nvim", ft = { "md" } })
use("sitiom/nvim-numbertoggle")
use("rcarriga/nvim-notify")
use("ethanholz/nvim-lastplace")
use("dstein64/vim-startuptime")
use("chrisbra/Colorizer")
-- Screenshot
use({ "krivahtoo/silicon.nvim", run = "./install.sh build" })
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)
I don't know how to provide more usefull logs / trace but if you tell me I'll try to.