← Back to Valloric/YouCompleteMe

How to Deploy & Use Valloric/YouCompleteMe

YouCompleteMe Deployment and Usage Guide

Prerequisites

System Requirements

  • Vim 8.1.2269 or higher, or Neovim 0.3.1 or higher
  • Python 2.7+ or Python 3.3+ (for the Vim plugin)
  • CMake 3.13.4 or higher (for building the C++ components)
  • Python 3.5.0 or higher (for the YCM server)

Development Dependencies

  • Git (for cloning the repository)
  • C++ compiler (GCC 5.0+, Clang 6.0+, or MSVC 2015+)
  • Python development headers (for building Python bindings)

Installation

macOS

# Clone the repository
git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/pack/plugins/start/YouCompleteMe

# Install with Python semantic completion
cd ~/.vim/pack/plugins/start/YouCompleteMe
python3 install.py --clang-completer --java-completer --rust-completer --go-completer

Linux 64-bit

# Clone the repository
git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/pack/plugins/start/YouCompleteMe

# Install with all semantic completers
cd ~/.vim/pack/plugins/start/YouCompleteMe
python3 install.py --all

Windows

# Clone the repository
git clone https://github.com/ycm-core/YouCompleteMe.git %USERPROFILE%\vimfiles\pack\plugins\start\YouCompleteMe

# Install with C-family and Python semantic completion
cd %USERPROFILE%\vimfiles\pack\plugins\start\YouCompleteMe
python install.py --clang-completer --java-completer

Alternative: Vim Packages (Recommended)

# Create the package directory
mkdir -p ~/.vim/pack/plugins/start

# Clone the repository
git clone https://github.com/ycm-core/YouCompleteMe.git ~/.vim/pack/plugins/start/YouCompleteMe

# Install
cd ~/.vim/pack/plugins/start/YouCompleteMe
python3 install.py

Configuration

Vim Configuration

Add the following to your ~/.vimrc or init.vim:

" YouCompleteMe configuration
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_auto_trigger = 1
let g:ycm_show_diagnostics_ui = 1
let g:ycm_enable_diagnostic_signs = 1
let g:ycm_enable_diagnostic_highlighting = 0
let g:ycm_always_populate_location_list = 1
let g:ycm_open_loclist_on_ycm_diags = 1
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']
let g:ycm_key_list_previous_completion = ['<S-TAB>', '<Up>']
let g:ycm_key_invoke_completion = '<C-Space>'
let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'

Language-Specific Configuration

C/C++ Configuration

Create a .ycm_extra_conf.py file in your project root:

def Settings(**kwargs):
    return {
        'flags': [
            '-Wall',
            '-Wextra',
            '-Werror',
            '-std=c++17',
            '-x',
            'c++',
            '-I',
            '.',
        ],
        'override_filename': kwargs['filename']
    }

Python Configuration

let g:ycm_python_interpreter_path = '/usr/bin/python3'
let g:ycm_python_sys_path = []
let g:ycm_extra_conf_vim_data = ['&filetype']
let g:ycm_log_level = 'debug'

Build & Run

Development Environment

# Clone and install in development mode
git clone https://github.com/ycm-core/YouCompleteMe.git
cd YouCompleteMe
python3 install.py --all --clang-completer --java-completer --rust-completer --go-completer

# Test installation
vim --version | grep YCM

Running Locally

  1. Start Vim/Neovim
  2. Open a source file (e.g., main.cpp, example.py)
  3. Type code to trigger completions automatically
  4. Use <TAB> to accept completions, <C-Space> to manually invoke

Production Deployment

For production use, the plugin is installed directly into your Vim/Neovim configuration directory. No separate server process needs to be managed.

Troubleshooting

Common Issues

"YouCompleteMe unavailable: requires Vim compiled with Python support"

Solution: Ensure your Vim/Neovim is compiled with Python support:

# For Vim
vim --version | grep +python
# For Neovim
nvim --version | grep +python3

"Server startup failed"

Solution: Check Python version compatibility:

python3 --version
# Must be 3.5.0 or higher

Compilation Errors

Solution: Ensure all build dependencies are installed:

# Ubuntu/Debian
sudo apt-get install build-essential cmake python3-dev

# macOS
xcode-select --install
brew install cmake

No Completions Appear

Solution: Check if YCM is loaded:

:echo has('python3')
:echo has('python')
:YcmDebugInfo

Diagnostic Display Issues

If diagnostics aren't showing:

let g:ycm_enable_diagnostic_signs = 1
let g:ycm_enable_diagnostic_highlighting = 1

Performance Issues

For large projects, configure the identifier database:

let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_use_ultisnips_completer = 0

Support and Contact

For issues not resolved by this guide, visit the GitHub Issues page or join the Gitter room.

Note: Do NOT go to #vim on Freenode for support. Please contact the YouCompleteMe maintainers directly.