How to expand an UltiSnips snippet using <c-y> in the YouCompleteMe pop-up menu?

∥☆過路亽.° 提交于 2020-02-04 10:57:39

问题


This problem really hit a nerve with me. I have both YouCompleteMe and UltiSnips installed on my vim 8.0 editor. It seems that both of these plugins use the tab key for doing the auto-completion and that has created an incompatibility that has been also addressed by this question. My question is more specific, though. When I write a piece of code like <html, there is a pop-up menu that shows me all related snippets for that code.

I use the tab key to navigate through that menu but when I hit ctrl+y to accept and therefore expand one of these snippets, nothing happens! I think this structure suggests that it's possible to somehow choose one of those snippets from the menu without trying to define a shortcut for UltiSnip. What am I doing wrong? How should I navigate and choose those snippets?

I also would not want to stuff my vim with any new plugins (like supertab, etc.).


回答1:


The solution was actually a lot simpler than I expected. In the beginning, I felt stupid for not knowing it but when I find a similar question like this one, I thought that probably many were fallen into the same trap.

I don't know whether to name it a bug or not but it's how Ultisnips and YouCompleteMe work together. In order to expand a snippet, you have to write the initializer exactly as it's defined. Of course, this seems obvious, but when you see a pop-up menu of different snippets, you might think they can be chosen but it only works if you already wrote the snippet initializer exactly as it's defined.

So when a snippet is called "html5"---as it's shown in my question---writing an extra opening bracket (<) will cause it to stop working. It cannot be expanded.


Also, don't forget to check out Siegfried Gevatter configuration. It's not possible to use tab key both for navigating into the pop-up menu and expanding the snippets.

P.S. It was nice if navigating through the pop-up menu could change the whole word (including the angle bracket), not just what succeeds it. This feature works this way in most of the other editors I see and that's probably why I wasn't able to spot the problem in the beginning.



来源:https://stackoverflow.com/questions/59685512/how-to-expand-an-ultisnips-snippet-using-c-y-in-the-youcompleteme-pop-up-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!