Configure nvim-cmp for s and c mode

This commit is contained in:
Oliver Hartmann 2021-11-19 17:37:42 +01:00
parent e142a3ec5b
commit f4631cbaa2
3 changed files with 27 additions and 14 deletions

View File

@ -34,15 +34,16 @@ cmp.setup {
end end
}, },
mapping = { mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(), ['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}),
['<C-n>'] = cmp.mapping.select_next_item(), ['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
['<C-e>'] = cmp.mapping.close(), ['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
['<CR>'] = cmp.mapping.confirm({ ['<CR>'] = cmp.mapping({
behavior = cmp.ConfirmBehavior.Insert, i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
select = true c = cmp.mapping.confirm({ select = false }),
s = cmp.mapping.confirm({ select = false }),
}), }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then if luasnip.expand_or_jumpable() then
@ -76,9 +77,26 @@ cmp.setup {
{name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"}, {name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"},
{name = "emoji"} {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 -- Autopairs
--require("nvim-autopairs.completion.cmp").setup({ --require("nvim-autopairs.completion.cmp").setup({
-- map_cr = true, -- map_cr = true,

View File

@ -84,11 +84,6 @@ utils.map('n', '<C-y>', '<cmd>Telescope neoclip<cr>')
utils.map('n', '<leader>j', '<cmd>Telescope jumplist<cr>') utils.map('n', '<leader>j', '<cmd>Telescope jumplist<cr>')
-- wildmode -- wildmode
utils.map('c', '<up>', 'wildmenumode() ? "\\<left>" : "\\<up>"', {expr = true})
utils.map('c', '<down>', 'wildmenumode() ? "\\<right>" : "\\<down>"', {expr = true})
utils.map('c', '<left>', 'wildmenumode() ? "\\<up>" : "\\<left>"', {expr = true})
utils.map('c', '<right>', 'wildmenumode() ? "\\<bs>\\<C-Z>" : "\\<right>"', {expr = true})
utils.map('c', '<CR>', 'wildmenumode() ? "\\<bs>\\<C-Z>" : "\\<CR>"', {expr = true})
-- Symbols Outline -- Symbols Outline
utils.map('n', '<leader>s', '<cmd>SymbolsOutline<cr>') utils.map('n', '<leader>s', '<cmd>SymbolsOutline<cr>')

View File

@ -24,7 +24,7 @@ return require('packer').startup(function()
'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp',
'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lua',
'octaltree/cmp-look', 'hrsh7th/cmp-path', 'hrsh7th/cmp-calc', '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'} use {'rafamadriz/friendly-snippets'}