Incorporate snippets.

main
Joshua Potter 2023-11-18 16:41:39 -07:00
parent 74ee41cf80
commit 7da4ea01fa
2 changed files with 23 additions and 1 deletions

View File

@ -84,6 +84,8 @@ in
nvim-treesitter nvim-treesitter
pkgs.vimPlugins.cmp-buffer pkgs.vimPlugins.cmp-buffer
pkgs.vimPlugins.cmp-nvim-lsp pkgs.vimPlugins.cmp-nvim-lsp
pkgs.vimPlugins.cmp_luasnip
pkgs.vimPlugins.luasnip
]; ];
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;

View File

@ -2,9 +2,15 @@ local M = {}
local cmp = require('cmp') local cmp = require('cmp')
local cmp_buffer = require('cmp_buffer') local cmp_buffer = require('cmp_buffer')
local luasnip = require("luasnip")
function M.setup() function M.setup()
cmp.setup { cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
sources = { sources = {
{ {
name = 'nvim_lsp', name = 'nvim_lsp',
@ -46,7 +52,21 @@ function M.setup()
end, { 'i', 's' }), end, { 'i', 's' }),
['<tab>'] = cmp.mapping(function(fallback) ['<tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then cmp.confirm() else fallback() end if cmp.get_active_entry() then
cmp.confirm()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<s-tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }), end, { 'i', 's' }),
}, },
} }