From 49081f4dfb877bfc33575a40eb6f4ca3e329ef6b Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 11 Nov 2023 17:11:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=20lazy=20loading=20and=20fix?= =?UTF-8?q?=20completeopt=20in=20cmdline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/core.lua | 2 +- lua/lazy-plugins.lua | 31 +++++++++++++++++++------------ lua/plugins/cmp.lua | 8 +++++++- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lua/core.lua b/lua/core.lua index 010a15e..ef3a5af 100644 --- a/lua/core.lua +++ b/lua/core.lua @@ -11,7 +11,7 @@ o.showmode = false o.scrolloff = 10 -- controlling -vim.opt.completeopt = { 'menu', 'menuone', 'noinsert' } +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } o.ignorecase = true o.smartcase = true o.smartindent = true diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index edb5ac0..bffaf7e 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -49,6 +49,7 @@ local plugins = { }, { "nvim-treesitter/nvim-treesitter-context", + event = {"BufReadPre", "BufNewFile"}, dependencies = { "nvim-treesitter/nvim-treesitter", }, @@ -93,27 +94,33 @@ local plugins = { }, { "hrsh7th/cmp-nvim-lsp", + event = { "BufReadPre", "BufNewFile" }, dependencies = { "neovim/nvim-lspconfig", - dependencies = { - { - "williamboman/mason-lspconfig.nvim", - dependencies = { - "williamboman/mason.nvim", - } - }, - "null-ls.nvim" + }, + lazy = true + }, + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { + "williamboman/mason-lspconfig.nvim", + dependencies = { + "williamboman/mason.nvim", + } }, - config = function() - require("plugins.lsp") - end, - } + }, + config = function() + require("plugins.lsp") + end, }, { "jay-babu/mason-null-ls.nvim", config = function() require("plugins.null-ls") end, + event = { "BufReadPre", "BufNewFile" }, dependencies = { "williamboman/mason.nvim", "jose-elias-alvarez/null-ls.nvim" diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 1d35d37..4e591e2 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -67,9 +67,12 @@ cmp.setup({ cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), + completion = { + completeopt = 'menu,menuone,noselect' + }, sources = { { name = 'buffer' } - } + }, }) -- Set configuration for specific filetype. @@ -85,6 +88,9 @@ cmp.setup.filetype('gitcommit', { -- `:` cmdline setup. cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), + completion = { + completeopt = 'menu,menuone,noselect' + }, sources = cmp.config.sources({ { name = 'path' } }, {