diff options
Diffstat (limited to 'nvim-primeagen/after/plugin/cmp.lua')
-rw-r--r-- | nvim-primeagen/after/plugin/cmp.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/nvim-primeagen/after/plugin/cmp.lua b/nvim-primeagen/after/plugin/cmp.lua new file mode 100644 index 0000000..a85ee9b --- /dev/null +++ b/nvim-primeagen/after/plugin/cmp.lua @@ -0,0 +1,41 @@ +local cmp = require("cmp") +local luasnip = require("luasnip") + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For luasnip users + end, + }, + sources = { + { name = "luasnip" }, + { name = "path" }, + }, + mapping = { + ["<Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- they way you will only jump inside the snippet region + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + ["<S-Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + + -- ... Your other mappings ... + }, +}) |