vim - Vim YouCompleteMe c++17:分解声明警告
问题描述
我想正确设置 YouCompleteMe,这样我就不会在 c++ 文件上收到以下警告:
...
auto [k,v] = mapIt; // some map iterator
...
decomposition declarations are a C++17 extension
我添加了
flags.append( '-std=c++17' )
在
~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py
并将以下内容添加到
~/.vimrc
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
解决方案
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.
推荐阅读
- html - 如何使表格响应移动设备并将某些列放在其他列下方
- java - 控制器中的Java MVC ActionListener,视图中的JButton。我如何将这些链接在一起?
- optimization - 斯坦纳树和完全图之间的图
- r - R 创建函数来运行许多假设检验
- angular - 如何解决错误上下文在离子/角度中调试上下文
- mysql - 关于更新子/父表的 MYSQL 错误
- react-native - 有没有办法获得 react-native-swiper 的滑动进度?
- python - 如何避免此熊猫数据帧处理的迭代
- android - 更改 recyclerview 的视图中按钮的可见性(使用卡片视图)
- reactjs - 如何根据 React 中的 3 个条件更改表格行颜色