在clang_complete.txt(帮助文件)中,它在clang_complete-compl_kinds中显示了这些:
2.Completion kinds *clang_complete-compl_kinds*
Because libclang provides a lot of information about completion, there are
some additional kinds of completion along with standard ones (see >
:help complete-items for details):
'+' - constructor
'~' - destructor
'e' - enumerator constant
'a' - parameter ('a' from "argument") of a function, method or template
'u' - unknown or buildin type (int, float, ...)
'n' - namespace or its alias
'p' - template ('p' from "pattern")
问题是:
1.我无法访问完整项目(没有此文件)
2.谁能告诉我如何使用参数'+''a'等。
3.或者你能告诉我如何在输入 ( 时显示函数参数吗?
谢谢!
(原谅我糟糕的英语)
最佳答案
已经过去很长时间了,但我会回答以帮助 future 的访客。
我不太明白你的问题,但我会回答第三个问题。 Clang Complete 仅在写入“.”、“->”或“::”时启动自动建议/完成,但您可以手动启动它。
我就是这样用的。在此来源中:
#include <iostream>
using namespace std;
void ExampleFunc (float foo, int &bar)
{
cout << foo;
bar++;
}
int main (int argc, char **argv)
{
int a(0);
Exa[cursor here]
return 0;
}
写“Exa”可以按<C-X><C-U>
您将看到一个预览窗口:
Example (float foo, int &bar)
和一个完成窗口(与在插入模式下按 <C-N>
(CTRL-N) 时出现的窗口相同):
Example f void Example(float foo, int &bar)
如果有多个匹配项,您可以使用 <C-N>
向下或向上移动或<C-P>
并完成 <CR>
(输入)。
完成并不完美,但它应该适用于许多其他情况,例如(正如您提到的)模板:
#include <vector>
using namespace std;
int main (int argc, char **argv)
{
struct MyType {int asdf; float qwer;};
vector<MyType> vec;
ve // suggestions after <C-X><C-U>:
// "vec v vector<MyType> vec" v is for variable
// "vector p vector<Typename _Tp>" p is for pattern (template)
// constructors with its parameters, etc.
vec. // auto-fired suggestions: all std::vector methods
vec[0]. // auto-fired suggestions: "asdf", "qwer" and MyType methods
return 0;
}
如果这些示例不适合您,则说明您尚未正确安装该插件。
顺便可以映射<C-X><C-U>
到其他快捷方式。
关于function - vim脚本(clang_complete)如何完成功能、模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684936/