From 498dcaef944ce235ebff08c5259f3b2e393eab1f Mon Sep 17 00:00:00 2001 From: jdhao Date: Tue, 19 Oct 2021 01:14:21 +0800 Subject: [PATCH] update cmp lazy load condition If we use InsertEnter, cmp may not be activated the first time we go to insert mode. I have to go to insert mode a second time to activate auto-completion, which is annoying. --- lua/plugins.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index b646632..b4e3517 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -26,14 +26,15 @@ require("packer").startup({ function(use) use({"wbthomason/packer.nvim", opt = true}) - -- nvim-lsp configuration - use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] }) - -- auto-completion engine - use {"hrsh7th/nvim-cmp", event = "InsertEnter", config = [[require('config.nvim-cmp')]]} + use {"hrsh7th/nvim-cmp", event = "BufEnter", config = [[require('config.nvim-cmp')]]} -- nvim-cmp completion sources - use {"hrsh7th/cmp-nvim-lsp", event = "VimEnter"} + use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"} + + -- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp). + use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] }) + use {"hrsh7th/cmp-path", after = "nvim-cmp"} use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}} use {"hrsh7th/cmp-emoji", after = 'nvim-cmp'}