alabaster.nvim icon indicating copy to clipboard operation
alabaster.nvim copied to clipboard

Errors with nvim-treesitter

Open comiluv opened this issue 1 year ago • 3 comments

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 avatar Sep 30 '24 19:09 comiluv

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
   ^

comiluv avatar Sep 30 '24 20:09 comiluv

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

p00f avatar Oct 01 '24 05:10 p00f

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

Zorbn avatar Oct 02 '24 17:10 Zorbn