Youcompleteme: YCM not showing snippets

Created on 12 Oct 2014  ·  54Comments  ·  Source: ycm-core/YouCompleteMe

I'm using spf13 with vim 7.4. vim-snippets and UltiSnips are both installed(with Vundle) and I can see them in my .vim /bundles directory. When I start typing YCM only shows me completions from the file (I tested it under Ruby and Python files). However,when I type class and press <C-j> Vim will complete the block.

When I enter :YcmCompleter in VIM, It gives me an error:

ValueError: No semantic completer exists for filetypes: [u'ruby']

Here is my :version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 11 2014 16:32:30)
Included patches: 1-475
Compiled by BlackEagle
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    -netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl/dyn        +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      +lua/dyn         +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      +X11
-dnd             +modify_fname    +signs           +xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -lncurses -lelf    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

Most helpful comment

I came to this page through this one since I was looking for a solution to my problem: UltiSnips snippet are not displayed in YCM popup menu, but they are inserted after pressing expand trigger (that is UltiSnips works correctly).
I can give you just one more information, which is maybe a big help in understanding what the problem and the solution are: It's enough that I open Vim's help (:h) to get everything work again.

All 54 comments

AFAIK UltiSnips by default does not come with snippets anymore (it's just the snippet engine), you have to get https://github.com/honza/vim-snippets installed as well. Did you do this?

@SirVer might know more.

@Valloric Thanks for your response.
Yes. I have vim-snippets installed(which I mentioned above), but seems that YCM can't find them somehow.

Is the snippet you expand using a regular expression trigger? Those cannot be shown by YCM since partial regular expressions is not supported for pythons regular expression.

If that is not the case and since UltiSnips expands the correct snippet this looks like a YCM issue to me.

@SirVer I used to have neocomplcache.vim, on that I could write cla and see all options starting with cla like class and expand them. With YCM I see nothing.

If that is not the case and since UltiSnips expands the correct snippet this looks like a YCM issue to me.

Please answer this question. If you use try to expand one of the triggers that are defined, does that work? What happens when you use <ctrl>+<tab> (try this in gvim, it does not work on the console).

@SirVer I mentioned at first that if I use c-j I can expand the triggers like class. In gvim when I hit <ctrl>+<tab> I see this on prompt:

1: (class) "class <class_name> def initialize ... end end" (~/.spf13-vim-3/.vim/bundle/vim-snippets/UltiSnips/ruby.snippets:546)
Type number abd <Enter> or click with mouse (empty: cancels):

Same issue here. It works for some filetypes, but not for others. My guess: If an omnicompletion is set, it does not lookup snippets.

@Necoro I just installed honza/vim-snippets and SirVer/ultisnips and tried in a python file where echo &omnifunc is youcomplete#OmniComplete and in a ruby file where echo &omnifunc is rubycomplete#Complete and snippets where showed to me just fine in the completion popup. So Is not that that get in the way :S

Ok, I tested with some more languages -- it works fine in every language except Haskell... That's awkward. I tried to remove all haskell-specific settings (and plugins), but no change. Have to investigate ...

I set up a complete clean slate -- still Haskell is the only language (I encountered), where snippets are not included in the completion.

This is the _complete_ .vimrc, no other configuration involved:

set nocompatible               " be iMproved
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#begin()

" vundle itself
Plugin 'gmarik/vundle'

" Snippet Management
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'

" YCM
Plugin 'Valloric/YouCompleteMe'

call vundle#end()
filetype plugin indent on     " required!

Same thing with Haskell here on OS X.

Sounds like haskell is trying to be clever about something then. I would start digging through the shipped haskell ftplugin to figure out what it is that breaks YCM here.

I just installed Vim and YCM with same configuration of my local vim on a server(Ubuntu 14.04), and YCM works alright there with ruby (couldn't make Haskell work).

differences between my local version and server is first the version (server: 7.4.52, local: 7.4.487) and second is my local version in compiled with following feature which is not available in Ubuntu's vim:

clientserver, clipboard, perl, python3, lua, ruby, X11, xfontset, xterm_clipboard, xsmp_interact

Here is my local version information:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 21 2014 22:36:24)
Included patches: 1-487
Compiled by BlackEagle
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    -netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl/dyn        +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      +lua/dyn         +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      +X11
-dnd             +modify_fname    +signs           +xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong 
--param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E 
-Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXt -lX11 
-lXdmcp -lSM -lICE  -lm -lncurses -lelf    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE 
-Wl,-O1,--sort-common,--as-needed,-z,relro -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil 
-lpthread -lc       

And here is the vim on Ubuntu server:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)
Included patches: 1-52
Modified by [email protected]
Compiled by buildd@
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security 
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl    
-L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions      

