I am using nvim + nvim-treesitter to parse and highlight my code. There is a problem on C source code #if...#elif...#endif
preprocessor block.
Say I have the following code
// test.c
#include "test.h"
#if defined(MACRO_A)
uint32_t myVar;
#elif defined(MACRO_B)
uint16_t myVar;
#endif
The default highlighting is as the following, as no macro definition is there.
If I define MACRO_A
in test.h. The highlight is changed as expected. Content following MACRO_A
is displayed normally, content following MACRO_B
is commented out.
The problem is, for real world code, the macro is not always defined in a header file, it can be passed from IDE preprocessor settings or command line arguments. How do I let nvim/treesitter know such macro definition?