-
|
Hi everyone, so far I'm really liking the visual and performance benefits of blink.cmp vs nvim-cmp. There's just one really annoying thing that prevents me from enjoying it fully. Which is tab behavior for luasnip that keeps on jumping back even though I've already "broken" the snippet's flow. Behavior: Details
Given a lua snippet with placeholders: s('pubf', {
t('public '),
t('function '),
i(1),
t('('),
i(2),
t(')'),
i(3),
t({ '', '{', '' }),
t(' '),
i(4),
t({ '', '}' }),
})If I use this snippet, it generates: public function |()
{
}(where If I then type a name, and break out of the snippet cycle, public function hello()
{
|
}(where And I press tab again, it jumps back up to the next placeholder public function hello(|)
{
}While I expect (and my nvim-cmp config did this as well): public function hello()
{
|
}In nvim-cmp I had the following configuration for luasnip: cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = 'menu,menuone,noinsert' },
mapping = cmp.mapping.preset.insert {
['<Tab>'] = cmp.mapping.confirm { select = true },
['<C-Space>'] = cmp.mapping.complete {},
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
},
sources = {
{
name = 'lazydev',
group_index = 0,
},
{ name = 'nvim_lsp' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
end,
},Can anyone help me with migrating this behavior to blink.cmp? My current setup there is: { -- Autocompletion
'saghen/blink.cmp',
event = 'VimEnter',
version = '1.*',
dependencies = {
'L3MON4D3/LuaSnip',
'folke/lazydev.nvim',
},
opts = {
keymap = {
preset = 'super-tab',
},
appearance = {
nerd_font_variant = 'mono',
},
completion = {
documentation = { auto_show = false, auto_show_delay_ms = 250 },
},
sources = {
default = { 'lsp', 'path', 'snippets', 'lazydev' },
providers = {
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
},
},
snippets = { preset = 'luasnip' },
fuzzy = { implementation = 'prefer_rust_with_warning' },
signature = { enabled = true },
},
}I think it is the keybindings I had in nvim-cmp's config that allowed me to insert tab without it doing funky things. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
How do you "break" the cycle?
You can read #1805, and Luasnip issue #872 as well for some pointers. Still, I'm kinda surprised this "just works" in Anyway, if you find a workaround or any insights about how |
Beta Was this translation helpful? Give feedback.
Ah got it! This is because
<Tab>in thesuper-tabpreset you're using fall backs tosnippet_forwardaction when no completion item can be accepted. You need to override the<Tab>keybind: