sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.9k stars 164 forks source link

An "extern" C "{" line affects the syntax coloring of the rest of the file. #159

Closed chaiNeehujui closed 1 year ago

chaiNeehujui commented 1 year ago

I have done the following steps before reporting this issue:

Operating system/version

debian bullseye

Terminal emulator/version

xfce4-terminal 1.0.4

$TERM environment variable

xterm-256color

Tmux version

No response

Feature matrix

man: require("man.health").check()
========================================================================
  - OK: plugin/man.vim not in $VIMRUNTIME
  - OK: autoload/man.vim not in $VIMRUNTIME

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='7001'
  - INFO: $COLORTERM='truecolor'

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - WARNING: `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `git` executable found.
  - OK: `/usr/bin/gcc` executable found. Selected from { "/usr/bin/gcc", "cc", "gcc", "clang", "cl", "zig" }
    Version: gcc (Debian 12.2.0-9) 12.2.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## OS Info:
{
  machine = "x86_64",
  release = "6.0.0-4-amd64",
  sysname = "Linux",
  version = "#1 SMP PREEMPT_DYNAMIC Debian 6.0.8-1 (2022-11-11)"
}

## Parser/Features H L F I J
  - vim            x ✓ ✓ . ✓
  - lua            x ✓ ✓ ✓ ✓
  - help           x . . . x
  - cpp            ✓ ✓ ✓ ✓ ✓
  - c_sharp        ✓ ✓ ✓ . ✓
  - c              ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

## The following errors have been detected:
  - ERROR: vim(highlights): /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 2765 for language vim
    vim(highlights) is concatenated from the following files:
    | [ERROR]:"/home/akanmuratcimen/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/vim/highlights.scm", failed to load: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 2765 for language vim
  - ERROR: lua(highlights): /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 1141 for language lua
    lua(highlights) is concatenated from the following files:
    | [ERROR]:"/home/akanmuratcimen/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/lua/highlights.scm", failed to load: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 1141 for language lua
  - ERROR: help(highlights): /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 424 for language help
    help(highlights) is concatenated from the following files:
    | [ERROR]:"/home/akanmuratcimen/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/help/highlights.scm", failed to load: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 424 for language help
  - ERROR: help(injections): /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 14 for language help
    help(injections) is concatenated from the following files:
    | [ERROR]:"/home/akanmuratcimen/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/help/injections.scm", failed to load: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:219: query: invalid node type at position 14 for language help

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 3 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - WARNING: Could not load Python 3:
    /usr/bin/python3 does not have the "neovim" module.
    /usr/bin/python3.10 does not have the "neovim" module.
    python3.9 not found in search path or not executable.
    python3.8 not found in search path or not executable.
    python3.7 not found in search path or not executable.
    python not found in search path or not executable.
    - ADVICE:
      - See :help |provider-python| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
  - INFO: Executable: Not found

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - WARNING: `ruby` and `gem` must be in $PATH.
    - ADVICE:
      - Install Ruby and verify that `ruby` and `gem` commands work.

## Node.js provider (optional)
  - WARNING: `node` and `npm` (or `yarn`, `pnpm`) must be in $PATH.
    - ADVICE:
      - Install Node.js and verify that `node` and `npm` (or `yarn`, `pnpm`) commands work.

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.4.0

## ===== Installed extensions =====

## Telescope Extension: `fzf`
  - INFO: No healthcheck provided

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/akanmuratcimen/.local/state/nvim/lsp.log
  - INFO: Log size: 0 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for c_sharp: ABI version 13
  - OK: Loaded parser for cpp: ABI version 14
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for help: ABI version 14
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for vim: ABI version 14

Minimal vimrc that can reproduce this bug.

vim.opt.termguicolors = true
vim.opt.background = 'dark'

vim.cmd 'syntax enable'

vim.g.gruvbox_material_background = 'hard'
vim.cmd 'colorscheme gruvbox-material'

Steps to reproduce this bug using minimal vimrc

create a .c file. paste the following code:

#if defined(__cplusplus)
extern "C" {
#endif

struct window_size {
  int width;
  int height;
} window_size;

int speed;

comment and uncomment "extern "C" {" line (by using #) and see the changes on 'window_size' and 'speed' keywords.

Expected behavior

In a C file, commenting/uncommentting "extern "C" {" line should not affect the following syntax coloring. The expected behavior is as if the line "extern" C "{" does not exist.

Actual behavior

As you can see in the pictures below; in a C file, commenting/uncommentting the line "extern "C" {" changes the following colors.

https://imgur.com/a/kW41GL8

edit (@antoineco): add code fences

antoineco commented 1 year ago

@akanmuratcimen Gruvbox Material is a color scheme, it has no influence on filetype syntax. If you switch to a different color scheme you'll observe the same behavior.

I would suggest reporting this to Vim directly if this is actually a bug in the cpp syntax.

Also, since you are using Neovim, enabling Treesitter syntax instead of Vim's default regexp-based syntax would give you much more accurate (and most likely bug-free) syntax highlights.

chaiNeehujui commented 1 year ago

I'm already using Treesitter but you're right; the same behavior happens in another color scheme. I think this is a Treesitter bug. Thanks.