4

I use Vim with clang_complete for omnicompletion.

The plugin is automatically triggered when I need completion, e.g., after I type . or -> to access an object members or methods (see screenshot below).

clang_complete showing std::map methods

The plugin works really nice, however I would need a way to trigger it manually (i.e. to compile my code for syntax checking).

This is useful for two reasons:

  1. Static syntax checking
  2. Clear previous errors which have been fixed (which otherwise will remain in their buffer). See the two screenshots below for a better understanding.

Any help is appreciated. Thanks.


Screenshot 1


Error at line 3


Screenshot 2


Error fixed


Peeter Joot
  • 7,848
  • 7
  • 48
  • 82
Vincenzo Pii
  • 18,961
  • 8
  • 39
  • 49

2 Answers2

3

From the clang_complete docs:

        *clang_complete-periodic_quickfix*
        *g:clang_periodic_quickfix*
If equal to 1, it will periodically update the quickfix window.
Default: 0
Note: You could use the g:ClangUpdateQuickFix() to do the same with a mapping.

If you set this variable to 1, it would update the quickfix window periodically, (and) or you could create a mapping thus:

nmap <leader>uq :call g:ClangUpdateQuickFix()

so that \uq would cause the update. (of course, using YOUR leader mapping, naturally)

lornix
  • 1,946
  • 17
  • 14
1

If you're looking for syntax checking on the fly, I suggest you have a look at syntastic, which basically runs g++ --fsyntaxonly on your code and marks the errors on your buffer. You can also configure it to use clang!