diff --git a/plugins/cmp.nix b/plugins/cmp.nix index 2923df7..507cbe9 100644 --- a/plugins/cmp.nix +++ b/plugins/cmp.nix @@ -14,6 +14,53 @@ _: # TODO: add this at luasnip: # { name = "luasnip", priority = 750 } + + mapping = { + "" = "cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }"; + "" = "cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }"; + "" = "cmp.mapping(function() + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then + cmp.select_prev_item { behavior = cmp.SelectBehavior.Insert } + else + cmp.complete() + end + end)"; + "" = "cmp.mapping(function() + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then + cmp.select_next_item { behavior = cmp.SelectBehavior.Insert } + else + cmp.complete() + end + end)"; + "" = "cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }"; + "" = "cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }"; + "" = "cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' })"; + "" = "cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' })"; + "" = "cmp.mapping(cmp.mapping.complete(), { 'i', 'c' })"; + "" = "cmp.config.disable"; + "" = "cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() }"; + "" = "cmp.mapping.confirm { select = false }"; + "" = "cmp.mapping(function(fallback) + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then + cmp.select_next_item() + elseif vim.snippet and vim.snippet.active { direction = 1 } then + vim.schedule(function() vim.snippet.jump(1) end) + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' })"; + "" = "cmp.mapping(function(fallback) + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then + cmp.select_prev_item() + elseif vim.snippet and vim.snippet.active { direction = -1 } then + vim.schedule(function() vim.snippet.jump(-1) end) + else + fallback() + end + end, { 'i', 's' })"; + }; }; };