omnicppcomplete 不支持所有形式的 const
我有omnicppcomplete 工作正常,除了偶尔它不会完成一些变量方法/成员。我终于很恼火地深入研究了原因,我相信原因是omnicppcomplete确实支持函数参数中的语法“Foo const & foo”。
例如,如果我有一个函数定义为:
int foo( Bar const & b ){
}
当我稍后输入“b.”时,我将无法获得完成信息。但是,如果我将签名更改为:
int foo( const Bar & b ){
}
当我输入“b.”时,我将能够获得完成信息。它似乎只出现在函数参数列表中,因为我尝试简单地在函数中定义一个带有签名“Bar const & bref”的变量,并且我能够获取 bref 的完成信息。
如果这是omnicppcomplete 的实际限制,我会感到惊讶;有人对这是否是一个错误和/或是否有解决方法有任何想法?改变编码风格似乎不是一个合理的解决方案。
I have omnicppcomplete working fine except once in a while it won't complete some of the variables methods/members. I finally got annoyed enough to dig into why and I believe the reason is that omnicppcomplete does support the syntax "Foo const & foo" in function arguments.
For example, if I have a function defined as:
int foo( Bar const & b ){
}
I won't be able to get completion information when I later type "b.". However if I change the signature to:
int foo( const Bar & b ){
}
I will be able to get completion information when I type "b.". It seems to only be in function argument lists because I tried simply defining a variable within the function with the signature "Bar const & bref" and I was able to get completion information for bref.
I would be surprised if this is an actual limitation of omnicppcomplete; anyone have any thoughts on whether or not this is a bug and/or if there is a workaround for it? Changing the coding style does not seem like a reasonable solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
似乎是omnicppcomplete 的限制,但我打开了vim 调试器并找到了它。
打开 autoload/omni/cpp/utils.vim,转到第 518 行,应如下所示:
并将该行更改为:
或者,这是执行此操作的 vim 命令 =):
我将尝试将其提交给维护者或许可以检查 token.kind == 'cppKeyword' 是否存在,但我想我会在改变最少的方面犯错误。
Seems like a limitation in omnicppcomplete, but I pulled up the vim debugger and found it.
Open up autoload/omni/cpp/utils.vim, go to line 518, should look like this:
And change that line to:
Or, here's the vim commands to do it =):
I'll try submitting this to the maintainer of omnicppcomplete, but it's kind of hackish, dunno if it'll get in. Might've been able to check if token.kind == 'cppKeyword', but I figured I'd err on the side of changing the least.
在遇到omnicppcomplete问题后,我寻找替代方案并发现clang Complete它使用 clang 的元数据输出(即用于此类目的)。我工作得非常好,只要你的代码编译,它就会理解一切。
Having experienced issues with omnicppcomplete, I searched for an alternative and found clang complete which uses clang's metadata output (that is intended for such purposes). I works extremely well and provided your code compiles, it will understand everything.