nvim-treesitter / nvim-treesitter

Nvim Treesitter configurations and abstraction layer
Apache License 2.0
10.79k stars 901 forks source link

Error: No handler for is-not? #6870

Closed pope closed 4 months ago

pope commented 4 months ago

Describe the bug

This is the error reported anytime I open a nix file.

Error in decoration provider treesitter/highlighter.line:
Error executing lua: ...d-0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:763: No handler for is-not?
stack traceback:
        [C]: in function 'error'
        ...d-0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:763: in function 'fn'
        ...pped-0.10.0/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'match_preds'
        ...d-0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:883: in function 'iter'
        ....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:310: in function 'fn'
        ....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:210: in function 'for_each_highlight_state'
        ....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:291: in function 'on_line_impl'
        ....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:367: in function <....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:361>

To Reproduce

  1. Ensure that the nix parser is available
  2. Open a nix file
  3. Observe the error

Expected behavior

That this error would be handled. The file mostly appears to be OK, just any action change and this error starts showing up disrupting the editing process.

Output of :checkhealth nvim-treesitter

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

Installation ~
- OK `tree-sitter` found 0.22.5 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.12.2 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: gcc (GCC) 13.3.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.6.36",
  sysname = "Linux",
  version = "#1-NixOS SMP PREEMPT_DYNAMIC Thu Jun 27 11:49:15 UTC 2024"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - nix                 ✓ ✓ ✓ . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - 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} ~

Output of nvim --version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info

Additional context

No response

clason commented 4 months ago

No handler for is-not?

None of the queries in nvim-treesitter use this predicate, so the error comes from somewhere else.

pope commented 4 months ago

Gotcha. Seems then https://github.com/nix-community/tree-sitter-nix is the right spot. But this is-not? predicate hasn't been touched in 3 years, but only recently has it started reporting this error.

pope commented 4 months ago

I downgraded nvim-treesitter and the issue was still there. I'll try looking in other spots.

juanibiapina commented 4 months ago

I'm getting this error after a recent update, haven't been able to identify where is it coming from yet.

clason commented 4 months ago

A "recent update" of what exactly?

clason commented 4 months ago

(Note that the tree-sitter-nix queries are not compatible with Neovim; you can't use them -- and if you include the repo as a plugin, they will pollute your runtimepath.)

juanibiapina commented 4 months ago

I get the error after upgrading nixpkgs:

    'github:NixOS/nixpkgs/b2852eb9365c6de48ffb0dc2c9562591f652242a' (2024-06-27)
  → 'github:NixOS/nixpkgs/655a58a72a6601292512670343087c2d75d859c1' (2024-07-08)

I was able to narrow it down to this commit: https://github.com/NixOS/nixpkgs/commit/e4207a145f8762c4b0b7f8314ac239567fe6a564

But the changes to tree-sitter-nix are meaningless (just a README change), so I don't understand yet what's going on. I think I may be missing some other change, possibly to nvim-treesitter itself.

clason commented 4 months ago

Nope, this has nothing to do with this plugin. Please follow up on the NixOS support channels.

wrvsrx commented 3 months ago

It's caused by 51e69413cfc928d02e19c27c9342af2931166d4d rather than what @juanibiapina says

I get the error after upgrading nixpkgs:

    'github:NixOS/nixpkgs/b2852eb9365c6de48ffb0dc2c9562591f652242a' (2024-06-27)
  → 'github:NixOS/nixpkgs/655a58a72a6601292512670343087c2d75d859c1' (2024-07-08)

I was able to narrow it down to this commit: NixOS/nixpkgs@e4207a1

But the changes to tree-sitter-nix are meaningless (just a README change), so I don't understand yet what's going on. I think I may be missing some other change, possibly to nvim-treesitter itself.

humemm commented 3 months ago

@pope @wrvsrx @juanibiapina I'm running into the same issue. For one in nix files but also in some other situations. Were any of you able to come up with a fix. Any help would be appreciated. I was not able to find an issue on nix packages related to this.

Related: https://github.com/nix-community/tree-sitter-nix/issues/56 https://github.com/NixOS/nixpkgs/pull/321550

pope commented 3 months ago

@pope @wrvsrx @juanibiapina I'm running into the same issue. For one in nix files but also in some other situations. Were any of you able to come up with a fix. Any help would be appreciated. I was not able to find an issue on nix packages related to this.

Related: nix-community/tree-sitter-nix#56 NixOS/nixpkgs#321550

The only thing I did so far was use the nix package from stable - and everything was using unstable. I haven't tried any other solution yet

wrvsrx commented 2 months ago

@humemm I fix that by removing queries from neovim treesitter grammars

                parsers = pkgs.symlinkJoin {
                  name = "treesitter-parsers";
                  paths = nvim-treesitter.withAllGrammars.dependencies;
                  postBuild = "rm -r $out/queries";
                };
juanibiapina commented 1 month ago

For clarity, seem like this project doesn't support is-not?. I found some evidence on this commented out query: https://github.com/nvim-treesitter/nvim-treesitter/blob/1fbc25fc111cf5c7e73819657c8968dc5fa302ad/queries/ruby/highlights.scm#L173-L176

clason commented 1 month ago

For clarity, we do not use locals for highlighting at all.