Skip to content

Commit

Permalink
fix: allow tabbing between luasnip snippet parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgilly17 committed Aug 20, 2024
1 parent d13ee74 commit 795589b
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions config/completion/cmp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,54 @@
mapping = {
__raw = ''
cmp.mapping.preset.insert({
['<C-j>'] = cmp.mapping.select_next_item(),
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-e>'] = cmp.mapping.abort(),
['<C-j>'] = cmp.mapping.select_next_item(),
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-e>'] = cmp.mapping.abort(),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<S-CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
['<S-CR>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
-- Taken from https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
-- to stop interference between cmp and luasnip
['<CR>'] = cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
'';
};
Expand Down Expand Up @@ -99,7 +134,7 @@
Event = "",
Operator = "",
TypeParameter = "",
}
}
local cmp = require'cmp'
Expand Down

0 comments on commit 795589b

Please sign in to comment.