Installation

Configuration

C/C++

YCM uses a python script called .ycm_extra_conf.py to set project wide settings, needed to provide completion and syntax check. A brief introduction to essential configuration follows, for details and advanced options see the upstream documentation.

Extra conf structure

A sample .ycm_extra_conf.py may be found here. You should save a copy of this file in your project folder and customize it with adequate settings for your source files. The most important settings (which usually suffices for a minimal configuration) are the -x and --std options, which respectively tell to the sintax checker the language used in the project and the standard followed. The -x value may be set to c or c++, while common values for the --std are --std=c89, --std=c99, --std=c11, --std=c14 and their respective c++ version. The standard parameter will determine the warning and the errors in the syntax check (e.g., a line commented with // will be marked as unallowed in C89, but not under following versions of the standard).

A third party script and vim plugin for the automatic generation of the .ycm_extra_conf.py is avaible on this repo.

Extra conf location

The program searches for the .ycm_extra_conf.py file on startup in the current source file directory and in its parent folders. If the file is not found, YCM features are not avaible. A global file (used as fallback when a local extra conf file is not found) may be set adding the following to ~/.vimrc:

~/.vimrc

let g:ycm_global_ycm_extra_conf = '/path/to/the/file'

Being the extra conf file a python script, when a file is found a confirmation is asked for security reason before to load it. This behaviour may be disabled adding the following to ~/.vimrc:

~/.vimrc

let g:ycm_confirm_extra_conf = 0

For a less unsecure solution, when the confirmation is enabled an extra conf file blacklist/whitelist may be set assigning a list of patterns to the ycm_extra_conf_globlist variable. A file matching one pattern is blacklisted if the pattern begins with !, whitelisted otherwise, confirmation is asked if the file does not match any pattern. Rule precedence is determined by the order, and the first match is applied. Some glob pattern rules are avaible:

* matches everything

? matches any single character

[seq] matches any character in seq

[!seq] matches any char not in seq

In example, with the following setting

~/.vimrc

let g:ycm_extra_conf_globlist = ['~/dev/*','!~/*']

any file in ~/dev will be whitelisted, any in ~/ will be blacklisted, and due to order precedence any file in ~/ excepted the ~/dev folder will be blacklisted.

Java

For Java completion, a project file should be present and Eclim headless server must be running.

Place your C# files in PROJECT directory and do not forget to manually add them at the bottom of PROJECT/PROJECT.csproj.

Now YouCompleteMe should work for C# files in that directory and you can build the project. To compile the project from inside Vim:

:!xbuild

Troubleshooting

Remember that it might take some time for YouCompleteMe to generate a list of completion strings.

The following commands are available for diagnostics:

:messages - show previous errors or messages from Vim

:YcmDiags

:YcmDebugInfo

E764: Option 'omnifunc' is not set

If this happens for Java files, you forgot to put this in your .vimrc:

~/.vimrc

let g:EclimCompletionMethod = 'omnifunc'

No completion in Java files

Make sure eclimd daemon is running:

$ ps -ax|grep eclimd

and that you have first generated project files.

URLError: <urlopen error [Errno 111] Connection refused>

This error appears when you do not have a .sln file in current or parent directory.

RuntimeError: Error starting OmniSharp server: no solutionfile found

Same as above.

Ctrl+space does not trigger the completion anymore in terminal vim

Due to a bug in KDE Framework5/Qt5, the Ctrl+space key combination is not recognized by Konsole5. A temporary workaround may be to set another trigger for YouCompleteMe completion, changing the value of the variable ycm_key_invoke_completion, e.g. to use Ctrl-b instead of Ctrl-space add the following to the ~/.vimrc config file: