Search code examples
vimvim-pluginultisnips

vim - UltiSnips not working with YCM


when I use YouCompleteMe and UltiSnips together, I encounter 2 errors:

  1. I can type a snip pattern and the YCM dropdown menu recognizes it, however when I tab down to the snip in the menu, I cannot expand it. I have tried remapping g:UltiSnipsExpandTrigger to several different key (c-l, c-j, c-k, c-l, F5) and still have no success. I have yet to see UltiSnips actually expand a snippet.
  2. When I open a new file, e.g. a.py, YCM does not recognize ultisnippets in the file. I am basically trying to recreate the usage demonstrated in the nice gif on the ultisnips git page. Typing #! is not recognized by YCM, but if I open an already saved python file, #! will be recognized.

Perhaps these two problems are related.

Thanks for your time.


Solution

  • I solved this problem with the following configurations:

    UltiSnips:

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

    YCM:

    let g:ycm_complete_in_comments = 1 
    let g:ycm_seed_identifiers_with_syntax = 1 
    let g:ycm_collect_identifiers_from_comments_and_strings = 1