omn​​icppcomplete 不支持所有形式的 const

发布于 2024-11-03 22:20:18 字数 503 浏览 0 评论 0原文

我有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝天 2024-11-10 22:20:18

似乎是omnicppcomplete 的限制,但我打开了vim 调试器并找到了它。

打开 autoload/omni/cpp/utils.vim,转到第 518 行,应如下所示:

  for token in tokens
        if state==0
            if token.value=='>'
                let parenGroup = token.group
                let state=1
            elseif token.kind == 'cppWord'
                let szResult = token.value.szResult
                let state=2
            elseif index(['*', '&'], token.value)<0 "This is line 518
                break
            endif

并将该行更改为:

 elseif token.value != 'const' && index(['*', '&'], token.value)<0

或者,这是执行此操作的 vim 命令 =):

/index(\['\*', '&'],<CR>itoken.value != 'const' &&<ESC>:w

我将尝试将其提交给维护者或许可以检查 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:

  for token in tokens
        if state==0
            if token.value=='>'
                let parenGroup = token.group
                let state=1
            elseif token.kind == 'cppWord'
                let szResult = token.value.szResult
                let state=2
            elseif index(['*', '&'], token.value)<0 "This is line 518
                break
            endif

And change that line to:

 elseif token.value != 'const' && index(['*', '&'], token.value)<0

Or, here's the vim commands to do it =):

/index(\['\*', '&'],<CR>itoken.value != 'const' &&<ESC>:w

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.

ゃ懵逼小萝莉 2024-11-10 22:20:18

在遇到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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文