ellisonleao/gruvbox.nvim

Comment out conditionally compiled code (C/C++) if inactive

nysal opened this issue · 1 comments

nysal commented

Describe the bug
C/C++ have preprocessor directives for conditionally compiling code. It will be nice to comment out inactive code blocks

To Reproduce
Steps to reproduce the behavior:

  1. The screenshots posted below are from the Linux kernel code, but any C/C++ code with the following preprocessor directives should exhibit the issue
#define __BLOCK1 1

#ifdef __BLOCK1
// Code block 1
#else
// Code block 2
#endif

Expected behavior
// Code block 2 should be commented out

Screenshots
Ran :Inspect and took screenshots of gruvbox and tokyonight color schemes:
1gb

The #else block is inactive and commented out
1tn

Additional context
The following patch helps, but it does inherit the italic from the Comment style, which seems reasonable to me.

@@ -1023,7 +1023,7 @@ local function get_groups()
     ["@macro"] = { link = "Macro" },
     ["@structure"] = { link = "Structure" },
     ["@lsp.type.class"] = { link = "@type" },
-    ["@lsp.type.comment"] = {}, -- do not overwrite comments
+    ["@lsp.type.comment"] = { link = "@comment" },
     ["@lsp.type.decorator"] = { link = "@macro" },
     ["@lsp.type.enum"] = { link = "@type" },
     ["@lsp.type.enumMember"] = { link = "@constant" },

hey @nysal thanks for the issue. Can you open a PR please?