HiPhish / rainbow-delimiters.nvim

Rainbow delimiters for Neovim with Tree-sitter
https://gitlab.com/HiPhish/rainbow-delimiters.nvim
Apache License 2.0
471 stars 35 forks source link

[Bug]: Error attaching strategy to buffer when open cpp file #25

Closed HATTER-LONG closed 11 months ago

HATTER-LONG commented 11 months ago

Neovim version

0.9.1

Language affected

cpp

Query

No response

Strategy

No response

Description

I'm not sure what caused it, it's not working on CPP.

working normally on lua ft.

#include <iostream>

int main(void)
{
    std::cout << "Hello, world!" << std::endl;
    return 0;
}
❯ cat rainbow-delimiters.log
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: rainbow-delimiters.log
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ 2023-08-13T10:58+0800   ERROR       Error attaching strategy to buffer 1: ...-3ce3218/share/nvim/runtime/lua
       │ /vim/treesitter/query.lua:273: query: invalid structure at position 338 for language cpp
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.5.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: Apple clang version 14.0.3 (clang-1403.0.22.14.1)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "arm64",
  release = "22.5.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - regex               ✓ . . . .
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  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} ~
HATTER-LONG commented 11 months ago

I think this is related to my Mac OS environment. I tested it on the Ubuntu server and it worked properly.

What is the possible cause of this? 😓

plugin config like this https://github.com/AstroNvim/astrocommunity/tree/main/lua/astrocommunity/editing-support/rainbow-delimiters-nvim

Isrothy commented 11 months ago

Same issue. Working on MacOS and Neovim 0.10.0

tan-wei commented 11 months ago

Met the same issue. I write cpp code block in markdown. It will cause:

Error in decoration provider treesitter/highlighter.win:
Error executing lua: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:273: query: invalid structure at position 338 for language cpp
stack traceback:
    [C]: in function '_ts_parse_query'
    /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:273: in function 'parse'
    /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:232: in function 'get_query'
    ...y/rainbow-delimiters.nvim/lua/rainbow-delimiters/lib.lua:68: in function 'get_query'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:108: in function 'fn'
    /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:457: in function 'for_each_child'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:104: in function 'setup_parser'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:133: in function 'cb'
    /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:838: in function '_do_callback'
    /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:501: in function '

I can confirm my cpp treesitter parser is update, and I use neovim-nightly.

jjiangweilan commented 11 months ago

Same here, Not working on cpp file. It's working on lua. I'm on MacOS, nvim version 0.10.0

HiPhish commented 11 months ago

Please try the current master branch. The Tree-sitter grammar for C++ has changed and is no longer compatible with the C grammar, so I had to update the query. Everything should work now.

jjiangweilan commented 11 months ago

Great! It's fixed on my end

tan-wei commented 11 months ago

I can confirm it is fixed after I do an update. I think the issue should be closed then. Thanks for this quick fix!

HATTER-LONG commented 11 months ago

work normally, thanks