安装YCM
安装Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Vundle也是vim的插件,所以放到~/.vim/bundle/下。
安装环境
# install CMake
sudo apt-get install build-essential cmake
# install Python
sudo apt-get install python-dev python3-dev
配置.vimrc
"set mouse=a
"set paste "取消自动注释
set selection=exclusive
set selectmode=mouse,key
set number
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set relativenumber number
set autoindent
set cindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"
Plugin 'VundleVim/Vundle.vim'
Plugin 'https://gitee.com/mirrors/youcompleteme.git'
"这个就是YCM插件
call vundle#end() " required
filetype plugin indent on " required
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_server_python_interpreter='/usr/bin/python3'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
let g:ycm_key_invoke_completion = '<c-z>'
let g:ycm_semantic_triggers = {
\ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
\ 'cs,lua,javascript': ['re!\w{2}'],
\ }
let g:ycm_confirm_extra_conf = 1 "设置为0关闭加载提示
let g:ycm_autoclose_preview_window_after_completion = 1 " 关闭原型提示
let g:ycm_autoclose_preview_window_after_insertion = 1
"let g:ycm_key_list_select_completion = ['<C-o>', '<C-l>']
let g:ycm_show_diagnostics_ui = 0 "关闭语法诊断
然后运行:PluginInstall,等待安装完成。
然后编译YCM
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clang-completer
最后在项目目录下新建.ycm_extra_conf.py
import os
import ycm_core
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-fexceptions',
'-DNDEBUG',
'-std=c++11',
'-x',
'c++',
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/include/c++/9', 这里要改!系统的c++头文件目录
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',
]
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
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 )
# This is the entry point; this function is called by ycmd to produce flags for
# a file.
def Settings( **kwargs ):
if not database::
return {
'flags': flags,
'include_paths_relative_to_dir': DirectoryOfThisScript()
}
filename = kwargs[ 'filename' ]
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object.
return {
'flags': list( compilation_info.compiler_flags_ ),
'include_paths_relative_to_dir': compilation_info.compiler_working_dir_
}
PS
学到一点新东西
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
i:插入状态下有效
nore:不递归
map:按键映射
:表示被代替按键是个表达式
pumvisible():Returns non-zero when the popup menu is visible, zero otherwise. See ins-completion-menu.This can be used to avoid some things that would remove the popup menu.
大概意思就是vim弹出选择菜单时返回非0值,这时候按就是,ctrl+n:向下选择,否则就是。
安装YCM的更多相关文章
- Mac 安装YCM
① 安装Xcode的同时, 安装配套的命令行工具, 包括git, cmake, clang ② 安装Macvim, 并在~/.bashrc文件中设定别名, alias vim="/path/ ...
- VIM安装YCM插件
折腾了两天,终于好了 1.配置VIM (1)下载相关插件 sudo apt-get install git sudo apt-get install build-essential cmake sud ...
- gvim 安装YCM
gvim的插件安装笔记 1.安装vunble插件 该插件主要用于管理别的插件,借助与git,从github来下载插件,实现自动安装前提条件是git安装正确,可以听过cnd使用,并且可以正确访问gith ...
- vim安装 YCM 过程记录
YCM(YouComplateMe) 属于Vim中大神级的插件,提供了类似于巨硬爸爸的VS中的代码补全,但是其安装方式也是比较复杂,因此特意写下一篇记录,记录下我自己如何安装这一插件的过程: 检查自己 ...
- 安装YCM出现:YouCompleteMe unavailable no module named frozendict或者 YouCompleteMe unavailable no module named future
参考博文:http://blog.sina.com.cn/s/blog_8f70642d0102wo57.html 原因就是你或者没用Vundle安装,或者Vundle由于网速太慢下载到一半不能把安装 ...
- YCM安装与配置
1.重新编译vim 2.通过vundle安装YCM 3.安装CMake 4.下载预先编译好的llvm+clang 5.看官网的命令,生成CMake的编译文件并编译 配置YCM: 要额外配置ycm_ex ...
- Linux --- vim 安装、支持python3的配置、插件自动补全YCM的安装配置及全过程错误总结
1.git(用来下载vim和相关插件) sudo apt-get install git 2,cmake(用来编译clang-llvm) sudo apt-get install build-esse ...
- Vim插件YCM的安装
YouCompleteMe(YCM)是一款非常好用的Vim插件,但是很多人安装的时候会出问题(尤其是涉及到C和C++的补全),我安装的时候也遇到了问题,现在解决了,给大家参考: Step1: 通过Vu ...
- Ubuntu18.04安装Vim-plug与YCM
由于个人强迫症的原因,之前的ycm是通过vundle来管理的,这次想更新一下ycm发现问题太多,于是就重新装了个Ubuntu虚拟机,用vim-plug来进行管理ycm及其他插件. 首先要换一下Ubun ...
- 源码安装Vim并配置YCM自动补全插件
Compiling Vim from source is actually not that difficult. Here's what you should do: 1. Install all ...
随机推荐
- Python常见设置
pip的相关设置 设置镜像 为pip设置国内的镜像源可以提高Python库下载的速度,这里推荐使用清华大学的镜像站,使用如下命令配置: python -m pip install --upgrade ...
- Florr 从新手到大佬
Florr 从新手到大佬 新手上路 首先在这里,你会遇到一些简单的教程.按照教程完成,也可以参考链接里的内容. 装备分为一下几种: $ \color{#7eef6D} \text{Common} $ ...
- Qt processEvents - 解决线程中事件阻塞(如槽函数被阻塞)
百度了一会,发现没太有文字讲这件事情,因此整理成文字记录一下. processEvents介绍 长时间运行的操作可以调用processEvents() 保持应用程序响应能力. void QCoreAp ...
- Linux-编译源码时所需提前安装的常用依赖包列表
编译源码时所需提前安装的常用依赖包列表: yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel f ...
- C# 二十年语法变迁之 C# 2,C# 3 ,C# 4参考
C# 二十年语法变迁之 C# 2,C# 3 ,C# 4参考 https://benbowen.blog/post/two_decades_of_csharp_i/ 自从 C# 于 2000 年推出以来 ...
- MYSQL 3 DAY
目录 MySQL day03 1.约束 1.1.唯一性约束(unique) 1.2.主键约束 1.3.外键约束 2.存储引擎?(整个内容属于了解内容) 2.1.完整的建表语句 2.2.什么是存储引擎呢 ...
- NC16641 [NOIP2007]守望者的逃离
题目链接 题目 题目描述 恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变.守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒芜的大岛上.为了杀死守望者,尤迪安开始对这个荒岛施咒 ...
- es6 快速入门 系列 —— Symbol
其他章节请看: es6 快速入门 系列 Symbol es6新增的一种原始类型 试图解决的问题 唯一的属性名 给对象新增一个属性,如何保证这个属性名是独一无二的? 更改 instanceof 的运行方 ...
- 如何从零实现属于自己的 API 网关?
序言 上一篇文章:你连对外接口签名都不会知道?有时间还是要学习学习. 有很多小伙伴反应,对外的 API 中相关的加签,验签这些工作可以统一使用网关去处理. 说到网关,大家肯定比较熟悉.市面上使用比较广 ...
- Swoole从入门到入土(24)——多进程[进程管理器Process\Manager]
Swoole提供的进程管理器Process\Manage,基于 Process\Pool 实现.可以管理多个进程.相比与 Process\Pool,可以非常方便的创建多个执行不同任务的进程,并且可以控 ...