How on earth do I set up YCM with CMake or Arch?

380 views
Skip to first unread message

Rain Gloom

unread,
Jan 30, 2016, 3:11:55 PM1/30/16
to ycm-users
It's been several days of Ring TFM and googling and I still couldn't figure out how to get the clang completer to work so I must turn to this group.

I'm using Neovim on Arch Linux and my project uses a really simple CMake setup. The project is on GitHub, it has all relevent files.

My vimrc (well, .config/nvim/init.vim actually) is:
set nocompatible               " be iMproved

call plug#begin('~/.config/nvim/plugged')

function! BuildYCM(info)
  if a:info.status == 'installed' || a:info.force
"
   !./install.sh
  endif
endfunction

Plug 'Valloric/YouCompleteMe', { 'do': function('BuildYCM') }

call plug
#end()

syntax on
let tabsize
= 4
execute
"set tabstop=".tabsize
execute
"set shiftwidth=".tabsize
execute
"set softtabstop=".tabsize
set noexpandtab

I'm also pretty sure I compiled the plugin the right way. As far as I remember, I ended up using the setup.py script with --use-system-clang and --clang-completer and it gave no errors.

NVim can find the python script when I open a cpp file, but when I run it, nothing seems to change. I tried completing "SDL_" and "std::", but nothing shows up besides the basic id list from the current file, C-space does nothing.

I also randomly get the following error, which I can't really put anywhere:
AttributeError: 'module' object has no attribute 'FlagsForFile'
It doesn't seem to affect anything, it just appears on the output thingy on the bottom (sorry, I'm pretty new to Vim and haven't got all the terminology memorized yet).

All in all: CMake generates the json file with the build options, how do I make YCM use it and does it matter if the JSON gets modified while nvim is running?


Sorry for being such a noob, but I really can't seem to make this work.

mbo...@gmail.com

unread,
Jan 30, 2016, 4:38:43 PM1/30/16
to ycm-users
Your .ycm_extra_conf.py file is not properly configured. It must implement the FlagsForFile function. This is why you are getting this AttributeError. As a reference, take a look at the configuration file used by the YCM server.
Since you are using a compilation database, I suggest to copy the whole file, remove the list of flags, and change the following line:
compilation_database_folder = ''
to point to your project (must be an absolute path).
Reply all
Reply to author
Forward
0 new messages