diff --git a/lua/cmp_plug.lua b/lua/cmp_plug.lua index 0ff0dbf..cff3984 100644 --- a/lua/cmp_plug.lua +++ b/lua/cmp_plug.lua @@ -34,15 +34,16 @@ cmp.setup { end }, mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}), + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }), + [''] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }), + [''] = cmp.mapping({ + i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + c = cmp.mapping.confirm({ select = false }), + s = cmp.mapping.confirm({ select = false }), }), [""] = cmp.mapping(function(fallback) if luasnip.expand_or_jumpable() then @@ -76,9 +77,26 @@ cmp.setup { {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, {name = "emoji"} }, - completion = {completeopt = 'menu,menuone,noinsert'} + completion = {completeopt = 'menu,menuone,noinsert, noselect'}, + -- experimental = { native_menu = true } } +-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' } + }, + }) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), +}) + -- Autopairs --require("nvim-autopairs.completion.cmp").setup({ -- map_cr = true, diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9e3dc32..13fc70e 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -84,11 +84,6 @@ utils.map('n', '', 'Telescope neoclip') utils.map('n', 'j', 'Telescope jumplist') -- wildmode -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) -utils.map('c', '', 'wildmenumode() ? "\\\\" : "\\"', {expr = true}) -- Symbols Outline utils.map('n', 's', 'SymbolsOutline') diff --git a/lua/plugins.lua b/lua/plugins.lua index 54936fe..0171e7e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -24,7 +24,7 @@ return require('packer').startup(function() 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua', 'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', - 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji' + 'f3fora/cmp-spell', 'hrsh7th/cmp-emoji', 'hrsh7th/cmp-cmdline' } } use {'rafamadriz/friendly-snippets'}