summaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lua/conf/plugins/cmp.lua54
1 files changed, 14 insertions, 40 deletions
diff --git a/lua/conf/plugins/cmp.lua b/lua/conf/plugins/cmp.lua
index 5dbb6ed..5d9dac2 100644
--- a/lua/conf/plugins/cmp.lua
+++ b/lua/conf/plugins/cmp.lua
@@ -7,7 +7,6 @@ end
return { 'hrsh7th/nvim-cmp',
requires = {
- 'danymat/neogen',
'nvim-treesitter/nvim-treesitter',
'lukas-reineke/cmp-under-comparator' -- better results
},
@@ -26,7 +25,6 @@ return { 'hrsh7th/nvim-cmp',
function()
local cmp = require('cmp')
local luasnip = require('luasnip')
- local neogen = require('neogen')
cmp.setup {
-- disable when in comments
@@ -116,54 +114,30 @@ return { 'hrsh7th/nvim-cmp',
-- mappings
mapping = cmp.mapping.preset.insert {
- ["<Tab>"] = cmp.mapping(function(fallback)
- if #cmp.get_entries() == 1 then
+ ["<C-y>"] = cmp.mapping(function()
+ if cmp.get_active_entry() then
cmp.confirm({ select = true })
- elseif cmp.visible() then
+ elseif cmp.visible() and not cmp.get_active_entry() then
+ cmp.select_next_item()
+ cmp.confirm({ select = true })
+ end
+ end, { "i", "c" }),
+
+ ["<C-n>"] = cmp.mapping(function()
+ if cmp.visible() then
cmp.select_next_item()
- elseif luasnip.expand_or_locally_jumpable() then
- luasnip.expand_or_jump()
- elseif has_words_before() then
- cmp.complete()
- if #cmp.get_entries() == 1 then
- cmp.confirm({ select = true })
- end
- elseif neogen.jumpable() then
- neogen.jump_next()
- else
- fallback()
end
- end, { "i", "s" }),
+ end),
- ["<S-Tab>"] = cmp.mapping(function(fallback)
+ ["<C-p>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
- elseif luasnip.jumpable(-1) then
- luasnip.jump(-1)
- elseif neogen.jumpable(-1) then
- neogen.jump_prev()
- else
- fallback()
end
- end, { "i", "s" }),
-
- ['<CR>'] = cmp.mapping {
- i = function(fallback)
- if cmp.visible() and cmp.get_active_entry() then
- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
- else
- fallback()
- end
- end,
- s = cmp.mapping.confirm({ select = true }),
- c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace,
- select = true }),
- },
+ end),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
- ['<ESC>'] = cmp.mapping.close(),
- ["<C-e>"] = cmp.mapping.abort()
+ ['<ESC>'] = cmp.mapping.close()
}
}
end