summaryrefslogtreecommitdiffstats
path: root/lua/plugins/cmp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins/cmp.lua')
-rw-r--r--lua/plugins/cmp.lua46
1 files changed, 14 insertions, 32 deletions
diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua
index b2ec2e5..76e8101 100644
--- a/lua/plugins/cmp.lua
+++ b/lua/plugins/cmp.lua
@@ -1,17 +1,20 @@
return {
{
'L3MON4D3/LuaSnip',
- dependencies = {
- 'iurimateus/luasnip-latex-snippets.nvim',
- 'rafamadriz/friendly-snippets',
+ event = 'InsertEnter',
+ keys = {
+ { 'jj', function() require('luasnip').jump(1) end, mode = 'i' },
+ { 'kk', function() require('luasnip').jump(-1) end, mode = 'i' },
},
opts = {
history = true,
- delete_check_events = "TextChanged",
+ enable_autosnippets = true,
+ delete_check_events = 'TextChanged',
+ update_events = { 'TextChanged', 'TextChangedI' },
},
- config = function()
- require('luasnip-latex-snippets').setup()
- require('luasnip.loaders.from_vscode').lazy_load()
+ config = function(_, opts)
+ require('luasnip').config.set_config(opts)
+ require('luasnip.loaders.from_lua').lazy_load({ paths = vim.fn.stdpath('config') .. '/Snippets/' })
end
},
{
@@ -36,10 +39,6 @@ return {
local luasnip = require('luasnip')
local cmp = require('cmp')
- luasnip.config.set_config({
- history = true,
- enable_autosnippets = true,
- })
return {
snippet = {
expand = function(args)
@@ -48,31 +47,14 @@ return {
},
mapping = cmp.mapping.preset.insert({
['<Space>'] = cmp.mapping.confirm({ select = false }),
- ['<Tab>'] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_next_item()
- 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' }),
+ ['<Tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
+ ['<S-Tab>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
+ ['jk'] = cmp.mapping.abort(),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
- {name = 'buffer' },
+ { name = 'buffer' },
{ name = 'path' },
{ name = 'calc' },
}),