Skip to content

Commit

Permalink
Un-collide Tab for cmp next/prev vs. snippet next/prev (#109)
Browse files Browse the repository at this point in the history
ctrl+n / ctrl+p already work for cmp next/prev and are pretty
obvious/natural, so letting Tab just do snippet stuff is fine
  • Loading branch information
jisantuc authored Jan 3, 2025
1 parent 6f2d5e9 commit 6cb2215
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dotfiles/neovim/lua/completion-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-g>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
if vim.snippet.active({ direction = 1 }) then
vim.snippet.jump(1)
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
Expand All @@ -25,10 +26,10 @@ cmp.setup({
end, { "i", "s" }),

["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
elseif vim.snippet.active({ direction = -1 }) then
vim.snippet.jump(-1)
else
fallback()
end
Expand Down

0 comments on commit 6cb2215

Please sign in to comment.