为什么UltiSnips无法识别我自己的片段? [英] Why UltiSnips does not recognize my own snippets?
问题描述
当前,我在Vim中使用 YouCompleteMe ,然后我已经安装了 UltiSnips 和 vim-snippets . UltiSnips 和 YouCompleteMe 兼容并且可以正常运行;但是,当我定义自己的代码段时就会出现问题,因为这些代码段无法识别.
Currently I use YouCompleteMe in Vim, then I have installed UltiSnips and vim-snippets with vundler. UltiSnips and YouCompleteMe are compatible and work properly; however, the problem comes when I define my own snippet because these are not recognized.
我怀疑使用UltiSnipsEdit
函数时出现问题,因为它在我的主目录中而不是.vim
文件夹中创建了UltiSnips
文件夹.例如,当我使用R脚本并且使用UltiSnipsEdit
时,它将在/home/UltiSnips
中创建r.snippets
文件.然后定义一个片段以进行测试:
I suspect that the problem comes when I use the UltiSnipsEdit
function because it creates the UltiSnips
folder in my home directory and not inside the .vim
folder. For example, when I am working with R scripts and I use UltiSnipsEdit
, it creates the r.snippets
file inside /home/UltiSnips
. Then I define a snippet just to test:
snippet test "Testing snip for R."
# snipp is working
endsnippet
保存文件后,该代码段不会出现在 YouCompleteMe 列表中,也不会使用:UltiSnipsExpandTrigger
展开(在我的情况下为<c-l>
).
After saving the file, the snippet does not apper on the list of YouCompleteMe nor is expanded with :UltiSnipsExpandTrigger
(<c-l>
in my case).
推荐答案
在 .vimrc 文件中添加let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']
使其可以工作.
Adding let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']
to the .vimrc file makes it works.
这篇关于为什么UltiSnips无法识别我自己的片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!