mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 11:24:55 +02:00
new nvim config
This commit is contained in:
parent
f087422bbf
commit
7d14948480
66 changed files with 1771 additions and 1719 deletions
44
nvim/lua/user/utils/cmp.lua
Normal file
44
nvim/lua/user/utils/cmp.lua
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
local hasluansp, luasnip = pcall(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 hasluansp and 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 hasluansp and 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue