1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 11:24:55 +02:00

moar nvim: snippets and other things

This commit is contained in:
Henrik Hautakoski 2024-05-18 14:56:00 +02:00
parent bcb84e54eb
commit 0fb3cfeef9
14 changed files with 426 additions and 138 deletions

45
nvim/lua/utils/cmd.lua Normal file
View file

@ -0,0 +1,45 @@
local luasnip = require('luasnip')
local cmp = require('cmp')
local M = {}
function M.selectNext(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item(opts or {})
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, {"i", "s"})
end
function M.selectPrev(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(opts or {})
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {"i", "s"})
end
function M.confirm(opts)
return cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
cmp.confirm(opts or {})
end
else
fallback()
end
end)
end
return M