So either YCM is not compatible with newer VIM versions or some patch in my local VIM is messing with YCM.

@SirVer the haskell ftplugin consists of only a dozen lines -- and as far as I can see, they don't do anything 'clever':

let s:cpo_save = &cpo
set cpo&vim

let b:undo_ftplugin = "setl com< cms< fo<"

setlocal comments=s1fl:{-,mb:-,ex:-},:-- commentstring=--\ %s
setlocal formatoptions-=t formatoptions+=croql

let &cpo = s:cpo_save
unlet s:cpo_save

edit: Found the issue, it stems from using Unicode in the snippets/haskell.snippet. Should I open a bug with vim-snippets to remove those, or is this an UltiSnips bug? (Question to @SirVer)

edit2: So probably not related to @arashm issue, sorry for this noise in your bug...

UltiSnips deals with unicode just fine. I have tests for german umlauts "äüö" in my test suite. And since you were able to expand snippets even they were not shown by YCM it does not seem to be an UltiSnips issue. Icbw though of course :).

I wouldn't be surprised if it were a Unicode issue in YCM; there's a ton of those around. The underlying candidate matching & filtering engine in ycm_core is not unicode-aware (and making it work would be a huuuuge undertaking) so I try to work around it in various places, but Python makes it super-hard with the whole string/unicode confusion in that language.

If you could narrow this down to a specific test-case, I should be able to track it down and fix it.

I just installed UltiSnips on my MacOS 10.10.2, together with YCM. The snippets don't show up in .tex files but work well with .cpp files. When editing .tex files, when there are multiple matches, the YCM simply treats them all as strings, while some of them should be treated as snippets.

A screenshot of the issue
screen shot 2015-02-28 at 01 28 04

The snippet is begin<tab>, it won't trigger when there is a \ in front I think.

@SirVer Hey, thanks loads for that! I was trying to trigger the snippet for more than three hours.

I can't make it work with any files (vim, python, c/cpp), the only snippets that are shown are the default ones from _.snippets:

In a python file:

date      <snip> (date)
datetime  <snip> (datetime)
ddate     <snip> (ddate)
modeline  <snip> (modeline) "Vim modeline"

Finishing the def and expanding with <Tab> will correctly expand the def snippet.

:YcmRestartServer will disable the default snippets as well.

Here are the relevant parts of my vimrc. The complete file can be found here.

filetype off
set runtimepath& " reset rtp
" remove all autocommands
autocmd!

set runtimepath+=$XDG_DATA_HOME/vim/vundle
call vundle#rc('$XDG_DATA_HOME/vim')

Plugin 'gmarik/vundle'

Plugin 'valloric/youcompleteme'
" snippets
Plugin 'sirver/ultisnips'
Plugin 'honza/vim-snippets'

" suppord xdg specs
" remove entries first
set runtimepath -=$HOME/.vim
set runtimepath -=$HOME/.vim/after
set runtimepath -=$XDG_CONFIG_HOME/vim
set runtimepath -=$XDG_CONFIG_HOME/vim/after
" then prepend and append them
set runtimepath ^=$XDG_CONFIG_HOME/vim
set runtimepath +=$XDG_CONFIG_HOME/vim/after

filetype plugin indent on
" UltiSnips {{{2
let g:UltiSnipsEditSplit = 'vertical'
let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
let g:UltiSnipsExpandTrigger = "<C-L>"
let g:UltiSnipsJumpForwardTrigger = "<C-L>"
let g:UltiSnipsJumpBackwardTrigger = "<C-H>"

" youcompleteme {{{2
let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
let g:ycm_extra_conf_vim_data = ['getcwd()']
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_insertion = 1

I've had the same issue as Ram-Z for an amount of time - perhaps two weeks. I cannot determine what caused it, but it has been either the latest update to vim or the latest update to YCM, or UltiSnips, or vim-snippets

