HiPhish / rainbow-delimiters.nvim

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

[Bug]: Parse Error on vim.lsp.hover #133

Open MinaMatta98 opened 3 weeks ago

MinaMatta98 commented 3 weeks ago

Neovim version

NVIM v0.10.1 Build type: Release LuaJIT 2.1.1720049189

Language affected

Go / markdown_inline

Query

No response

Strategy

No response

Description

The original bug report was sent to the team at tree sitter: https://github.com/tree-sitter/tree-sitter/issues/3536#issue-2471829552

They said I should come here.

My specs and distro:

                  -`                    mina@Z370-Aorus
                  .o+`                   ---------------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Host: B650 AORUS ELITE AX
               `+oooooo:                 Kernel: 6.6.43-rt38-x64v2-1-xanmod1-rt
               -+oooooo+:                Uptime: 2 days, 14 hours, 14 mins
             `/:-:++oooo+:               Packages: 2471 (pacman), 24 (brew), 6 (flatpak)
            `/++++/+++++++:              Shell: zsh 5.9
           `/++++++++++++++:             Resolution: 1920x1080
          `/+++ooooooooooooo/`           WM: dwm
         ./ooosssso++osssssso+`          Theme: Tokyonight-Storm-BL [GTK2/3]
        .oossssso-````/ossssss+`         Icons: Lyra-purple [GTK2/3]
       -osssssso.      :ssssssso.        Terminal: alacritty
      :osssssss/        osssso+++.       CPU: AMD Ryzen 9 7950X3D (32) @ 5.759GHz
     /ossssssss/        +ssssooo/-       GPU: NVIDIA GeForce GTX 1080
   `/ossssso+/:-        -:/+osssso+-     GPU: AMD ATI 11:00.0 Raphael
  `+sso+:-`                 `.-/+oso:    Memory: 10995MiB / 63443MiB
 `++:.                           `-/+/
 .`                                 `/

Error on vim.lsp.hover

Error in decoration provider treesitter/highlighter.win:
Error executing lua: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:253: Query error at 10:3. Impossible pattern:
  "(" @delimiter
  ^

stack traceback:
    [C]: in function '_ts_parse_query'
    /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:253: in function 'fn'
    /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
    /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'get_query'
    ...y/rainbow-delimiters.nvim/lua/rainbow-delimiters/lib.lua:77: in function 'get_query'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:191: in function 'thunk'
    .../rainbow-delimiters.nvim/lua/rainbow-delimiters/util.lua:33: in function 'for_each_child'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:187: in function 'setup_parser'
    ...limiters.nvim/lua/rainbow-delimiters/strategy/global.lua:266: in function 'cb'
    /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:899: in function '_do_callback'
    /usr/s

Tree Sitter Check Health:

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v22.6.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `gcc` executable found. Selected from { "gcc", "cc", "gcc", "clang", "cl", "zig" }
  Version: gcc (GCC) 14.2.1 20240805
- 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.6.43-rt38-x64v2-1-xanmod1-rt",
  sysname = "Linux",
  version = "#1 SMP PREEMPT_RT Sat, 03 Aug 2024 06:42:37 +0000"
} ~

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - gomod               ✓ . . . ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - 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} ~-

I edited /usr/share/nvim/runtime/lua/vim/treesitter/query.lua line 252 to output the language in question. When hovering above a symbol, the language used is specifically markdown_inline. This is contrasted with doing the same thing in RUST, which returns...rust. I don't get errors parsing rust.

image

image

Commentary from the tree-sitter team:

EDIT: No, the error

..y/rainbow-delimiters.nvim/lua/rainbow-delimiters/lib.lua:77

points to that plugin bundling outdated queries. Please complain there.

Originally posted by @clason in https://github.com/tree-sitter/tree-sitter/issues/3536#issuecomment-2295203727

HiPhish commented 3 weeks ago

Looks like there was a change in the upstream Go parser. I have pushed a fix, please try the current master branch.

MinaMatta98 commented 3 weeks ago

Hello,

It works.

I pinned my lazy config as follows:

    {
        "https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
        branch = "master",
        dependencies = "nvim-treesitter/nvim-treesitter",
        event = "FileType",
        enabled = true,
        config = function()
            local rainbow_delimiters = require("rainbow-delimiters")
            require("rainbow-delimiters.setup").setup({
                strategy = {
                    [""] = rainbow_delimiters.strategy["global"],
                    vim = rainbow_delimiters.strategy["local"],
                },
                query = {
                    [""] = "rainbow-delimiters",
                    lua = "rainbow-blocks",
                },
                priority = {
                    [""] = 110,
                    lua = 210,
                },
                highlight = {
                    "RainbowDelimiterRed",
                    "RainbowDelimiterYellow",
                    "RainbowDelimiterBlue",
                    "RainbowDelimiterOrange",
                    "RainbowDelimiterGreen",
                    "RainbowDelimiterViolet",
                    "RainbowDelimiterCyan",
                },
            })
        end,
    },

And no more errors. Thank you!

HiPhish commented 3 weeks ago

FYI, your config can be made shorter if you omit all the setting which you are setting to the defaults anyway. In your case that's the highlights and the settings which have the empty string as their key.

This plugin works out of the box without any settings, you only need to specify that which you are changing.

MinaMatta98 commented 3 weeks ago

Yes, but I purposefully paste the settings so that I don't have to go back to the repo to find them if I need to 😅.

Cheers for the advice

HiPhish commented 3 weeks ago

You can find all settings under :h rb-delimiters-setup, you don't have to look up them up in the repo. But it's not as if those redundant settings cause any harm either, so use whatever works for you.