Open eyalk11 opened 2 years ago
Is it related to https://github.com/quangnguyen30192/cmp-nvim-ultisnips/issues/78 ?
I don't think this is related to 78, no. Can you share your reproduction steps (i.e. what do you type when this happens and which snippets are you using?). Thanks.
have the similar issue after updating plugins, had to remove cmp-nvim-ultisnips
from the plugin list
im running neovim version v0.7.2 link to my vim.init
Please share your reproduction steps: when does this occur, which snippet are you expanding when this happens? Otherwise, we can't do anything to resolve this.
sure, actually no steps are needed to reproduce, in my case the error happens any time I try typing anything in the insert mode or altering the text in any way. so in that sense steps would look like:
the error should occur immediately, at least in my case it did
@quangnguyen30192 Due to the way I changed my plugins and lazy-loading, I can't get cmp-nvim-ultisnips
to work at the moment (I am using luasnip
instead) and I don't want to invest too much time in getting it to work. Did you manage to reproduce this issue?
For anyone else that wants to help debug this issue (@fastndead, @eyalk11), here's what you can do:
autoload/cmp_nvim_ultisnips.vim
print(snippet.__dict__, visual_content.__dict__, before)
, restart Nvim, then try to reproduce the error. Then tell me the output you're seeing in the console (i.e. what is shown with :mes
) :)Sure, I will take it
Hey @fastndead I couldn't reproduce the issue. Could you share your config again? the link you sent is dead
Hey @quangnguyen30192, i switched completely to vsnip for the time being, so I won't help with debugging, sorry. but here's my init.vim configuration, sorry for the broken link, didn't know Notion links do that
im gonna just dump my whole config below, it's the version in which i got the errors
set number
set relativenumber
set ignorecase
set guifont=FiraCode\ Nerd\ Font\ Mono
call plug#begin()
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'mhinz/vim-startify'
Plug 'tpope/vim-fugitive'
Plug 'SirVer/ultisnips'
Plug 'neovim/nvim-lspconfig'
Plug 'mlaursen/vim-react-snippets'
Plug 'ryanoasis/vim-devicons'
Plug 'David-Kunz/jester'
Plug 'mfussenegger/nvim-dap'
" color schemes
Plug 'lifepillar/vim-solarized8'
Plug 'shaeinst/roshnivim-cs'
Plug 'rakr/vim-one'
Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'wadackel/vim-dogrun'
Plug 'sts10/vim-pink-moon'
Plug 'FrenzyExists/aquarium-vim'
Plug 'lmburns/kimbox'
" nvim-cmp plugins below:
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
call plug#end()
nnoremap <SPACE> <Nop>
let mapleader=" "
nnoremap <leader>e :NERDTreeFind<CR>
nnoremap <C-e> :NERDTreeToggle<CR>
nnoremap <silent> <C-p> :GFiles<CR>
nnoremap <leader>s :split<CR>
nnoremap <leader>w :tabclose<CR>
nnoremap <leader>t :tabnew<CR>
nnoremap <leader>] :tabnext<CR>
nnoremap <leader>[ :tabprev<CR>
nnoremap <leader>f :EslintFixAll<CR>
nnoremap <C-f> :Ag<CR>
nnoremap <leader>a ggVG
nnoremap <leader>rr :NERDTreeRefreshRoot<CR>
nnoremap <leader>g :Git<CR>
colorscheme one
set background=dark " for the light version
let g:one_allow_italics = 1 " I love italic for comments
let g:ackprg = 'ag --nogroup --nocolor --column'
set termguicolors
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=2
" when indenting with '>', use 4 spaces width
set shiftwidth=2
" On pressing tab, insert 4 spaces
set expandtab
let g:vim_jsx_pretty_highlight_close_tag = 1
" treesitter configs below
lua <<EOF
require'nvim-treesitter.configs'.setup {
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "maintained",
-- Install languages synchronously (only applied to `ensure_installed`)
sync_install = false,
highlight = {
-- `false` will disable the whole extension
enable = true,
-- list of language that will be disabled
disable = { "c", "rust" },
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = true,
},
}
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.api.nvim_set_keymap('n', '<space>sd', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
end
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
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 = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'ultisnips' }, -- For ultisnips users.
}, {
{ name = 'buffer' },
})
})
-- 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' }
})
})
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'eslint', 'tsserver' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
capabilities = capabilities,
on_attach = on_attach,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
}
}
end
EOF
@SingularisArt Since you also encountered this issue, can you please help us debug this issue by performing the steps I outlined in this comment: https://github.com/quangnguyen30192/cmp-nvim-ultisnips/issues/80#issuecomment-1217645365. Thanks.
@smjonas Sure. Here's what I get when I type b
in a latex file:
{'_priority': 0, '_trigger': 'box', '_value': '`!p\nbox = make_box(len(t[1]))\nsnip.rv = box[0]\nsnip += box[1]\n`${1:${VISUAL:content}}`!p\nbox = make_box(len(t[1]))\nsnip.rv = box[2]\nsnip += box[3]`\n$0', '_description': '"A nice box with the current comment symbol"', '_opts': 'b', '_matched': 'b', '_last_re': None, '_globals': defaultdict(<class 'list'>, {'!p': ['from vim_.snippets import make_box']}), '_compiled_globals': <code object <mo
dule> at 0x7f648449dfd0, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singularis/aspects/nvim/files/.config/nvim/UltiSnips/all/boxes.snippets:10', '_context_code': None, '_context': None, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': 'bbox', '_value': '`!p\nif not snip.c:\n\twidth = int(vim.eval("&textwidth - (virtcol(\'.\') == 1 ? 0 : virtcol(\'.\'))")) or 71\nbox = make_box(len(t[1]), width)\nsnip.rv = box[0]\nsnip += box[1]\n`${1:${VISUAL:content}}`!p\nbox = make_box(len(t[1]), width)\nsnip.rv = box[2]\nsnip += box[3]`\n$0', '_description': '"A nice box over the full width"', '_opts': 'b', '_matched': 'b', '_last_re': None, '_globals': defau
ltdict(<class 'list'>, {'!p': ['from vim_.snippets import make_box']}), '_compiled_globals': <code object <module> at 0x7f648449dfd0, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singularis/aspects/nvim/files/.config/nvim/UltiSnips/all/boxes.snippets:22', '_context_code': None, '_context': None, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': '\\b[a-z]+\\b', '_value': '\\begin{`!p snip.rv = environments[match[0]]`}[$1]\n\t\\label{`!p snip.rv = match[0]`:${2:${1/\\\\\\w+\\{(.*?)\\}|\\\\(.)|(\\w+)|([^\\w\\\\]+)/(?4:_:\\L$1$2$3\\E)/ga}}}\n\n\t$3\n\\end{`!p snip.rv = environments[match[0]]`}', '_description': '"Custom Environments"', '_opts': 'rAbm', '_matched': 'b', '_last_re': <re.Match object; span=(0, 1), match='b'>, '_globals': defaultdict(<class 'list
'>, {'!p': ['\nfrom latex_.scopes import text\nenvironments = {\n\t"def": "definition",\n\t"thm": "theorem",\n\t"exm": "example",\n\t"clm": "claim",\n\t"cor": "corollary",\n\t"prop": "proposition",\n\t"lem": "lemma",\n\t"exc": "exercise",\n\t"qst": "question",\n\t"sol": "solution",\n\t"not": "note",\n\t"nta": "notation",\n}\n']}), '_compiled_globals': <code object <module> at 0x7f648449e8c0, file "<global-snippets>", line 1>, '_location': '/ho
me/singularis/Documents/school-notes/College/Year-1/winter/mth-252/UltiSnips/tex.snippets:35', '_context_code': 'match[0] in environments', '_compiled_context_code': <code object <module> at 0x7f648449e600, file "<context-code>", line 1>, '_context': None, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': 'bf', '_value': '\\textbf{${VISUAL}$1}$0', '_description': '"Bold"', '_opts': '', '_matched': 'b', '_last_re': None, '_globals': defaultdict(<class 'list'>, {'!p': ['\nfrom latex_.scopes import text, math\n']}), '_compiled_globals': <code object <module> at 0x7f648449f310, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singularis/aspects/nvim/files/.config/nvim/UltiSnips/tex/text.sni
ppets:16', '_context_code': 'text()', '_context': None, '_compiled_context_code': <code object <module> at 0x7f648449e760, file "<context-code>", line 1>, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': 'bit', '_value': '\\bibitem{${1:label}}\n\t${2:Author},\n\t\\emph{${3:Title}}, \n\t${4:Date}.', '_description': '"Bibliography Item"', '_opts': 'wi', '_matched': 'b', '_last_re': None, '_globals': defaultdict(<class 'list'>, {'!p': ['from latex_.scopes import env']}), '_compiled_globals': <code object <module> at 0x7f64844bc660, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singular
is/aspects/nvim/files/.config/nvim/UltiSnips/tex/other.snippets:12', '_context_code': None, '_context': None, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': 'builder', '_value': '\\\\{ ${1:x} \\in ${2:\\mathbb{R}} | ${3:P(x)} \\\\}', '_description': '"Set Builder Notation"', '_opts': 'w', '_matched': 'b', '_last_re': None, '_globals': defaultdict(<class 'list'>, {'!p': ['\nfrom latex_.scopes import math\n']}), '_compiled_globals': <code object <module> at 0x7f648449f730, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singularis/aspects/n
vim/files/.config/nvim/UltiSnips/tex/sets.snippets:49', '_context_code': 'math()', '_context': None, '_compiled_context_code': <code object <module> at 0x7f648449e4a0, file "<context-code>", line 1>, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None} b
{'_priority': 0, '_trigger': 'beg', '_value': '\\begin{$1}[$2]\n \\label{$3:${4:${2/\\\\\\w+\\{(.*?)\\}|\\\\(.)|(\\w+)|([^\\w\\\\]+)/(?4:_:\\L$1$2$3\\E)/ga}}}\n\n ${VISUAL}$5\n\\end{$1}', '_description': '"begin{} / end{}"', '_opts': 'Abm', '_matched': 'b', '_last_re': None, '_globals': defaultdict(<class 'list'>, {'!p': ['\nfrom latex_.scopes import math, display_math, inline_math, chem, not_chem, unit, not_unit, text, env\n']}), '_compiled
_globals': <code object <module> at 0x7f64844bd840, file "<global-snippets>", line 1>, '_location': '/home/singularis/.local/share/Singularis/aspects/nvim/files/.config/nvim/UltiSnips/tex/environments.snippets:15', '_context_code': 'text()', '_context': None, '_compiled_context_code': <code object <module> at 0x7f648449e760, file "<context-code>", line 1>, '_actions': {}, '_compiled_actions': {}} {'_mode': '', '_text': '', '_placeholder': None
} b
I figured out why I was having this issue. I'm currently using lazy.nvim
as my plugin manager, and here's how I was loading the plugins:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
"folke/lazy.nvim",
{
"SirVer/ultisnips",
config = function()
vim.g.UltiSnipsRemoveSelectModeMappings = 0
vim.g.UltiSnipsEditSplit = "tabdo"
vim.g.UltiSnipsSnippetDirectories = {
"~/.config/nvim/UltiSnips", "UltiSnips"
}
end,
event = "InsertEnter",
},
{
"hrsh7th/nvim-cmp",
config = function()
local cmp = require("cmp")
-- ...
end,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"quangnguyen30192/cmp-nvim-ultisnips",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-path",
-- ...
},
event = "InsertEnter",
},
-- ...
}, {
defaults = { lazy = true, version = "*" },
install = {},
checker = { enabled = false },
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
When I changed the line from defaults = { lazy = true, version = "*" }
to defaults = { lazy = true }
, I stopped getting this issue. This was also how I resolved the issue in #84. Even tho I fixed my issue, I'll still try and help with whatever I can.
Great that you finally make it works, hopefully, it would be useful for you. Thank you for choosing it.
@SingularisArt thanks for helping with this! Honestly this error (_context_match() takes 2 positional arguments but 3 were given
) does not make sense to me at all since _context_match
takes 3 arguments and not 2 as the error message suggests. And based on the print statements it definitely does take 3 arguments (snippet
being one of them).
Maybe there are some Python experts that come across this - if so please enlighten me ;)
Getting a similar error:
Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: TextChangedI Autocommands for "*"..function cmp_nvim_ultisnips#get_current_snippets[33]..provider#python3#Call, line 18: Vim(return):Error invoking 'python_execu
te' on channel 10 (python3-script-host):
This happens when I type the word all.
I'm getting errors again, I opened up an issue in SirVer/ultisnips#1546
Error executing vim.schedule lua callback: function cmp_nvim_ultisnips#get_current_snippets[33]..provider#python3#Call, line 18: Vim(return):Error invoking 'python
_execute' on channel 8 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "/usr/lib/python3.12/site-packages/pynvim/api/nvim.py", line 287, in command
return self.request('nvim_command', string, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pynvim/api/nvim.py", line 182, in request
res = self._session.request(name, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
raise self.error_wrapper(err)
pynvim.api.common.NvimError: Vim:<action-code>:1: SyntaxWarning: invalid escape sequence '\e'
stack traceback:
[C]: in function 'load_snippets'
...ged/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/source.lua:27: in function 'complete'
...ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/source.lua:334: in function 'complete'
...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:169: in function 'autoindent'
...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/init.lua:338: in function 'callback'
...ie/.config/nvim/plugged/nvim-cmp/lua/cmp/utils/async.lua:165: in function <...ie/.config/nvim/plugged/nvim-cmp/lua/cmp/utils/async.lua:163>
It happens in tex files when I type things. Especially things that trigger ltex. I updated nvim-cmp to latest version.