emacs-lsp / emacs-ccls

Emacs client for ccls, a C/C++ language server
200 stars 29 forks source link

cpp source file doesn't have syntax highlighting at all #35

Closed zhongweiy closed 5 years ago

zhongweiy commented 5 years ago

Hi, there, In my project, some cpp file have syntax highlight but some have not at all. I even have seen a cpp file which half of it have syntax highlight but the other half doesn't (but this case can not be reproduced after revert-buffer).

And if put the cursor on the keyword (like if) of the cpp file doesn't have syntax highlight and call the describe-face gives the Face: Face: ccls-skipped-range-face. Is it caused by some issue in emacs-ccls? How can I get back my syntax highlight? Thanks!

zhongweiy commented 5 years ago

I find setting the ccls-skipped-range-face to nil can get the highlighting back.

I have not debugged into it. And if any log or information needed, please tell me.

MaskRay commented 5 years ago

These ranges are skipped by clang because the #if #ifdef #else branch isn't taken.

In the following case,

#ifdef A
int a;
#else 
int b;
#endif

There is at least one skipped range. You may say that the file is compiled twice with -DA or without it, but each file is only indexed once.

You can also set (setq ccls-enable-skipped-ranges nil) if you don't like skipped ranges.