解决“NoExtraConfDetected: No .ycm_extra_conf.py file detected”问题

该配置只针对C、C++!

在用户目录下新建文件“.ycm_extra_conf.py”,复制以下代码到文件。

import os
import ycm_core

flags = [
    '-Wall',
    '-Wextra',
    '-Werror',
    '-Wno-long-long',
    '-Wno-variadic-macros',
    '-fexceptions',
    '-DNDEBUG',
    '-std=c++11',
    '-x',
    'c++',
    '-I',
    '/usr/include',
    '-isystem',
    '/usr/lib/gcc/x86_64-linux-gnu/5/include',
    '-isystem',
    '/usr/include/x86_64-linux-gnu',
    '-isystem'
    '/usr/include/c++/5',
    '-isystem',
    '/usr/include/c++/5/bits'
  ]

SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', ]

def FlagsForFile( filename, **kwargs ):
  return {
    'flags': flags,
    'do_cache': True
  }

在“~/.vimrc”中添加两行

let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'

let g:ycm_confirm_extra_conf = 0

 

到此结束!

参考:

https://www.jianshu.com/p/5aaae8f036c1

你可能感兴趣的:(配置环境)