Skip to content

Instantly share code, notes, and snippets.

@NerdDiffer
Last active October 27, 2023 11:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NerdDiffer/765b742a0833ab021cc3063c0a04ee77 to your computer and use it in GitHub Desktop.
Save NerdDiffer/765b742a0833ab021cc3063c0a04ee77 to your computer and use it in GitHub Desktop.
YCM on my Manjaro system

Building YCM on Manjaro

YouCompleteMe, the Vim code-completion engine, on my laptop running with Manjaro. This is extracted from the full installation guide.

Sifting through YCM's documentation is a pain, so I'm preserving the steps that work on my system and fit my personal requirements. Those are:

  • Use system-provided clang library.
    • Docs recommend using clang versions >= 3.8. My distro provides this.
  • Provide auto-completion support for C-family languages.
  • Do not use system-provided version of boost.

Check vim requirements

  • vim version >= 7.4.143
    • :version
  • check for python support:
    • :echo has('python') || has('python3')

Install YCM

  • Add Vallorc/YouCompleteMe to your vimrc
  • type :PluginInstall from inside of vim.

Support auto-completion for C-family languages

For completion support for C-family languages, install clang:

  • pacman -S clang

Compile libraries

Take these steps to compile:

YCM_BUILD_DIR=$HOME/builds/ycm_build
mkdir -p $YCM_BUILD_DIR && cd $YCM_BUILD_DIR
rm ./* -rf

# Generate the make files
cmake -G "Unix Makefiles" \
  -DUSE_SYSTEM_LIBCLANG=ON \
  . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

# Compile:
cmake --build . --target ycm_core

Set up support for additional languages

YCM_3RD_PARTY_DIR=$HOME/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party

function make_err_msg() {
  local cmd=$1
  echo "$cmd executable not found. Please install $cmd, add to PATH. Then build YCM support"
}

# build go support
if [[ -x $(which go) ]]; then
  cd "$YCM_3RD_PARTY_DIR/gocode"
  pwd
  go build
else
  make_err_msg go
fi

# build typescript
if [[ -x $(which npm) ]]; then
  npm install -g typescript
else
  make_err_msg 'node & npm'
fi

# build js support
if [[ -x $(which npm) ]]; then
  cd "$YCM_3RD_PARTY_DIR/tern_runtime"
  pwd
  npm install --production
else
  make_err_msg 'node & npm'
fi

# build rust support
if [[ -x $(which cargo) ]]; then
  cd "$YCM_3RD_PARTY_DIR/racerd"
  pwd
  cargo build --release
else
  make_err_msg 'rust & cargo'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment