CentOs 7下vim安装YouCompleteMe插件
来源:互联网 发布:java 反射获取类的字段 编辑:程序博客网 时间:2024/05/16 14:36
最权威的原始步骤可以参考github中关于此插件的README.md,如果时间允许的话,尽量多看几遍可以避免很多不必要的麻烦。
一.版本检测
使用vim --version
指令,检 vim版本是否大于7.3.584,一般新系统都满足。打开vim
,输入下述指令查看是否支持python。如果显示为1,则表示支持python;如果显示为0,则表示不支持python,需要重新下载编译vim,使其支持python。
:echo has('python')
二.下载Vundle和YouCompleteMe插件
输入以下指令,下载Vundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
下载成功后,在用户根目录下面,修改.vimrc文件,追加下面语句以便后续安装YouCompleteMe插件
set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'gmarik/Vundle.vim' Plugin 'Valloric/YouCompleteMe' call vundle#end() filetype plugin indent on
然后在vim中先按Esc建,并且输入以下指令安装插件:
:PluginInstall
三.编译YouCompleteMe
在编译之前下载编译工具,准备编译YouCompleteMe
sudo yum install automake gcc gcc-c++ kernel-devel cmakesudo yum install python-devel python3-devel
编译YouCompleteMe使其支持C/C++ 自动补全
cd ~/.vim/bundle/YouCompleteMe./install.py --clang-completer
四.配置vim
修改.vimrc
文件
let g:ycm_global_ycm_extra_conf = '/home/li/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全 let g:ycm_confirm_extra_conf=0 " 打开vim时不再询问是否加载ycm_extra_conf.py配置 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项 set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
五. 附件
.ycm_extra_conf.py
文件内容
import osimport ycm_coreflags = ['-Wall','-Wextra','-Werror','-Wc++98-compat','-Wno-long-long','-Wno-variadic-macros','-fexceptions','-DNDEBUG',# '-std=c11'.'-std=c++11','-x','c++',#'c','-isystem','/usr/include','-isystem','/usr/local/include','-isystem','/usr/include/c++/4.8.5',]compilation_database_folder = ''if os.path.exists( compilation_database_folder ): database = ycm_core.CompilationDatabase( compilation_database_folder )else: database = NoneSOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]def DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) )def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): if not working_directory: return list( flags ) new_flags = [] make_next_absolute = False path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] for flag in flags: new_flag = flag if make_next_absolute: make_next_absolute = False if not flag.startswith( '/' ): new_flag = os.path.join( working_directory, flag ) for path_flag in path_flags: if flag == path_flag: make_next_absolute = True break if flag.startswith( path_flag ): path = flag[ len( path_flag ): ] new_flag = path_flag + os.path.join( working_directory, path ) break if new_flag: new_flags.append( new_flag ) return new_flagsdef IsHeaderFile( filename ): extension = os.path.splitext( filename )[ 1 ] return extension in [ '.h', '.hxx', '.hpp', '.hh' ]def GetCompilationInfoForFile( filename ): if IsHeaderFile( filename ): basename = os.path.splitext( filename )[ 0 ] for extension in SOURCE_EXTENSIONS: replacement_file = basename + extension if os.path.exists( replacement_file ): compilation_info = database.GetCompilationInfoForFile( replacement_file ) if compilation_info.compiler_flags_: return compilation_info return None return database.GetCompilationInfoForFile( filename )def FlagsForFile( filename, **kwargs ): if database: compilation_info = GetCompilationInfoForFile( filename ) if not compilation_info: return None final_flags = MakeRelativePathsInFlagsAbsolute( compilation_info.compiler_flags_, compilation_info.compiler_working_dir_ ) else: relative_to = DirectoryOfThisScript() final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) return { 'flags': final_flags, 'do_cache': True }
0 0
- CentOs 7下vim安装YouCompleteMe插件
- CentOS 7下Vim安装YouCompleteMe插件
- CentOS 7下的Vim自动补齐插件YouCompleteMe安装及配置
- ubuntu下为vim安装youcompleteme插件
- centos7下安装vim的YouCompleteMe插件
- 安装Vim插件 YouCompleteMe
- vim安装YouCompleteMe 插件
- vim youcompleteme插件安装
- vim 安装YouCompleteMe 插件
- Centos下安装YouCompleteMe
- [安装]Vim插件YouCompleteMe在mac下的安装
- 安装vim的YouCompleteMe插件
- Linux vim安装YouCompleteMe插件
- Ubuntu vim安装插件YouCompleteMe
- mac 安装vim 插件YouCompleteMe
- Fedora25下vim智能补全插件YouCompleteMe安装
- mac vim 下安装自动补全插件YouCompleteMe
- Centos 7 安装 vim自动补全神器 YouCompleteMe
- 算法:动态规划
- 第九周实践-阅读程序写出运行结果并理解(3)
- PEP8 Python 编码规范整理
- c语言.野指针
- popwindow 点击外部消失
- CentOs 7下vim安装YouCompleteMe插件
- Basemap可视化地图信息
- BestCoder Round #81 (div.2)A
- 4540: [Hnoi2016]序列|莫队+ST表
- Leetcode 59. Spiral Matrix II
- Android多分辨率适配巧妙方法
- 如何批量删除会计科目、供应商、客户的主数据
- C#OOP之二 变量和表达式
- Eclipse 安卓开发导入SlidingMenu侧滑菜单这些坑!!