diff options
| author | Nanderty <psopka@sopka.ch> | 2023-03-25 18:16:24 +0100 |
|---|---|---|
| committer | Nanderty <psopka@sopka.ch> | 2023-03-25 18:16:24 +0100 |
| commit | 063c2d97218cdabe0634054a8038cd6b5c9a9a12 (patch) | |
| tree | 768cb00820e92f577fe59253ba07e58f606ced4e /lua/plugins/cmp.lua | |
| parent | af7c85ef9daaf702a179a9b3d66d03eff71db7a6 (diff) | |
| download | neovim-config-063c2d97218cdabe0634054a8038cd6b5c9a9a12.tar.gz neovim-config-063c2d97218cdabe0634054a8038cd6b5c9a9a12.tar.bz2 neovim-config-063c2d97218cdabe0634054a8038cd6b5c9a9a12.zip | |
cleanup, snippets
Diffstat (limited to 'lua/plugins/cmp.lua')
| -rw-r--r-- | lua/plugins/cmp.lua | 46 |
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' }, }), |
