5

I use YouCompleteMe and it works great (after some setting up woes) for both C/C++ and Python code. However, it tries to complete things in text files such as ReStructured text, markdown, etc...

The error I keep getting is:

-- User defined completion (^U^N^P) Pattern not found

How can I stop it form doing so?

I did try this:

autocmd FileType c,cpp,python let g:ycm_global_ycm_extra_conf = "~/.ycm_extra_conf.py"
autocmd FileType c,cpp,python let g:ycm_collect_identifiers_from_tags_files = 1
autocmd FileType c,cpp,python let g:ycm_complete_in_comments = 0
autocmd FileType c,cpp,python let g:ycm_complete_in_strings = 0
autocmd FileType c,cpp,python let g:syntastic_enable_signs=1
autocmd FileType c,cpp,python let g:syntastic_error_symbol = '✗'
autocmd FileType c,cpp,python let g:syntastic_warning_symbol = '⚠'
autocmd FileType c,cpp,python let g:ycm_confirm_extra_conf = 0

But the error still persists. I even tried adding a g:ycm_filetype_specific_completion_to_disable command like so:

let g:ycm_filetype_specific_completion_to_disable = {
      \ 'rst': 1
      \}

But the error still persists.

2
  • Is a solution to enable it for only certain files ok? Or do you also want it for example disabled in C comments but enabled in code?
    – Shahbaz
    Commented Mar 12, 2015 at 10:38
  • @Shahbaz: Enabling it only for certain files types is a solution I'd accept. However, your second sounds awesome if it were possible! ^_~ Commented Mar 12, 2015 at 10:51

2 Answers 2

8

The command g:ycm_filetype_whitelist was the one I needed!

let g:ycm_filetype_whitelist = { 'cpp': 1, 'c': 1, 'python':1 }

Finally, to get ride of this message altogether, the answer is in the FAQ. Basically, update to Vim 7.4.314 or later and it shall go away.

1

This would be a generic answer, since I don't know YouCompleteMe. You mentioned in the comments that you would be ok with enabling this plugin on a per-file basis, so here is the solution:

autocmd FileType c,cpp <command>

The command above executes command whenever a c or cpp filetype is detected. If you have filetype detection enabled on startup, this means the command would execute when you open a c or cpp file. Furthermore, remember that the effect may be on all opened splits (see set vs setlocal). :h autocmd and :h filetypes have additional information.

That said, you need to find the command that enables/disables YouCompleteMe and stick it in an autocommand.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.