3

I would like to set YouCompleteMe correctly so that I do not get the following warning on a c++ file:

...

auto [k,v] = mapIt; // some map iterator

...
decomposition declarations are a C++17 extension

I added

   flags.append( '-std=c++17' ) 

in

~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py

and added the following to

~/.vimrc
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
D. Ben Knoble
  • 4,273
  • 1
  • 20
  • 38
Frankie Y. Liu
  • 121
  • 2
  • 9
  • 1
    I'm not sure StackOverflow is the best channel to get help for YouCompleteMe. I suggest that you give a look [here](https://github.com/ycm-core/YouCompleteMe#help-advice-support). – Enlico Feb 05 '20 at 21:19
  • I’ve rolled-back your edits. The correct way to answer a question on Stack Exchange is to post an answer – D. Ben Knoble Feb 06 '20 at 14:20

2 Answers2

4

I decided to remove the previous installation and do everything from the command line (assuming previous Vundle installation as recommended in YouCompleteMe docs).

# typical installation directory for vundle and pathogen
cd ~/.vim/bundle

# clone the repository for YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe

# and all submodules
git submodule update --init --recursive

# install
python3 install.py --clang-completer

Next I created a simple ycm_extra_conf.py (without the .dot) containing:

def FlagsForFile ( filename, **kwargs ):
    return {
        'flags': ['-x', '-Wall', '-Wextra', '-Werror', '-std=c++2a']
    }

I added the c++2a flag, but c++17 should also work.

Then point to this file in your ~/.vimrc file.

let g:ycm_global_ycm_extra_conf = '$HOME/.vim/bundle/YouCompleteMe/ycm_extra_conf.py'

Note: you may have to add to your ~/.vimrc

Plugin 'Valloric/YouCompleteMe'  

in your vimrc file.

And run (from vim)

:PluginInstall

I didn't do these steps as I had installed YouCompleteMe previously.

This seems to have fixed the problem for me. Hope this can be useful for someone.

Frankie Y. Liu
  • 121
  • 2
  • 9
0

just change the flag '-std=c++11' to '-std=c++17' in the .ycm_extra_conf.py .

that works for me perfectly.

kroos
  • 37
  • 6