You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings. I set up ultisnips' global variables, cmp_nvim_ultisnips, and neovim-cmp, in their respective order with Lazy.vim plug-in manager. (I will provide the full configuration code at the end.)
When I hit <tab> in a document, the following error pops up:
E5108: Error executing lua Vim:E117: Unknown function: UltiSnips#CanExpandSnippet
stack traceback:
[C]: at 0x55a4871cf190
...y/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/mappings.lua:8: in function <...y/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/mappings.lua:7>
...y/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/mappings.lua:52: in function <...y/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/mappings.lua:39>
...y/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/mappings.lua:62: in function 'expand_or_jump_forwards' ~/.config/nvim/lua/plugins/nvim-cmp.lua:34: in function 'on_keymap'
.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:144: in function 'callback'
.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:118: in function <.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:112>
.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:248: in function <.../.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/keymap.lua:247>
Based on Lazy.vim info panel, the ultisnips' version info and cmp-nvim-ultisnips' version info are here:
● ultisnips
dir ~/.local/share/nvim/lazy/ultisnips
URL https://github.com/SirVer/ultisnips
version 3.2.0
tag 3.2
branch master
commit 7dc30c5
...
● cmp-nvim-ultisnips
dir ~/.local/share/nvim/lazy/cmp-nvim-ultisnips
URL https://github.com/quangnguyen30192/cmp-nvim-ultisnips
branch main
commit 2be0eda
...
The function 'UltiSnips#CanExpandSnippet' used in the mapping-related features for the "cmp-nvim-ultsnips" plugin is not available in this version of UltiSnips. Therefore, the following lines won't work:
I hope this could help someone facing the same issue. Below are the codes I used. If there were better solutions or my code did not follow good practices, please mention it.
Sincerely
-- Ultisnips.lualocalfunctioninit()
localsnip_folder='/.config/nvim/UltiSnips'vim.g.UltiSnipsExpandTrigger='<Tab>'vim.g.UltiSnipsJumpForwardTrigger='<Tab>'vim.g.UltiSnipsJumpBackwardTrigger='<S-Tab>'vim.g.UltiSnipsSnippetDirectories= {(os.getenv("HOME") ..snip_folder), "UltiSnips"}
-- Setup operation result variables for expand and jump operationsvim.g.ulti_expand_or_jump_res=0vim.g.ulti_jump_backwards_res=0endreturn {
"SirVer/ultisnips",
version="*",
init=init,
lazy=false,
}
-- nvim-cmp.lua-- This file sets up auto-completion with Ultisnips and otherslocalfunctionconfig()
-- Load cmp_nvim_ultisnips plugin firstlocalcmp_ultisnips=require("cmp_nvim_ultisnips")
localcmp_ultisnips_opts= {
filetype_source="treesitter",
show_snippets="expandable",
documentation=function(snippet)
returnsnippet.description.."\n\n" ..snippet.valueend,
}
cmp_ultisnips.setup(cmp_ultisnips_opts)
-- Config nvim-cmp-- local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")localcmp=require("cmp")
localcmp_opts= {
snippet= {
expand=function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
-- windows = {-- -- completion = cmp.config.window.bordered(),-- -- documentation = cmp.config.window.bordered(),-- },mapping=cmp.mapping.preset.insert({
['<C-n>'] =cmp.mapping.select_next_item(),
['<C-p>'] =cmp.mapping.select_prev_item(),
['<C-d>'] =cmp.mapping.scroll_docs(3),
['<C-f>'] =cmp.mapping.scroll_docs(3),
['<CR>'] =cmp.mapping.confirm({ select=true }),
["<Tab>"] =cmp.mapping(function(fallback)
-- cmp_ultisnips_mappings.expand_or_jump_forwards(fallback)vim.fn["UltiSnips#ExpandSnippetOrJump"]()
ifvim.g.ulti_expand_or_jump_res==0then-- Operation failed, input tab, and call fallbackvim.fn["feedkeys"](vim.api.nvim_replace_termcodes("<Tab>", true, true, true), 'n')
fallback()
endend, { "i", "s" }),
["<S-Tab>"] =cmp.mapping(function(fallback)
-- cmp_ultisnips_mappings.jump_backwards(fallback)vim.fn["UltiSnips#JumpBackwards"]()
ifvim.g.ulti_jump_backwards_res==0then-- Operation failed, input tab, and call fallbackvim.fn["feedkeys"](vim.api.nvim_replace_termcodes("<S-Tab>", true, true, true), 'n')
fallback()
endend, { "i", "s" }),
}),
sources=cmp.config.sources({
{ name='ultisnips' },
{ name='nvim_lsp' },
}, {
{ name='buffer' },
{ name='path' },
}),
}
cmp.setup(cmp_opts)
-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below-- Set configuration for specific filetype.--[[ cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, }, { { name = 'buffer' }, }) }) require("cmp_git").setup() ]]---- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).cmp.setup.cmdline({ '/', '?' }, {
mapping=cmp.mapping.preset.cmdline(),
sources= {
{ name='buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).cmp.setup.cmdline(':', {
mapping=cmp.mapping.preset.cmdline(),
sources=cmp.config.sources({
{ name='path' }
}, {
{
name='cmdline',
option= {
ignore_cmds= { 'Man', '!' }
},
}
}),
matching= { disallow_symbol_nonprefix_matching=false }
})
-- -- Set up lspconfig.-- local capabilities = require('cmp_nvim_lsp').default_capabilities()-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.-- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {-- capabilities = capabilities-- }endreturn {
"hrsh7th/nvim-cmp",
dependencies= {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"SirVer/ultisnips",
"quangnguyen30192/cmp-nvim-ultisnips",
"neovim/nvim-lspconfig",
},
config=config,
version="*",
}
The text was updated successfully, but these errors were encountered:
Greetings. I set up ultisnips' global variables, cmp_nvim_ultisnips, and neovim-cmp, in their respective order with Lazy.vim plug-in manager. (I will provide the full configuration code at the end.)
When I hit
<tab>
in a document, the following error pops up:Based on Lazy.vim info panel, the ultisnips' version info and cmp-nvim-ultisnips' version info are here:
The function 'UltiSnips#CanExpandSnippet' used in the mapping-related features for the "cmp-nvim-ultsnips" plugin is not available in this version of UltiSnips. Therefore, the following lines won't work:
After researching a little bit, my workaround is using the method mentioned in
:h UltiSnips-trigger-functions
as follows:I hope this could help someone facing the same issue. Below are the codes I used. If there were better solutions or my code did not follow good practices, please mention it.
Sincerely
The text was updated successfully, but these errors were encountered: