syntax highlighting - nvim treesitter highlight for "#if...#elif...#endif" preprocessors - Stack Overflow

I am using nvim + nvim-treesitter to parse and highlight my code. There is a problem on C source code #

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744894856a4599632.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信