Omnicppcomplete not supporting all forms of const

I have omnicppcomplete working fine, except that from time to time it will not complete some of the methods / members of the variables. I was finally annoyed to understand why, and I think the reason is because omnicppcomplete supports the syntax "Foo const and foo" in the function arguments.

For example, if I have a function defined as:

int foo( Bar const & b ){ } 

I will not be able to get completion information when I later type "b". However, if I changed my signature to:

 int foo( const Bar & b ){ } 

I can get completion information when I type "b". It seems that this is only in the argument lists of the function, because I tried just to define the variable inside the function with the signature "Bar const and bref", and I was able to get the completion information for bref.

I would be surprised if this is an actual omnicppcomplete limitation; Does anyone have thoughts on whether this is a mistake or / or if there is a workaround for this? Changing the coding style does not seem like a reasonable solution.

+6
source share
2 answers

Looks like a limitation in omnicppcomplete, but I stopped the vim debugger and found it.

Open autoload /omni/cpp/utils.vim, go to line 518, it 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 this line to:

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

Or, here the vim command does this =):

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

I will try to pass this to the omnicppcomplete developer, but it's kind of hacky, dunno, if he logs in. Could check if there is token.kind == 'cppKeyword', but I decided that I 'd err on the change side the least.

+3
source

Having experienced problems with omnicppcomplete, I searched for an alternative and found clang complete which uses clang metadata output (intended for such purposes), I work very well, and provided that your code compiles, it will understand everything.

+2
source

Source: https://habr.com/ru/post/886909/


All Articles