如何在 Windows 下使用 Vim 的vim youcompletemee 插件

Vim自动补全神器:YouCompleteMe - 文章 - 伯乐在线
& Vim自动补全神器:YouCompleteMe
第一次听说这个插件还是在偶然的情况下看到别人的博客,听说了这个插件的大名。本来打算在实训期间来完成安装的,无奈网实在不给力,也就拖到了回家的时候。在开始准备工作的时候就了解到这个插件不是很容易安装,安装的时候果然名不虚传。(关于这方面的内容,请查看另一篇文章)不过,有付出总有回报,安装之后用上这个插件,真心为这个插件的强大所折服。
那这个插件有何不同?
YouCompleteMe的特别之处
基于语义补全
总所周知,Vim是一款文本编辑器。也就是说,其最基础的工作就是编辑文本,而不管该文本的内容是什么。在Vim被程序员所使用后,其慢慢的被肩负了与IDE一样的工作,文本自动补全(ie.acp,omnicppcompleter),代码检查(Syntastic)等等工作。
针对文本自动补全这个功能来说,主要有两种实现方式。
我们常用的omnicppcompleter,acp,vim自带的c-x, c-n的实现方式就是基于文本。更通俗的说法,其实就是一个字:
其通过文本进行一些正则表达式的匹配,再根据生成的tags(利用ctags生成)来实现自动补全的效果。
顾名思义,其是通过分析源文件,经过语法分析以后进行补全。由于对源文件进行分析,基于语义的补全可以做到很精确。但是这显然是vim所不可能支持的。而且经过这么多年发展,由于语法分析有很高的难度,也一直没有合适的工具出现。直到,由apple支持的clang/llvm横空出世。YouCompleteMe也正是在clang/llvm的基础上进行构建的。
整合实现了多种插件
clang_complete
AutoComplPop
neocomplcache
(类似功能,仅仅针对c/c++/obj-c代码)
对于其他的语言,会调用vim设置的omnifunc来匹配,因此同样支持php,ruby等语言。
已知的有 * javascript —- * ruby/java —-
使用效果图
和IDE一样,自动补全,
根据include的文件进行补全
不用再蹩脚的生成tags
补全非常精准,而且速度很快,不会有延迟(以前在大项目上,acp用起来实在是很卡)
支持类似tags的跳转,跳到定义处以及使用处
出错提示很智能,并且用起来真的是如丝般柔滑,不用输入:w进行强制检测
说完了那么多好处,就要说到安装了。不同于以往其他vim插件,YCM是一款编译型的插件。在下载完后,需要手动编译后才能使用。对应其他的插件来说,仅仅就是把.vim的文件丢到相应文件夹下就可以。而这也加大了使用YCM的难度。
最新版的Vim(7.3.584+),编译时添加+python标志(已经安装的可以通过vim --version查看)
cmake(mac可以通过安装,brew install cmake,ubuntu可以通过sudo apt-get install cmake)
安装插件,用于安装管理vim的插件
mac下快速安装
在.vimrc中添加下列代码
Bundle 'Valloric/YouCompleteMe'
Bundle 'Valloric/YouCompleteMe'
保存退出后打开vim,在正常模式下输入
:BundleInstall
:BundleInstall
等待vundle将YouCompleteMe安装完成
而后进行编译安装:
cd ~/.vim/bundle/YouCompleteMe
./install --clang-completer
cd ~/.vim/bundle/YouCompleteMe./install --clang-completer
如果不需要c-family的补全,可以去掉--clang-completer。如果需要c#的补全,请加上--omnisharp-completer。
正常来说,YCM会去下载clang的包,如果已经有,也可以用系统--system-libclang。
就这样,安装结束。打开vim,如果没有提示YCM未编译,则说明安装已经成功了。
手动编译安装
安装的脚本并不是什么时候都好用,至少对我来说是这样的。安装完之后出现了问题,参考。
在用:BundleInstall安装完成或者使用
git clone --recursive /Valloric/YouCompleteMe.git
git clone --recursive https://github.com/Valloric/YouCompleteMe.git
获取最新的仓库,而后使用git submodule update --init --recursive确认仓库的完整性后,开始安装流程。
下载最新的clang二进制文件 YCM要求clang版本 & 3.2,一般来说都是。
安装python-dev.(ubuntu下使用sudo apt-get install python-dev,mac下默认提供,否则请安装)
mkdir ycm_build
cd ycm_build
cmake -G “Unix Makefiles” -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp make ycm_support_libs
cd ~mkdir ycm_buildcd ycm_buildcmake -G “Unix Makefiles” -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp make ycm_support_libs
这里需要注意的是,~/ycm_temp/llvm_root_dir中包含的是根据第一步下载的压缩包解压出来的内容(包括include, bin等等文件)。
这样就完成了,开始感受YCM提供的完全不逊色于大型IDE所提供的自动补全功能吧。
不同于很多vim插件,YCM首先需要编译,另外还需要有配置。在vim启动后,YCM会找寻当前路径以及上层路径的.ycm_extra_conf.py.在~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py中提供了默认的模板。也可以参考我的(就在模板上改改而已)。不过这个解决了标准库提示找不到的问题。
一般来说,我会在~目录下放一个默认的模板,而后再根据不同的项目在当前目录下再拷贝个.ycm_extra_conf.py。
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
# Here's the license text for this file:
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# For more information, please refer to &http://unlicense.org/&
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
'-Wextra',
#'-Werror',
#'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-stdlib=libc++',
# THIS IS IMPORTANT! Without a "-std=&something&" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=&something&".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/Library/Developer/CommandLineTools/usr/include',
'-isystem',
'/Library/Developer/CommandLineTools/usr/bin/../lib/c++/v1',
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
# Most projects will NOT need to
you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = pilationDatabase( compilation_database_folder )
database = None
SOURCE_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
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
if new_flag:
new_flags.append( new_flag )
return new_flags
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 piler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that piler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
piler_flags_,
piler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
final_flags.remove( '-stdlib=libc++' )
#except ValueError:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
'flags': final_flags,
'do_cache': True
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
# This file is NOT licensed under the GPLv3, which is the license for the rest# of YouCompleteMe.## Here's the license text for this file:## This is free and unencumbered software released into the public domain.## Anyone is free to copy, modify, publish, use, compile, sell, or# distribute this software, either in source code form or as a compiled# binary, for any purpose, commercial or non-commercial, and by any# means.## In jurisdictions that recognize copyright laws, the author or authors# of this software dedicate any and all copyright interest in the# software to the public domain. We make this dedication for the benefit# of the public at large and to the detriment of our heirs and# successors. We intend this dedication to be an overt act of# relinquishment in perpetuity of all present and future rights to this# software under copyright law.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR# OTHER DEALINGS IN THE SOFTWARE.## For more information, please refer to &http://unlicense.org/&&import osimport ycm_core&# These are the compilation flags that will be used in case there's no# compilation database set (by default, one is not set).# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.flags = ['-Wall','-Wextra',#'-Werror',#'-Wc++98-compat','-Wno-long-long','-Wno-variadic-macros','-fexceptions','-stdlib=libc++',# THIS IS IMPORTANT! Without a "-std=&something&" flag, clang won't know which# language to use when compiling headers. So it will guess. Badly. So C++# headers will be compiled as C headers. You don't want that so ALWAYS specify# a "-std=&something&".# For a C project, you would set this to something like 'c99' instead of# 'c++11'.'-std=c++11',# ...and the same thing goes for the magic -x option which specifies the# language that the files to be compiled are written in. This is mostly# relevant for c++ headers.# For a C project, you would set this to 'c' instead of 'c++'.'-x','c++','-I','.','-isystem','/usr/include','-isystem','/usr/local/include','-isystem','/Library/Developer/CommandLineTools/usr/include','-isystem','/Library/Developer/CommandLineTools/usr/bin/../lib/c++/v1',]&# Set this to the absolute path to the folder (NOT the file!) containing the# compile_commands.json file to use that instead of 'flags'. See here for# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html## Most projects will NOT need to
you can just change the# 'flags' list of compilation flags. Notice that YCM itself uses that approach.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 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_flags&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 )&def FlagsForFile( filename, **kwargs ):&&if database:&&&&# Bear in mind that piler_flags_ does NOT return a&&&&# python list, but a "list-like" StringVec object&&&&compilation_info = GetCompilationInfoForFile( filename )&&&&if not compilation_info:&&&&&&return None&&&&&final_flags = MakeRelativePathsInFlagsAbsolute(&&&&&&compilation_info.compiler_flags_,&&&&&&compilation_info.compiler_working_dir_ )&&&&&# NOTE: This is just for YouCompleteMe; it's highly likely that your project&&&&# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR&&&&# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.&&&&#try:&&&&#&&final_flags.remove( '-stdlib=libc++' )&&&&#except ValueError:&&&&#&&pass&&else:&&&&relative_to = DirectoryOfThisScript()&&&&final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )&&&return {&&&&'flags': final_flags,&&&&'do_cache': True&&}
YouCompleteMe提供的其他功能
YCM除了提供了基本的补全功能,自动提示错误的功能外,还提供了类似tags的功能:
跳转到定义GoToDefinition
跳转到声明GoToDeclaration
以及两者的合体GoToDefinitionElseDeclaration
可以在.vimrc中配置相应的快捷键。
nnoremap &leader&gl :YcmCompleter GoToDeclaration&CR&
nnoremap &leader&gf :YcmCompleter GoToDefinition&CR&
nnoremap &leader&gg :YcmCompleter GoToDefinitionElseDeclaration&CR&
nnoremap &leader&gl :YcmCompleter GoToDeclaration&CR&nnoremap &leader&gf :YcmCompleter GoToDefinition&CR&nnoremap &leader&gg :YcmCompleter GoToDefinitionElseDeclaration&CR&
另外,YCM也提供了丰富的配置选项,同样在.vimrc中配置。具体请
let g:ycm_error_symbol = '&&'
let g:ycm_warning_symbol = '&*'
let g:ycm_error_symbol = '&&'let g:ycm_warning_symbol = '&*'
同时,YCM可以打开location-list来显示警告和错误的信息:YcmDiags。个人关于ycm的配置如下:
let g:ycm_error_symbol = '&&'
let g:ycm_warning_symbol = '&*'
nnoremap &leader&gl :YcmCompleter GoToDeclaration&CR&
nnoremap &leader&gf :YcmCompleter GoToDefinition&CR&
nnoremap &leader&gg :YcmCompleter GoToDefinitionElseDeclaration&CR&
nmap &F4& :YcmDiags&CR&
" for ycmlet g:ycm_error_symbol = '&&'let g:ycm_warning_symbol = '&*'nnoremap &leader&gl :YcmCompleter GoToDeclaration&CR&nnoremap &leader&gf :YcmCompleter GoToDefinition&CR&nnoremap &leader&gg :YcmCompleter GoToDefinitionElseDeclaration&CR&nmap &F4& :YcmDiags&CR&
YCM提供的跳跃功能采用了vim的jumplist,往前跳和往后跳的快捷键为Ctrl+O以及Ctrl+I。
YouCompleteMe是我用过的最爽的一个自动补全的插件了。之前使用acp时,遇到大文件基本上就卡死了,以至于都不怎么敢使用。由于YCM使用的时C/S结构,部分使用vim脚本编写,部分认为原生代码,使得跑起来速度飞快。
抛弃Vim自带的坑爹的补全吧,抛弃ctags吧,抛弃cscope吧,YCM才是终极的补全神器。
在安装过程中,我也遇到了不少的坑。一会会发一篇解决这些坑的文章。
最后祝大家码年顺利,一码平川,码到功成。
可能感兴趣的话题
不支持我大Java!!!!
关于伯乐在线博客
在这个信息爆炸的时代,人们已然被大量、快速并且简短的信息所包围。然而,我们相信:过多“快餐”式的阅读只会令人“虚胖”,缺乏实质的内涵。伯乐在线内容团队正试图以我们微薄的力量,把优秀的原创文章和译文分享给读者,为“快餐”添加一些“营养”元素。
新浪微博:
推荐微信号
(加好友请注明来意)
– 好的话题、有启发的回复、值得信赖的圈子
– 分享和发现有价值的内容与观点
– 为IT单身男女服务的征婚传播平台
– 优秀的工具资源导航
– 翻译传播优秀的外文文章
– 国内外的精选文章
– UI,网页,交互和用户体验
– 专注iOS技术分享
– 专注Android技术分享
– JavaScript, HTML5, CSS
– 专注Java技术分享
– 专注Python技术分享
& 2016 伯乐在线安装youcompleteme插件不能用,求指导_vim吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:4,617贴子:
安装youcompleteme插件不能用,求指导收藏
我完全按照官方readme来操作的。一台新安装的ubuntu14.04,我首先安装了build-essential,python-dev,cmake,git,vim。确认了vim版本是7.4,支持python。然后我git clone
~/.vim/bundle/Vundle.vim,安装vundle,然后编辑vimrc,添加了youcompleteme,在vim下运行PluginInstall,安装好后,我执行cd ~/.vim/bundle/YouCompleteMe,然后./install.sh --clang-completer。按说这就应该搞定了。可是我用vim建立一个.cpp文件,下方提示pattern not found,无法进行补全。还请大神指导。
炫酷暗黑奇迹MU页游强悍来袭,秒怪秒BOSS,来玩就送海量RMB礼包!
还有,安装好后,在.vim/bundle/YouCompleteMe文件夹下没有cpp文件夹,也就没有那个配置文件,好奇怪
解决了,网上太多的帖子说默认配置文件就在cpp/ycm文件夹里,可能过去的版本是这样的,但实际上目前的版本已经不是这样了。配置文件需要自己创建。而且我试了下,直接复制粘贴似乎不行,我就直接用wget下载下来,就可以用了
不喜欢YCM这个插件,他违背了do one thing and do it well.我还是喜欢将提供补全内容的插件和提供补全习惯的插件分开。这样可以按需安装你要的语言的补全接口名什么的插件。
YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py
依然用不成。我当时用搜索找到了这个文件,也放到了自己的目录里面,但是依然用不成啊!!!.c,.py,.cpp文件都不会自动补全,到底是闹哪样啊!
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或我有时候会有比较短的代码会在windows下编写。我的vim没有支持lua,所以还没有用过neocomplete。这货的前身neocomplcache有点难用,如果你打错了一个词,他也会一直记录着,直到你关掉vim再次打开。官方给的windows下的youcompleteme的guide太复杂了,我实在是看着头大,需要装一大堆东西,而我尝试着使用,它要求我去下载一个libclang.dll。我在克隆下来,是一个make libclang的py文件,而在download的地方是两个mingw的链接...它上面一段话说的是clang.exe可以代替gcc神马的,然后说libclang.dll就是mingw编译出来的,但是就是没给我一个一步到位的东西啊T T。我下载下来,这里面也没有叫做libclang.dll的东西 T T,大婶们求教啊!
Runtime Error!
Program: $VIM\gvim.exe
An application has made an attempt to load the C runtime
library incorrectly.
Please contact the application's support team for more
information.
可以参照下面这个帖子!最后我发现是syswow64下的msvcr90.dll在作祟!我把syswow64下的这个文件改了后缀名,就不报错了。
-----------------------------------------------------------更新------------------------------------------------------------&br&
最近由于工作原因同时使用Linux和Windows,之前做的便携版明显不够用了。 所以又自己重新折腾了下vim. &br&
YCM由于官方支持了Windows,所以按照官方教程做几乎不会出错。 我遇到的唯一一个大坑是在64位vim中,python2.7.11 x64有BUG,会导致vim找不到Python模块进而无法使用YCM。 在我手动清理注册表过后依然不行,最后是通过从源码编译vim解决。&br&
共享的是使用python3.5.2 x64
以及VS2015编译的,使用的时候使用插件管理工具如vundle或者plug.vim管理或者set runtimepath += ycm_path
注意全套必须是64位。 &br&&br&作者:竹青叶&br&链接:&a href=&/question//answer/& class=&internal&&如何在 Windows 下使用 Vim 的 YouCompleteMe 插件? - 知乎用户的回答&/a&&br&来源:知乎&br&著作权归作者所有,转载请联系作者获得授权。&br&&a href=&///?target=http%3A///s/1hrSwSNM& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&http://&/span&&span class=&visible&&/s/1hrSwSN&/span&&span class=&invisible&&M&/span&&span class=&ellipsis&&&/span&&i class=&icon-external&&&/i&&/a&&br&-----------------------------------------------------------更新------------------------------------------------------------&br&之前做的是windows上的便携版,后面考虑到个人需求(就是没有便携的需求,hah)。所以在@Johnny Wu 大神的exVim基础上加上了自己的一些配置后重新做了个安装包(必须是64位系统), gvim默认支持lua和python,其他特性没用到过。&br&已经集成了youcompleteme, 现在youcompleteme官方支持windows,只不过需要在自己电脑上编译一下。
安装好CMake,python2.7, vs2015,7-zip就好了=_=, 教程在
&a href=&///?target=https%3A///Valloric/YouCompleteMe%23windows& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&GitHub - Valloric/YouCompleteMe: A code-completion engine for Vim&i class=&icon-external&&&/i&&/a& ,安装过程,很简单。 注意所有软件必须是64位(ps: 有人用32位么?)&br&&br&使用这个安装包安装完成后建议阅读下安装目录下的说明文件。 祝使用愉快^_^&br&&a href=&///?target=http%3A///s/1kUr09CV& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&http://&/span&&span class=&visible&&/s/1kUr09C&/span&&span class=&invisible&&V&/span&&span class=&ellipsis&&&/span&&i class=&icon-external&&&/i&&/a&&br&-----------------------------------------------------------更新------------------------------------------------------------&br&(没粉么~)&br&这次做了个带YCM的便携版本,代码补全高亮文件树语法检查神马功能的都有。 &br&YCM配置容易掉进的坑:&br&
1. 在XP下使用(本版本的clang经测试不行)。。&br&
2. libclang/python/vim/ycm版本不匹配&br&
3.YCM不支持python&br&
4.MinGW/MinGW64的头文件路径不对/字符转义没做好/头文件包含不全&br&
5.YCM的配置文件没设置对&br&╮(╯▽╰)╭且行且珍惜╮(╯▽╰)╭&br&-----------------------------&a class=& wrap external& href=&///?target=http%3A///s/1mgE97LY& target=&_blank& rel=&nofollow noreferrer&&gvim便携版.7z_免费高速下载&i class=&icon-external&&&/i&&/a&---------------------------------------------------------------------&br&没图没真相:&br&&br&:YcmDebug&br&&img data-rawheight=&406& data-rawwidth=&1312& src=&/ae02aba959dbb34e16b5d8dda6943f99_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1312& data-original=&/ae02aba959dbb34e16b5d8dda6943f99_r.jpg&&&br&&img data-rawheight=&697& data-rawwidth=&1328& src=&/078a33d88acd_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1328& data-original=&/078a33d88acd_r.jpg&&&img data-rawheight=&694& data-rawwidth=&1319& src=&/a41c7de883c3ac2618ed7_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1319& data-original=&/a41c7de883c3ac2618ed7_r.jpg&&&img data-rawheight=&693& data-rawwidth=&1327& src=&/9eda68f68f60a706c2b10863ecbed081_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1327& data-original=&/9eda68f68f60a706c2b10863ecbed081_r.jpg&&&img data-rawheight=&694& data-rawwidth=&1324& src=&/f163d2fe8b21b0c84ac50_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1324& data-original=&/f163d2fe8b21b0c84ac50_r.jpg&&&img data-rawheight=&661& data-rawwidth=&1324& src=&/97bd73e3ca2bad5c744438_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1324& data-original=&/97bd73e3ca2bad5c744438_r.jpg&&(目录结构)&br&&br&PHP补全(未按任何键):&br&&img data-rawheight=&686& data-rawwidth=&1310& src=&/bd6b6cbb5daac5d3037e7_b.jpg& class=&origin_image zh-lightbox-thumb& width=&1310& data-original=&/bd6b6cbb5daac5d3037e7_r.jpg&&&br&--------------------------------------------------------------------------------------------------------------------------------------------&br&使用说明:&br&================================================================================&br&本Gvim便携版为学习C++和PHP Web开发&br&而配置的。适用于C/C++,HTML,CSS,HTML,PHP,JS开发。&br&本便携版本包含了coding常用的插件,目录树关键词函数列表高亮等等。详情见_vimrc&br&对于常见的注释,查找与替换功能在帮助文件目录下有对应说明。&br&&br&0.使用之前请将vim74目录加到path里面。将user_fonts里面的字体拷贝到c/windows/fonts&br&
中间已获得更好的显示效果&br&1.自动补全功能有2个可选的插件:&br&
*neocomplete
(默认)&br&
*YourCompleteMe&br&&br&2.在vimrc中注释掉相应的内容即可。 建议是Web开发时用neocomplete,C++开发时用&br&YourComplete.&br&&br&3.压缩包中的 neocomplete.txt 为neocomplete插件的推荐配置。按需添加。&br&&br&
在我的电脑上YCM运行效率不好,而Neocomplete非常好。并且功能也完全可以满足。&br&
该插件对C/C++的补全需要tags,所以需先用ctags生成对应的tags才行。_vimrc中有&br&
对应的说明。&br&&br&4.YourCompleteMe使用说明&br&
1.YourComplete的windows版本 &a class=& external& href=&///?target=https%3A//bitbucket.org/Haroogan/vim-youcompleteme& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&https://&/span&&span class=&visible&&bitbucket.org/Haroogan/&/span&&span class=&invisible&&vim-youcompleteme&/span&&span class=&ellipsis&&&/span&&i class=&icon-external&&&/i&&/a&&br&
-for-windows&br&
2.本程序YCM部分使用的几乎是该作者提供的文件。&br&
3.使用步骤:&br&
a.确保电脑上安装有python2.7,并且python.exe在path目录里。&br&
b.在_vimrc中注释掉neocpmplete插件,反注释YourCompleteMe.&br&
c.打开vim ,输入命令 :YcmDebug.如果有看到clang版本信息号,server running at,&br&
server process ID 等即表示YCM已经可以使用。&br&
d.对于C++补全,首先确保电脑上安装有MinGW或者CLang(折腾去吧)。然后运行如下&br&
命令找到C++的库文件:&br&
POSIX shell:
g++ -E -x c++ - -v & /dev/null&br&
g++ -E -x c++ - -v & nul &br&
LLVM/CLang:&br&
POSIX shell:
clang++ -E -x c++ - -v & /dev/null&br&
clang++ -E -x c++ - -v & nul&br&
在#include &...& search starts here:和End of search list.之间的路径就是C++&br&
库路径。按照默认配载的格式添加进去。&br&
你也可以直接下载我克隆的MinGW,把它放在C盘根目录,再把MinGW/bin目录加到path中。&br&
e. 经测试,XP系统YCM不可用。WIN7 X86和64可以正常使用。原因未知。&br&
4.YourComplete插件的默认配置文件 帮助文件里面的 .ycm_extra_conf.py文件。注意&br&
里面用的MinGW的C++库路径。windows下目录注意转义字符。&br&&br&----------------------------------------------------------隔割割------------------------------------------------------------------------&br&想自己配置的我这有个包含YCM所有必需文件的压缩包。附简要说明。&br&&a class=& wrap external& href=&///?target=http%3A///s/1kT20pUJ& target=&_blank& rel=&nofollow noreferrer&&windows上YoucompeleteMe完整包.rar_免费高速下载&i class=&icon-external&&&/i&&/a&
-----------------------------------------------------------更新------------------------------------------------------------ 最近由于工作原因同时使用Linux和Windows,之前做的便携版明显不够用了。 所以又自己重新折腾了下vim. YCM由于官…
刚好编译了一个最新的 日:&br&&a href=&///?target=http%3A///s/1eRL7my2& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&http://&/span&&span class=&visible&&/s/1eRL7my&/span&&span class=&invisible&&2&/span&&span class=&ellipsis&&&/span&&i class=&icon-external&&&/i&&/a&&br&支持 官网 GVIM + python2.7.9(官网的gvim只可以和Python 2.7.9配套),32位版本,用 MINGW编译,包含 clang complete。使用时候,解压到任意位置,vimrc里面加一句:&br&&div class=&highlight&&&pre&&code class=&language-vim&&&span class=&k&&set&/span& &span class=&nb&&runtimepath&/span&&span class=&p&&+=&/span&&span class=&k&&d&/span&:/&span class=&nb&&path&/span&&span class=&p&&-&/span&&span class=&k&&to&/span&&span class=&p&&-&/span&youcompleteme
&/code&&/pre&&/div&&br&即可,注意安装:Visual C++ Redistributable for Visual Studio 2015&br&&br&下载地址:&br&&a href=&///?target=https%3A///zh-cn/download/details.aspx%3Fid%3D48145& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Visual C++ Redistributable for Visual Studio 2015&i class=&icon-external&&&/i&&/a&&br&&br&因为我用 2015重新编译了 LLVM,默认llvm发行版打开了 assertions 编译选项,ycm里面稍微调用的不对(千分之一的几率,某些复杂的源代码)就assert导致ycm退出了,取消这个选项后,llvm会返回错误给ycm,你就可以安心的用了,再也不会弹出 clang runtime error&br&------&br&更新(日):上个版本已经是3个月前的了,今天重新更新编译了一个:&br&&a href=&///?target=http%3A///s/1bEY3cq& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&http://&/span&&span class=&visible&&/s/1bEY3cq&/span&&span class=&invisible&&&/span&&i class=&icon-external&&&/i&&/a&(欢迎试用最新版,如果有问题,请回滚4月21日的旧版)
刚好编译了一个最新的 日:
支持 官网 GVIM + python2.7.9(官网的gvim只可以和Python 2.7.9配套),32位版本,用 MINGW编译,包含 clang complete。使用时候,解压到任意位置,vimrc里面加一句: set runtimepath+=d:/pat…
已有帐号?
无法登录?
社交帐号登录
计算机专业/学生

我要回帖

更多关于 vim 插件使用 的文章

 

随机推荐