摘要:64bit vim, YCM, 64bit clang VS 2012, 64bit Widnows

vim x64 for windows

https://bitbucket.org/Haroogan/vim-for-windows

https://bintray.com/veegee/generic/vim_x64

vim 插件管理 Vundle 或NeoBundle

https://github.com/Shougo/neobundle.vim

MinGW 环境

https://bitbucket.org/Haroogan/vim-youcompleteme-for-windows/src

查找头文件目录,添加到.ycm_extra_conf.py

1
2
g++ -E -x c++ - -v < /dev/null
clang++ -E -x c++ - -v < /dev/null

Or in Windows Command Prompt:

1
2
g++ -E -x c++ - -v < nul
clang++ -E -x c++ - -v < nul

VS2012 环境

LLVM/CLANG x64 for windows

http://my.oschina.net/GIIoOS/blog/165542

https://sourceforge.net/projects/clangonwin/

需要 VS 2012

cmake

git for windows http://msysgit.github.io/

编译 YCM

下面主角登场了

1
cmake -G "Visual Studio 11 Win64" -DPATH_TO_LLVM_ROOT=d:\library\LLVM34 -DUSE_CLANG_COMPLETER=1 -DEXTERNAL_LIBCLANG_PATH=d:\library\LLVM34\lib\libclang.lib -DPYTHON_LIBRARY=D:\library\Python27\libs\python27.lib -DPYTHON_INCLUDE_DIR=D:\library\Python27\include . <USERFOLDER>\.vim\bundle\YouCompleteme\cpp

_vimrc配置

1
2
3
4
let g:ycm_key_list_select_completion = ['<C-TAB>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-S-TAB>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-Tab>'
let g:ycm_global_ycm_extra_conf = 'PATHTO\.vim\dot.ycm_extra_conf.py'

dot.ycm_extra_conf.py 配置添加

’-I’, ‘C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include’

我们一般把“-I”用作自己的代码,”-isystem”用作第三代码。这样编译代码的时候,第三方代码编译时的warning,就不会显示出来,只需要专注在自己写的代码。

与SuperTab、UltiSnips配合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
"supertab插件
let g:SuperTabDefaultCompletionType = "context" "自动检测需要补全什么内容
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
let g:SuperTabContextDiscoverDiscovery = ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
"let g:SuperTabContextDefaultCompletionType = '<c-n>'设置补全方式
"let g:SuperTabRetainCompletionType=2        "记住上次的补全方式,直到退出插入模式

let g:ycm_key_list_select_completion = ['<C-TAB>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-S-TAB>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-Tab>'
"let g:ycm_collect_identifiers_from_tags_files = 1
"let g:ycm_autoclose_preview_window_after_completion=1
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>

"let g:UltiSnipsExpandTrigger="<c-j>"
"let g:UltiSnipsJumpForwardTrigger="<c-j>"
"let g:UltiSnipsJumpBackwardTrigger="<c-k>"