Skip to content

Instantly share code, notes, and snippets.

@vtellier
Last active February 15, 2022 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtellier/5409373af06340ff44d17e225cde406f to your computer and use it in GitHub Desktop.
Save vtellier/5409373af06340ff44d17e225cde406f to your computer and use it in GitHub Desktop.

Installing YouCompleteMe on Ubuntu 18.04

Install vim 8.2:

sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim

See https://www.tecmint.com/install-vim-in-linux/

Install gcc-8 and g++-8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo update-alternatives --config gcc # And make sure gcc-8 is activated

See https://askubuntu.com/a/1028656/660737

Install Vundle

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Then add the following to the beginning of your ~/.vimrc:

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Install YouCompleteMe

  • Add the following to your ~/.vimrc
" YouCompleteMe via github
Plugin 'ycm-core/YouCompleteMe'
  • Open vim and type :PluginInstall
  • You will get an error (YCM core missing or something like that)
  • Go to ~/.vim/bundle/YouCompleteMe and install YCM with the module you want, for example: python3 install.py --clangd-completer --clang-tidy
  • Open vim and type :PluginInstall

Generate and link the compilation database

Only if you use cmake:

  • Add set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) to your CMakeLists.txt
  • Rebuild your compilation chain: rm -fr build && cmake -S . -B build
  • Link the compilation dabase to the root of your project: ln -s build/compile_commands.json .
  • Add compilation_commands.json to your .gitignore

For more details or if you do not use cmake: https://github.com/ycm-core/YouCompleteMe#option-1-use-a-compilation-database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment