How to Make YouCompleteMe Compatible with UltiSnips
Although NCC can also do auto-completions, it was so slow that I had to turn it off. For a long time, I have been doing completions by triggering the TAB key manually. YCM is much faster in most conditions, but I found it is also slow for C source files. Moreover, with the power of jedi, YCM makes completions of python sources much wiser, which is very convenient.
Then a problem raised again. It’s the confiliction of mappings for Tab key between YCM and UltiSnips. Many people changed the default mapping of either YCM or UltiSnips, but I cannot tolerate that. I insist that the most convenient way is UltiSnips having a higher priority above YCM, which means, when Tab is triggered, UltiSnips expands the snippet, if there is not a valid snippet, YCM will take over the job.
I have to say that UltiSnips is a well-written script, it passes Tab key through if there is not a snippet. Then SuperTab will be triggered. Since the default action of SuperTab is customizable, so I can set it to the key-binding of YCM. That is the whole trick.
First, change the default key-binding of YCM to <C-TAB> and <C-S-TAB>:
let g:ycm_key_list_select_completion = ['<C-TAB>’, ‘<Down>’]
let g:ycm_key_list_previous_completion = ['<C-S-TAB>’, ‘<Up>’]
Then set the default action of SuperTab to triggering <C-TAB>:
let g:SuperTabDefaultCompletionType = ‘<C-Tab>’
OK, job done.