Vim version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 16 2015 10:01:43)
Included patches: 1-622
Modified by Gentoo-7.4.622

Relevant parts of vimrc:

" YouCompleteMe
let g:ycm_global_ycm_extra_conf=expand('~/.vim/ycm_extra_conf.py')
let g:ycm_register_as_syntastic_checker = 1
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_collect_identifiers_from_tags_files=1

" UltiSnips
"let g:UltiSnipsSnippetsDir=$HOME.'/.vim/UltiSnips/'
"let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnipsExpandTrigger='<f10>'
let g:UltiSnipsListSnippets='<c-f10>'
let g:UltiSnipsJumpForwardTrigger='<f10>'
let g:UltiSnipsJumpBackwardTrigger='<s-f10>'

The commented "let lines have been attempted uncommented. This changed nothing.

I was using Vim 7.4.417, but upgraded now .617, and still experiencing this, latest versions of ycm and UltiSnips

Is your vim built against both python2 and python3? Mine was and this issue was gone when I rebuild it against python2 only.

@Ram-Z I assumed this could be the issue based on what @arashm commented earlier (The vim that the snippets worked for was built only against python2), but decided against assuming so since it used to work with python3 linked in, as far as I recall.

I'll try that, and I'll try building it against a newer Python3 and report back on this.

Okay:

Compiling against Python 3.4 as opposed to Python 3.3 made no difference. Compiling against _only_ Python 2.7 as opposed to Py2 and Py3 fixed this issue.

Dunno what the actual _problem_ is but at least there's a solution to it, now.

I can offer a theory, but cannot test it since you can no longer build a Vim against py3 and py2 under Mac OS it seems.

Ultisnips defaults to py3 if it is available while YCM requires py2. Maybe US used py3 and therefore did no longer work with YCM in your case. You can force US to use python2, maybe that fixes it: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L107

Yes, that does seem to fix it! Compiling vim with both python3 and python2 support and forcing UltiSnips to use Python2 fixes the issue for me. I wonder if Python2 should be implicitly forced in case YCM support is enabled?

This still doesn't explain why the snippets from the default snippet file appear - but I suppose that could just be some strange, strange side effect.

Setting the flag let g:UltiSnipsUsePythonVersion = 2 fixes the issue for me, but it changes the YCM behaviour somewhat.

After setting the flag , a user is prompted to load .ycm_extra_conf.py before vim's window appears.
Without the flag, the prompt appears in a command bar, but after a user input.

Tried to debug ycm + ultisnips + haskell type and got this

2015-08-27 04:55:21,905 - INFO - Received event notification
Traceback (most recent call last):
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 861, in _handle
    return route.call(**args)
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1734, in wrapper
    rv = callback(*a, **ka)
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 100, in wrapper
    return callback( *args, **kwargs )
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/hmac_plugin.py", line 62, in wrapper
    body = callback( *args, **kwargs )
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 64, in EventNotification
    getattr( _server_state.GetGeneralCompleter(), event_handler )( request_data )
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/general/general_completer_store.py", line 95, in OnBufferVisit
    completer.OnBufferVisit( request_data )
  File "/Users/onemanstartup/Code/dotfiles/vim2/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/general/ultisnips_completer.py", line 53, in OnBufferVisit
    for snip in raw_candidates ]
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2192' in position 0: ordinal not in range(128)

Opening c file is ok. And c file works and shows snippets, but haskell don't.

one of the haskell snippet files or the file you are currently editing contains a non unicode character at the very beginning. Python's string decoding chokes on that.

Yeah. I could think myself a little more about that. Thanks. https://github.com/dag/vim2hs had snippets which I just open & saved and it works now.
UPD: Nope. Strange, it worked. I will try to investigate.
UPD. Found offensive lines in vim-snippets/snippets/haskell.snippets

 snippet λ
    \\${1:x} -> ${0:expression}
 snippet ←
    ${1:a} <- ${0:m a}
 snippet →
    ${1:m a} -> ${0:a}

so it is not a non unicode, but unicode :laughing:

I had the same issue and @Mike-Now 's fix worked for me. Setting let g:UltiSnipsUsePythonVersion = 2 displays the snippets properly

The let g:UltiSnipsUsePythonVersion = 2 worked for me too. Closing the issue.

