mirror of
https://github.com/josean-dev/dev-environment-files.git
synced 2025-01-08 17:21:23 +01:00
Add snippet navigation
Adds the usage of Tab and Shift-Tab to jump through parts of the snippet after selecting one. Pretty essential
This commit is contained in:
parent
cb670e8890
commit
e547afc985
1 changed files with 16 additions and 0 deletions
|
@ -42,6 +42,22 @@ return {
|
||||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback) -- next part of snippet
|
||||||
|
if luasnip.expandable() then
|
||||||
|
luasnip.expand()
|
||||||
|
elseif luasnip.locally_jumpable(1) then
|
||||||
|
luasnip.jump(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }), -- in both insert and select mode
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback) -- previous part of snippet
|
||||||
|
if luasnip.locally_jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }), -- in both insert and select mode
|
||||||
}),
|
}),
|
||||||
-- sources for autocompletion
|
-- sources for autocompletion
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
|
|
Loading…
Reference in a new issue