Comments (9)
I haven't tested it extensively, but the issue I reported is now gone.
from cmp-nvim-ultisnips.
Could you share some additional info on how to reproduce this issue? Where did you put that code? What is the exact error message? Which snippet definitions are you using? Possibly relevant: your Neovim version. I added this to my .vimrc
(and I can confirm A
snippets are not triggered automatically anymore) but I can't reproduce this issue.
from cmp-nvim-ultisnips.
I am using Neovim version 0.6. The code I provided in the first post is inside the config file I have for ultisnips.
Here's my cmp
config:
local present, cmp = pcall(require, "cmp")
local has_any_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local press = function(key)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), "n", true)
end
cmp.setup {
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
completion = {
completeopt = "menu,menuone,noselect",
keyword_length = 1,
},
sources = {
{ name = "ultisnips" },
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
},
mapping = {
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
["<C-Space>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then
return press("<C-R>=UltiSnips#ExpandSnippet()<CR>")
end
cmp.select_next_item()
elseif has_any_words_before() then
press("<Space>")
else
fallback()
end
end, {
"i",
"s",
}),
["<Tab>"] = cmp.mapping(function(fallback)
if vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
press("<ESC>:call UltiSnips#JumpForwards()<CR>")
elseif cmp.visible() then
cmp.select_next_item()
elseif has_any_words_before() then
press("<Tab>")
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then
press("<ESC>:call UltiSnips#JumpBackwards()<CR>")
elseif cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s",
}),
},
}
I am using the default configuration for ultisnips. With the autotrigger disabled, when I am insert mode and press any character, I get the following .
from cmp-nvim-ultisnips.
Thank you. Possibly a duplicate of #46? Are you using the latest version of this plugin? Also, we have now added recommended mapping functions you can call - see readme (they do the same as your code).
from cmp-nvim-ultisnips.
I just updated and tried the recommended settings. I'm still getting the same error.
from cmp-nvim-ultisnips.
Ok this is weird. Just to be 100% sure: everything works correctly when autotrigger is enabled? I will look into it.
from cmp-nvim-ultisnips.
Have a look at the video to see exactly what is going on. While experimenting, I noticed that if I press the tab key by itself while in insert mode, the problem does not occur
2021-12-09.21-10-09.mp4
.
from cmp-nvim-ultisnips.
Could you try this PR? #51
I suspect it is some kind of loading order problem, seems like UltiSnips is not available yet when cmp_nvim_ultisnips is ready.
So I tried to source the UltiSnips file as cmp_nvim_ultisnips starts.
from cmp-nvim-ultisnips.
Wow I'm a bit surprised that it worked, thanks for testing!
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
- When cmp is active, jump forward doesnt go forward. HOT 7
- 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.