Comments (7)
Which key do you press to expand the snippet? Right now, jumping to the next placeholder only works if the snippet was already expanded (the item was selected from cmp's menu). The default in cmp is <cr>
by the way.
For example, I have this mapping:
["<C-f>"] = cmp.mapping(
cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
{ "i", "s" }
),
from cmp-nvim-ultisnips.
I am having a similar issue, potentially the same. I am using return to expand snippets, and also set tab and s-tab to jump forward and backward like mentioned above. After expended a snippet, the cursor jumps to the first placeholder in select mode waiting for user input.
- If I replace the placeholder text by typing a few characters, I am then in insert mode. Tab will jump to the next placeholder with no problem
- However, if I press tab to jump the second placeholder without typing anything (essentially still in select mode), it will not jump. Instead, the tab kicks me out of select mode and goes into normal mode.
from cmp-nvim-ultisnips.
@Guzzii could you share your nvim-cmp
config? It might be a configuration issue because I can't reproduce it (<Tab>
moves me to the next placeholder even in select mode).
from cmp-nvim-ultisnips.
Sure, below is my config
vim.cmd('set completeopt=menu,menuone,noselect')
local cmp = require('cmp')
local lspkind = require('lspkind')
local cmp_ultisnips_mappings = require('cmp_nvim_ultisnips.mappings')
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn['UltiSnips#Anon'](args.body) -- For `ultisnips` users.
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'ultisnips' },
{ name = 'buffer' }, { name = 'nvim_lua' },
{ name = 'tmux' }, { name = 'emoji' }
}),
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }),
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<Tab>'] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.compose {'select_next_item', 'jump_forwards'}(fallback)
end, {'i', 's'}
),
['<S-Tab>'] = cmp.mapping(
function(fallback)
cmp_ultisnips_mappings.compose {'select_prev_item', 'jump_backwards'}(fallback)
end, {'i', 's'}
),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 's', 'c'}),
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's', 'c'}),
},
formatting = {
format = lspkind.cmp_format({
with_text = true,
menu = {
buffer = '[Buffer]',
nvim_lsp = '[LSP]',
nvim_lua = '[Lua]',
ultisnips = '[UltraSnip]',
tmux = '[Tmux]',
emoji = '[Emoji]',
}
}),
},
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', { sources = {{ name = 'buffer' }}})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({{ name = 'path' }}, {{ name = 'cmdline' }})
})
from cmp-nvim-ultisnips.
Sorry, I still can't reproduce it with your config. For some reason, setting <cr>
as the key to confirm the selected item does not even work for me (it does not expand the snippet). Can you check that smap <Plug>
contains the three mappings cmpu-expand
, cmpu-jump-forwards
and cmpu-jump-backwards
?
from cmp-nvim-ultisnips.
Just to confirm, with the latest update, it is working as expected and no longer an issue.
from cmp-nvim-ultisnips.
Perfect, thanks for letting me know!
from cmp-nvim-ultisnips.
Related Issues (20)
- Strange error when trying to load ultisnips HOT 5
- Expand Snippet shows on the command line HOT 6
- Using tab to jump forward leaves a space before jumping forward HOT 6
- Snippetes with multiple options doesn't works HOT 1
- Possible bug when triggering snippet before the completion menu has opened for the first time
- Wrong context matching HOT 5
- If i set jump_forwards before expand, it has a lag before i can expand HOT 8
- Error detected while processing TextChangedI Autocommands for "*": HOT 16
- Not showing all honza/vim-snippets (but it still exists somehow) HOT 12
- Failed to load parser: uv_dlsym: dlsym(0x208d77c60, tree_sitter_Dockerfile): symbol not found HOT 1
- Many auto-snippets can not be trigger HOT 1
- E5108: Error executing lua Vim:E117: Unknown function: `UltiSnips#CanJumpForwards`, `UltiSnips#CanJumpBackwards`, and `UltiSnips#CanExpand` HOT 21
- Error detected while processing TextChangedI Autocommands for "*": HOT 4
- Ultisnips stopped working HOT 1
- Insert mode is slow and laggy with this source enabled HOT 12
- Load the wrong snippets source HOT 1
- Error out when using latest master. HOT 8
- bad argument #1 to 'pairs' (table expected, got nil) in source.lua:29 HOT 2
- tab completion does not work anymore HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmp-nvim-ultisnips.