So I got YouCompleteMe working for python autocompletion. Whenever I use a . operator such as:
import sys;
sys.
It shows the correct suggestions. Note that I didn't have to hit CtrlSpace

But when I type the word 'import', it doesn't show any suggestion.

I have to enter CtrlSpace in order for it to show the correct suggestion.

I want it to automatically suggest without me having to press "ctrl-space". Is there a way to fix it?
Btw, here is my output of ':YcmDebugInfo':

And the value of my g:ycm_min_num_of_chars_for_completion is 2.
You can do that with the g:ycm_semantic_triggers option. For instance, if you want semantic completion to automatically trigger after typing two characters:
let g:ycm_semantic_triggers = {
\ 'python': [ 're!\w{2}' ]
\ }
or if you just want to automatically complete import statements:
let g:ycm_semantic_triggers = {
\ 'python': [ 're!(import\s+|from\s+(\w+\s+(import\s+(\w+,\s+)*)?)?)' ]
\ }
@micbou
Wow! It actually works, thank you. Is it alright if you give me a short explanation of the line
'python': [ 're!\w{2}' ]?
Like what does it mean? Because I want to enable it in javascript as well. Thank you again.
This line adds a list of triggers to the python filetype: re!\w{2} in this case. The re! prefix tells YCM that the rest of the string is a Python regular expression: \w matches any alphanumeric character and {2} repeats the match exactly twice so we are telling YCM to trigger semantic completion for Python when there are exactly two alphanumeric characters.
@micbou Alright thank you!
Most helpful comment
You can do that with the
g:ycm_semantic_triggersoption. For instance, if you want semantic completion to automatically trigger after typing two characters:or if you just want to automatically complete
importstatements: