helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.63k stars 2.5k forks source link

C syntax highlight for "#if 0" #4955

Closed pandysong closed 6 months ago

pandysong commented 1 year ago

Summary

The code inside "#if 0" is not greyed out.

Reproduction Steps

"""

include

include

int main() {

if 0

int i;
int j;
int k;
int l;
int m;
i = 1;
j = i +1;

endif

int a;
return 0;

} """

Open above code in hx

I expected this to happen (what happened in vim)

image

Instead, this happened:

image

Helix log

No response

Platform

macOS/Linux

Terminal Emulator

tmux

Helix Version

helix 22.08.1 (590a6284)

pascalkuthe commented 1 year ago

Helix uses treesitter grammars for syntax highlighting which can currently not display semantic information. This might theoretically be implemented with stackgraphs #1252 but the problem in practice is that most defines either come from CLI compiler flags or header files (and the include directories are once again defined by compiler flags) that makes this pretty hard to implement.

Other editors achieve this using LSP semantic highlighting (see #814) but that is not supported in helix (and there is hesitancy about supporting it for performance reasons).