blob: a85ee9bb3856b589519b14f541fd15b13c3855db (
plain) (
tree)
|
|
local cmp = require("cmp")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For luasnip users
end,
},
sources = {
{ name = "luasnip" },
{ name = "path" },
},
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- they way you will only jump inside the snippet region
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
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" }),
-- ... Your other mappings ...
},
})
|