From 317c612f41e38757d261cc7a2a693666d780c779 Mon Sep 17 00:00:00 2001 From: newbie Date: Tue, 19 Dec 2023 07:16:27 +0800 Subject: [PATCH] update lspconfig --- lua/plugs/nvim-lspconfig.lua | 37 ++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lua/plugs/nvim-lspconfig.lua b/lua/plugs/nvim-lspconfig.lua index a6c6681..1dcd4fc 100644 --- a/lua/plugs/nvim-lspconfig.lua +++ b/lua/plugs/nvim-lspconfig.lua @@ -179,9 +179,10 @@ return { { name = 'nvim_lsp' }, { name = 'buffer' }, { name = 'path' }, - { name = 'cmdline' }, + -- { name = 'cmdline' }, }), mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping({ i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), c = function(fallback) @@ -268,7 +269,7 @@ return { -- }) }, } - cmp.setup.cmdline('/', { + cmp.setup.cmdline({ '/', '?' }, { view = { entries = { name = 'wildmenu', separator = '|' } }, @@ -289,6 +290,38 @@ return { end end, { "i", "s" }), + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + end + end, { "i", "s" }), + }), + }) + cmp.setup.cmdline(':', { + view = { + entries = { name = 'wildmenu', separator = '|' } + }, + sources = cmp.config.sources({ + { name = 'buffer' }, + }), + mapping = cmp.mapping.preset.insert({ + + [''] = cmp.mapping.confirm({ select = false }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item()