I can't get Ruby-completions to show up even after having @fennekki's settings and the let g:UltiSnipsUsePythonVersion = 2 statement in my ~/.vimrc. Installed vim is macvim 7.4 patches 1-909, used via console, installed via homebrew.

:set omnifunc? gives omnifunc=rubycomplete#Complete
and :YcmCompleter gives ValueError: No semantic completer exists for filetypes: [u'ruby']

It kinda works with .c files though...
:set omnifunc? gives omnifunc=youcompleteme#OmniComplete
and :YcmCompleter gives

ValueError: Supported commands are:
GoToDefinition
GoToDeclaration
GoTo
GoToImprecise
GoToInclude
ClearCompilationFlagCache
GetType
GetParent
FixIt
GetDoc
GetDocQuick
See the docs for information on what they do.

Any tips?

@suan we don't have a native support for ruby: this means that you don't get any GoTo functionality. So you have to rely on some vim omnifunc.

I came to this page through this one since I was looking for a solution to my problem: UltiSnips snippet are not displayed in YCM popup menu, but they are inserted after pressing expand trigger (that is UltiSnips works correctly).
I can give you just one more information, which is maybe a big help in understanding what the problem and the solution are: It's enough that I open Vim's help (:h) to get everything work again.

Indeed @Aster89 , it seems to be doing the trick for me as well.

So, is this a bug? or a feature? Or a buggy feature?

Typing :doautocmd FileType as suggested on the README, also fixes the issue. While I can see sometimes the snippets, most of the time I don't. So, I guess YCM most of the time does not call UltiSnipsAddFiletypes for optimization. This is either the intended behavior, or their is a bug somewhere.

Also, it's not just entering help that fixes the issue. Typing ":cope" to open quickfix, and then you will have your snippets working again. Both :h and :cope "fix" the issue by forcing the FileType command. Which is the same by the README suggestion.

In the unlikely case that this is not a bug, but intended behavior, can we get an option instead?

Yes, I imagined that it's a matter of file type..
Btw you wrote "While I can see sometimes the snippets, most of the time I don't"; do you mean you're experiencing a kind of randomness?

Most of the times when autocomplete pops up the snippets are missing.
However, there are few times that YCM shows the snippets.
I can't reproduce when or how this happens.

I played a bit with the sources and saw that this line here gets all the snippets. And this is called once the buffer is open (OnBufferVisit()).

So YCM does query and gets all theUltiSnips. But somehow they don't make it to the final popup list.
They are either ignored, or maybe overwritten e.g. if another option is enabled (I checked and the option that puts ctags in the autocomplete seems not to interfere ).

It's happening for me also. let g:UltiSnipsUsePythonVersion = 2 as commented at https://github.com/Valloric/YouCompleteMe/issues/1214#issuecomment-149054851 doesn't fix the issue for me. Opening :h as commented at https://github.com/Valloric/YouCompleteMe/issues/1214#issuecomment-278369934 make it behave normally.

I noticed that I don't get completions opening an empty file as vim sample.cpp, but if I open vim first, and then :e sample.cpp, completions are correct. I guess there's some issue in the loading phase.

Oh, btw I should say that I've been experiencing this problem since the last plugin update a couple of days ago.

Same for me.

I can only reproduce this when opening a file as parameter to vim command (or by loading a vim session). When opening vim first and using :e (or :so <session file>), it avoids the issue as far as I see.

@Aster89 you may open another bug report as this one seems settled throught other means.

@oblitum, are you sure? The problem is exactly the same. Should I open another bug report with practically the same title?

@Aster89 hmm, to tell the truth I don't know (if it were my repo I won't mind because despite the same title, context is now other). cc @Valloric.

As a temporary solution, I press <F5> after opening a file:
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>:doautocmd FileType<CR>

Diagnostics appear in the file, and also the snippets are showing.
What is weird though is that YCM queries and indeed gets all the snippets as soon as a file is opened.

These workarounds force YCM to get snippets once again, and this time they are displayed.

@oblitum are you using Terminal Vim or GVim? Because for GVim I think that yes we have a problem and #2475 will fix it.

@vheon I'm on terminal.

@Aster89 did you open the new issue regarding this bug?

I'll try to do it this night.

@zatan , done.

Was this page helpful?
0 / 5 - 0 ratings