Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query: invalid node type at position 268 and other errors #27

Open
kmaasrud opened this issue Mar 27, 2022 · 5 comments
Open

query: invalid node type at position 268 and other errors #27

kmaasrud opened this issue Mar 27, 2022 · 5 comments

Comments

@kmaasrud
Copy link

The latest tree-sitter-nix gives me a bunch of errors and fails to parse any Nix buffer. The error I get printed as virtual text in my editor is: <nix-store-path-to-nvim>/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 268.

Running :checkhealth nvim-treesitter gives me the following:

  - ERROR: nix(highlights): ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 268
    nix(highlights) is concatenated from the following files:
    | [ERROR]:"/nix/store/81bljv7lbi9w22qi38p9rl8pq6m8fkf1-vim-pack-dir/pack/home-manager/start/nvim-treesitter/queries/nix/highlights.scm", failed to load: ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 268
  - ERROR: nix(locals): ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 16
    nix(locals) is concatenated from the following files:
    | [ERROR]:"/nix/store/81bljv7lbi9w22qi38p9rl8pq6m8fkf1-vim-pack-dir/pack/home-manager/start/nvim-treesitter/queries/nix/locals.scm", failed to load: ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 16
  - ERROR: nix(folds): ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 86
    nix(folds) is concatenated from the following files:
    | [ERROR]:"/nix/store/81bljv7lbi9w22qi38p9rl8pq6m8fkf1-vim-pack-dir/pack/home-manager/start/nvim-treesitter/queries/nix/folds.scm", failed to load: ...ed-0.6.1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 86

I have installed the Nix grammar through Nix (vimPlugins.nvim-treesitter.withPlugins (plugins: [ ... plugins.tree-sitter-nix ... ])). My system is an Macbook Air M1 running the latest macOS 12.3 and I have Neovim 0.6.1 installed.

I am not quite sure how to interpret these errors, and if the fault is with me or with the grammar. Any help is very much appreciated 😄

@Electrostasy
Copy link

I also have this issue running NixOS from the nixpkgs-unstable branch. This PR should help, seems it's already merged in at least master and nixos-unstable-small.

@kmaasrud
Copy link
Author

kmaasrud commented Mar 28, 2022

Thanks for the additional info @Electrostasy! I saw that PR too, and according to @siraben it seems that the issue might be with the queries, not the grammar (- as the error message does indeed indicate.) This should at least be documented, as I'm apparently not the only one whose tree-sitter config is rendered broken.

@cstrahan
Copy link
Collaborator

cstrahan commented Apr 5, 2022

Hey all,

Sorry, I didn't realize third-parties/packagers would automatically follow master (at least not without any testing being done first). My apologies for the hassle. I wanted to add a breaking change to get the grammar up to parity with the official Nix parser (i.e. the support for interpolation syntax in paths that was added to Nix in NixOS/nix#5066), and took this as an opportunity to address the collective feedback regarding naming and the shape of the AST. I don't expect any further big changes, and I hope to soon release a version 1.0.0 that can give some assurance around that.

@adisbladis
Copy link
Member

I believe that with nvim-treesitter/nvim-treesitter#2957 and NixOS/nixpkgs#174740 this issue can be closed.

@hagen-eriksen
Copy link

Hi everyone,

I just installed the nix grammar for treesitter using :TSInstall nix, i.e. I do not use the grammar from Nixpkgs, and I have the exact same issues as above.

Specifically, my nix code is not highlighted and when running :checkhealth nvim-treesitter, I get:

  1                                                                                                                                                                stack traceback:
  2 nvim-treesitter: require("nvim-treesitter.health").check()
  3 ========================================================================
  4 ## Installation
  5   - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  6   - OK: `node` found v16.15.0 (only needed for :TSInstallFromGrammar)
  7   - OK: `git` executable found.
  8   - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  9     Version: gcc (GCC) 11.3.0
 10   - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
 11
 12 ## Parser/Features H L F I J
 13   - python         ✓ ✓ ✓ ✓ ✓
 14   - latex          ✓ . ✓ . ✓
 15   - nix            x x x . ✓
 16   - scala          ✓ . ✓ . ✓
 17
 18   Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
 19          +) multiple parsers found, only one will be used
 20          x) errors found in the query, try to run :TSUpdate {lang}
 21
 22 ## The following errors have been detected:
 23   - ERROR: nix(highlights): ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 268
 24     nix(highlights) is concatenated from the following files:
 25     | [ERROR]:"/home/yves/.local/share/nvim/site/pack/packer/opt/nvim-treesitter/queries/nix/highlights.scm", failed to load: ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 268
 26   - ERROR: nix(locals): ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 16
 27     nix(locals) is concatenated from the following files:
 28     | [ERROR]:"/home/yves/.local/share/nvim/site/pack/packer/opt/nvim-treesitter/queries/nix/locals.scm", failed to load: ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 16
 29   - ERROR: nix(folds): ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 86
 30     nix(folds) is concatenated from the following files:
 31     | [ERROR]:"/home/yves/.local/share/nvim/site/pack/packer/opt/nvim-treesitter/queries/nix/folds.scm", failed to load: ...ed-0.7.0/share/nvim/runtime/lua/vim/treesitter/query.lua:172: query: invalid node type at position 86

How should I proceed to fix this issue?

In any case, thanks a lot for the hard work! I really appreciate that there is a treesitter grammar for nix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants