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

Errors with nvim-treesitter #15

Open
comiluv opened this issue Sep 30, 2024 · 3 comments
Open

Errors with nvim-treesitter #15

comiluv opened this issue Sep 30, 2024 · 3 comments

Comments

@comiluv
Copy link

comiluv commented Sep 30, 2024

Description

:checkhealth nvim-treesitter reports error messages for C# and Zig

Neovim version

v0.10.1

How to reproduce the issue

  1. Use minimal init.lua as below
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{
			"nvim-treesitter/nvim-treesitter",
			opts = { ensure_installed = { "c_sharp", "zig" } },
			config = function(_, opts)
				require("nvim-treesitter.configs").setup(opts)
			end,
		},
		"p00f/alabaster.nvim",
	},
})
vim.cmd.colorscheme("alabaster")
  1. :checkhealth nvim-treesitter
  2. See error

Output of :checkhealth nvim-treesitter

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

Installation ~
- OK `tree-sitter` found 0.23.0 (12fb31826b8469cc7b9788e72bceee5af1cf0977) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.17.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Rev1, Built by MSYS2 project) 14.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 = "10.0.22631",
  sysname = "Windows_NT",
  version = "Windows 11 Pro"
} ~

Parser/Features         H L F I J
  - c_sharp             x ✓ ✓ . ✓
  - zig                 x ✓ ✓ ✓ ✓

  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 c_sharp(highlights): .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 589:2. Invalid node type "record_struct_declaration":
  (record_struct_declaration
   ^
  
  c_sharp(highlights) is concatenated from the following files:
  |    [OK]:"C:\Users\username\OneDrive\dotfiles\.repro\data\nvim-data\lazy\nvim-treesitter\queries\c_sharp\highlights.scm"
  | [ERROR]:"C:\Users\username\OneDrive\dotfiles\.repro\data\nvim-data\lazy\alabaster.nvim\after\queries\c_sharp\highlights.scm", failed to load: .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 12:2. Invalid node type "record_struct_declaration":
  (record_struct_declaration
   ^
  
- ERROR zig(highlights): .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 287:2. Invalid node type "Decl":
  (Decl
   ^
  
  zig(highlights) is concatenated from the following files:
  |    [OK]:"C:\Users\username\OneDrive\dotfiles\.repro\data\nvim-data\lazy\nvim-treesitter\queries\zig\highlights.scm"
  | [ERROR]:"C:\Users\username\OneDrive\dotfiles\.repro\data\nvim-data\lazy\alabaster.nvim\after\queries\zig\highlights.scm", failed to load: .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 4:2. Invalid node type "Decl":
  (Decl
   ^
@comiluv
Copy link
Author

comiluv commented Sep 30, 2024

If I do :TSInstall all and then :che nvim-treesitter, report shows 3 errors (out of all 297 parsers)

The following errors have been detected: ~
- ERROR c_sharp(highlights): .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 589:2. Invalid node type "record_struct_declaration":
  (record_struct_declaration
   ^
  
  c_sharp(highlights) is concatenated from the following files:
  |    [OK]:"C:\Users\username\AppData\Local\nvim-data\lazy\nvim-treesitter\queries\c_sharp\highlights.scm"
  | [ERROR]:"C:\Users\username\AppData\Local\nvim-data\lazy\alabaster.nvim\after\queries\c_sharp\highlights.scm", failed to load: .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 12:2. Invalid node type "record_struct_declaration":
  (record_struct_declaration
   ^
  
- ERROR hare(highlights): .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 278:12. Invalid node type "name":
            (name) @AlabasterDefinition))
             ^
  
  hare(highlights) is concatenated from the following files:
  |    [OK]:"C:\Users\username\AppData\Local\nvim-data\lazy\nvim-treesitter\queries\hare\highlights.scm"
  | [ERROR]:"C:\Users\username\AppData\Local\nvim-data\lazy\alabaster.nvim\after\queries\hare\highlights.scm", failed to load: .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 6:12. Invalid node type "name":
            (name) @AlabasterDefinition))
             ^
  
- ERROR zig(highlights): .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 287:2. Invalid node type "Decl":
  (Decl
   ^
  
  zig(highlights) is concatenated from the following files:
  |    [OK]:"C:\Users\username\AppData\Local\nvim-data\lazy\nvim-treesitter\queries\zig\highlights.scm"
  | [ERROR]:"C:\Users\username\AppData\Local\nvim-data\lazy\alabaster.nvim\after\queries\zig\highlights.scm", failed to load: .../current/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 4:2. Invalid node type "Decl":
  (Decl
   ^

@p00f
Copy link
Owner

p00f commented Oct 1, 2024

I don't write C#, @Zorbn can you take a look? I'll update zig

@Zorbn
Copy link
Contributor

Zorbn commented Oct 2, 2024

It's been a while since I used Neovim but I guess record_struct_declaration just doesn't exist (anymore?) so it can be removed from the highlights file. Maybe all of those C# *_declarations can be replaced with a single type_declaration.

https://github.com/tree-sitter/tree-sitter-c-sharp/blob/fd7f7402db6e66afd70b402fb2e367b2d71c10d6/grammar.js#L250

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

3 participants