From 2fedf661e7f5db3abc826dff89da6de038261c62 Mon Sep 17 00:00:00 2001
From: SinTan1729 <sayantan.santra689@gmail.com>
Date: Sat, 23 Mar 2024 03:36:19 -0500
Subject: [PATCH] chg: Properly lazyload nvim-cmp related plugins

---
 laptop/plugins.lua | 17 +++++++++++------
 server/plugins.lua | 15 ++++++++++-----
 vps/plugins.lua    | 15 ++++++++++-----
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/laptop/plugins.lua b/laptop/plugins.lua
index 40d6149..f5a3592 100644
--- a/laptop/plugins.lua
+++ b/laptop/plugins.lua
@@ -28,12 +28,17 @@ require("lazy").setup({
     -- LSP related plugins
     "neovim/nvim-lspconfig",
     "nvim-lua/plenary.nvim",
-    "hrsh7th/nvim-cmp", -- For LSP completion
-    "hrsh7th/cmp-nvim-lsp",
-    "hrsh7th/cmp-buffer",
-    "hrsh7th/cmp-omni", -- For LaTeX completion
-    "hrsh7th/cmp-path",
-    "hrsh7th/cmp-cmdline",
+    {
+        "hrsh7th/nvim-cmp", -- For LSP completion
+        event = "InsertEnter",
+        dependencies = {
+            "hrsh7th/cmp-nvim-lsp",
+            "hrsh7th/cmp-buffer",
+            "hrsh7th/cmp-omni", -- For LaTeX completion
+            "hrsh7th/cmp-path",
+            "hrsh7th/cmp-cmdline",
+        }
+    },
     "SirVer/ultisnips", -- For snippets
     -- Support programming terms
     { "psliwka/vim-dirtytalk",     build = ":DirtytalkUpdate" },
diff --git a/server/plugins.lua b/server/plugins.lua
index 8ac36d3..ca0672e 100644
--- a/server/plugins.lua
+++ b/server/plugins.lua
@@ -25,11 +25,16 @@ require("lazy").setup({
     "sitiom/nvim-numbertoggle",
     -- LSP related plugins
     "neovim/nvim-lspconfig",
-    "hrsh7th/nvim-cmp",         -- For LSP completion
-    "hrsh7th/cmp-nvim-lsp",
-    "hrsh7th/cmp-cmdline",
-    "hrsh7th/cmp-buffer",
-    "hrsh7th/cmp-path",
+    {
+        "hrsh7th/nvim-cmp",         -- For LSP completion
+        event = "InsertEnter",
+        dependencies = {
+            "hrsh7th/cmp-nvim-lsp",
+            "hrsh7th/cmp-cmdline",
+            "hrsh7th/cmp-buffer",
+            "hrsh7th/cmp-path",
+        }
+    },
     -- Support programming terms
     { "psliwka/vim-dirtytalk", build = ":DirtytalkUpdate" },
     -- vim-moonfly theme
diff --git a/vps/plugins.lua b/vps/plugins.lua
index 3ba8857..8229338 100644
--- a/vps/plugins.lua
+++ b/vps/plugins.lua
@@ -25,11 +25,16 @@ require("lazy").setup({
     "sitiom/nvim-numbertoggle",
     -- LSP related plugins
     "neovim/nvim-lspconfig",
-    "hrsh7th/nvim-cmp",         -- For LSP completion
-    "hrsh7th/cmp-nvim-lsp",
-    "hrsh7th/cmp-buffer",
-    "hrsh7th/cmp-path",
-    "hrsh7th/cmp-cmdline",
+    {
+        "hrsh7th/nvim-cmp",         -- For LSP completion
+        event = "InsertLeave",
+        dependencies = {
+            "hrsh7th/cmp-nvim-lsp",
+            "hrsh7th/cmp-buffer",
+            "hrsh7th/cmp-path",
+            "hrsh7th/cmp-cmdline",
+        }
+    },
     -- Support programming terms
     { "psliwka/vim-dirtytalk", build = ":DirtytalkUpdate" },
     -- vim-moonfly theme