C-家庭语义自动完成插件Vim的使用铛(clang_complete,YouCompleteMe) [英] C-family Semantic Autocompletion Plugins for Vim Using Clang (clang_complete, YouCompleteMe)

查看:994
本文介绍了C-家庭语义自动完成插件Vim的使用铛(clang_complete,YouCompleteMe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用64位VIM在Windows上,这个版本通过 Haroogan

I am using 64-bit Vim on windows, this version by Haroogan:

+python27
+python33
+huge

我试图使用 clang_complete 的,所以我把 libclang.dll 并设置我的的vimrc 正确。 libclang.dll 中找到。

I am trying to use clang_complete, so I took the libclang.dll library here and I set up my vimrc correctly. libclang.dll is found.

然而,当我打开 * CPP 文件我现在有一个消息:

However when I open a *.cpp file I now have a message:

libclang 找不到内建包括这会导致慢
  完成code

libclang cannot find the builtin includes this will cause slow completion code

但我没有完成在所有...

but I have no completion at all...

我发现这个帖子与谁建立Vim的版本,我用的家伙,但有是做什么没有明确的指示。任何人可以帮助吗?

I found this post with the guy who build the version of Vim that I use, but there is no clear instruction about what to do. Can anybody help here?

下面是我做过什么:


  1. 为YouCompleteMe的Windows

  2. 为Windows

  3. 从它采取了liclang.dll和YCM蟒蛇目录卡住它

  4. 注意到<一href=\"https://github.com/Valloric/YouCompleteMe/blob/master/cpp/ycm/.ycm_extra_conf.py\">.ycm_extra_conf.py和我的CPP文件坚持了

  1. Took Vim YouCompleteMe for Windows
  2. Took LLVM for Windows
  3. Took the liclang.dll from it and stuck it in YCM python directory
  4. Took .ycm_extra_conf.py and stuck it with my cpp file

这几乎是工作(我没有任何错误消息),但我还是得到:

It almost work (I do not have any error message), but I still get:

推荐答案

感谢您使用 的Vim的Windows 希望您能喜欢。

clang_complete


Thanks for using Vim for Windows, hope you enjoy.

要解决你的问题,你必须使用 .clang_complete 文件。了解更多关于它:H clang_complete 。简单地说,你可以把这个文件到您的任何项目的根目录下(即每个项目这个文件可以是不同的,什么完美的是有道理的,因为不同的项目有不同的工具链配置)。这里是MinGW的-W64工具链样本:

To solve your problem you have to utilize .clang_complete file. Read more about it in :h clang_complete. In brief, you can put this file into the root directory of any of your projects (i.e. for each project this file can be different, what perfectly makes sense, since different projects have different toolchain configurations). Here is the sample for MinGW-w64 toolchain:

-ID:/Toolchains/x64/MinGW-w64/4.8.1/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++
-ID:/Toolchains/x64/MinGW-w64/4.8.1/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32
-ID:/Toolchains/x64/MinGW-w64/4.8.1/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/backward
-ID:/Toolchains/x64/MinGW-w64/4.8.1/lib/gcc/x86_64-w64-mingw32/4.8.1/include
-ID:/Toolchains/x64/MinGW-w64/4.8.1/lib/gcc/x86_64-w64-mingw32/4.8.1/include-fixed
-ID:/Toolchains/x64/MinGW-w64/4.8.1/x86_64-w64-mingw32/include

-ID:/Libraries/x64/MinGW-w64/4.8.1/Boost/1.54.0/include

-ID:/Libraries/x64/MinGW-w64/4.8.1/Qt/4.8.5/include

-ID:/Libraries/x64/MinGW-w64/4.8.1/Eigen/3.1.3/include

"-ID:/Libraries/x64/MinGW-w64/4.8.1/Example with Spaces/0.0.1/include"

-std=c++11

-DUNICODE

当您正在编辑与vim项目的一些文件, clang_complete ,直到它跨越第一 .clang_complete 文件中读取。然后,它读取所有这些标志/开关/定义和 libclang 的完成调用过程中使用它们。

When you are editing some file in the project with Vim, clang_complete traverses backward all the parent directories of the edited file until it stumbles across the first .clang_complete file to read. Then it reads all these flags/switches/definitions and uses them during the invocation of libclang for completion.

这些天来,我不使用 clang_complete 了。还有更强大的语义自动完成插件的Vim我们那里。它的 YouCompleteMe 。我强烈建议你尝试一下。对于C家族语言语义完成(C / C ++ / Objective-C的/的Objective-C ++),它使用 libclang 为好。它依赖于一个强大的C ++后端,因此是令人难以置信的快速。它有 syntastic (另一个必须有插件VIM)大整合。它有跳转到定义的能力,等等​​。

These days, I don't use clang_complete anymore. There is more powerful semantic autocompletion plugin for Vim our there. It's YouCompleteMe. I highly recommend you try it out. For semantic completion of C-family languages (C/C++/Objective-C/Objective-C++) it uses libclang as well. It relies on a robust C++ back end, and is therefore incredibly fast. It has great integration with syntastic (another must have plugin for Vim). It has an ability to jump to definitions, and so on.

由于它是用C ++编写,并通过Python粘Vim的,你必须编译C ++后端。为了减轻你可以下载prebuilt的痛苦,并准备使用YCM插件从我的的Vim YouCompleteMe为Windows 。我已经建立了这两个x86和x64架构。本机组件是名为 ycm_core.pyd 。像往常一样,Vim的体系结构构建您选择具有相匹配的YCM版本(即 ycm_core.pyd )。 YCM可以工作的与Python 2(未3),所以只要确保你有Python的2 DLL(如 python27.dll )和Python 2国际米兰preTER( python.exe )的 PATH 环境变量。

Since it's written in C++ and glued to Vim via Python, you'd have to compile the C++ back end. To ease the pain you can download prebuilt and ready to use YCM plugin from my Vim YouCompleteMe for Windows. I've built it for both x86 and x64 architectures. The native component is called ycm_core.pyd. As usual the architecture of the Vim build you chose has to match the YCM build (i.e. ycm_core.pyd). YCM can work ONLY with Python 2 (not 3), so just make sure that you have Python 2 DLL (e.g. python27.dll) and Python 2 Interpreter (python.exe) in the PATH environment variable.

如果您需要LLVM / Clang的,你可以从我这里下载以及 LLVM用于Windows 。同样,只要确保你有 libclang.dll PATH 环境变量(推荐)旁边的 ycm_core.pyd 。再次x86和x64体系结构的支持,并再次架构应该同时匹配Vim的和YCM的人。

If you need LLVM/Clang, you can download it from me as well: LLVM for Windows. Again, just make sure that you have libclang.dll in the PATH environment variable (recommended) OR right next to ycm_core.pyd. Once again both x86 and x64 architectures are supported, and once again the architecture should match both Vim's and YCM's ones.

关于完成:

如果他奇迹般地找到哪里是STL?

Should he magically find where is the STL?

当然不是!这仅仅是基于锵前端的自动完成系统。它是如何应该知道您目前使用编译你的code哪些工具链?你可以使用任何内容:VISUAL C ++,用Borland C ++,GCC,MinGW的,MinGW的-W64,LLVM /锵等,他们每个人都有自己的标准库和运行时提供。因此,在每种情况下你必须指定你目前使用的工具链找到标准包含了所有的路径。

Of course not! This is just an autocompletion system based on Clang front end. How is it supposed to know which toolchain you're currently using to compile your code? You could use anything: Visual C++, Borland C++, GCC, MinGW, MinGW-w64, LLVM/Clang, etc. Each of them has their own standard library and runtime supplied. Thus, in each case you'd have to specify all the paths which your current toolchain uses to find standard includes.

例如,在GCC的情况下,MinGW的,MinGW的-W64,可以运行在POSIX外壳以下内容:

For example, in case of GCC, MinGW, MinGW-w64, you can run the following in POSIX shell:

g++ -E -x c++ - -v < /dev/null

,或在Windows命令提示符:

Or in Windows Command Prompt:

g++ -E -x c++ - -v < nul

和查找以下摘录:

#include <...> search starts here:
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/backward
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/include-fixed
 d:\toolchains\x64\mingw-w64\4.8.1\posix\seh\bin\../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/include
End of search list.

这会告诉你所有的路径标准包括GCC,MinGW的,MinGW的-W64使用隐式您的code编译过程中。

This tells you all the paths to standard includes which GCC, MinGW, MinGW-w64 use implicitly during compilation of your code.

有关LLVM / Clang的,你可以这样做:

For LLVM/Clang, you can do the same:

clang++ -E -x c++ - -v < /dev/null

或者

clang++ -E -x c++ - -v < nul

当你知道的路径,你可以愉快地将它们添加到 .ycm_extra_conf.py 。举例来说,在我的情况:

When you know the paths, you can happily add them into .ycm_extra_conf.py. For instance, in my case:

'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++',
'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32',
'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/backward',
'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/lib/gcc/x86_64-w64-mingw32/4.8.1/include',
'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/lib/gcc/x86_64-w64-mingw32/4.8.1/include-fixed',
'-I',
'D:/Toolchains/x64/MinGW-w64/4.8.1/POSIX/SEH/x86_64-w64-mingw32/include',

这篇关于C-家庭语义自动完成插件Vim的使用铛(clang_complete,YouCompleteMe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