tree-sitter-nu icon indicating copy to clipboard operation
tree-sitter-nu copied to clipboard

Neovim highlight is (sometimes) broken

Open Tazoeur opened this issue 3 months ago • 6 comments

Sometimes (3 out of 4 times I'd say), instead of providing a good highliting, I have the following error instead.

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):Error executing lua callback: ...64/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:266: ...x-x86_64/share/
nvim/runtime/lua/vim/treesitter/query.lua:373: Query error at 24:6. Invalid node type "register":
    "register"
     ^

stack traceback:
        [C]: in function 'error'
        ...64/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:266: in function 'get_query'
        ...64/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:107: in function 'set_conceal_lines'
        ...64/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:146: in function 'new'
        ...m-linux-x86_64/share/nvim/runtime/lua/vim/treesitter.lua:432: in function 'start'
        ...m/lazy/nvim-treesitter/lua/nvim-treesitter/highlight.lua:20: in function 'attach'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:132>
        [C]: in function 'nvim_cmd'
        ...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:36: in function <...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'pcall'
        vim/shared.lua: in function <vim/shared.lua:0>
        [C]: in function '_with'
        ...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:35: in function <...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function '_with'
        ...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:35: in function <...u/.opt/nvim-linux-x86_64/share/nvim/runtime/filetype.lua:10>

Here's what checkhealth nvim-treesitter provides

- ✅ OK `node` found v23.11.1 (only needed for :TSInstallFromGrammar)
- ✅ OK `git` executable found.
- ✅ OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
- ✅ OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "6.8.0-65-generic",
  sysname = "Linux",
  version = "#68~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 15 18:06:34 UTC 2"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - c_sharp             ✓ ✓ ✓ . ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - csv                 ✓ . . . .
  - diff                ✓ . ✓ . ✓
  - dockerfile          ✓ . . . ✓
  - git_config          ✓ . ✓ . ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - groovy              ✓ ✓ ✓ ✓ ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - ini                 ✓ . ✓ . ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - luadoc              ✓ . . . .
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - nu                  x . ✓ ✓ ✓
  - properties          ✓ ✓ . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - requirements        ✓ . . . ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - sql                 ✓ . ✓ ✓ ✓
  - ssh_config          ✓ ✓ ✓ ✓ ✓
  - tmux                ✓ . . . ✓
  - toml                ✓ ✓ ✓ ✓ ✓
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  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 nu(highlights): ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:373: Query error at 24:6. Invalid node type "register":
      "register"
       ^

  nu(highlights) is concatenated from the following files:
  | [ERROR]:"/home/me/.local/share/nvim/lazy/nvim-nu/queries/nu/highlights.scm", failed to load: ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:373: Query error at 24:6. Invalid node type "register":
      "register"
       ^

I have relied on the TS "ensure_installed" property to install the nu parser, because I understood we shouldn't install this repository as nvim plugin anymore.

I don't really understand why sometimes it's working as intended, and sometimes I get this error...

I hope this bug report is useful, in the meantime do you think of a workaround ?

Tazoeur avatar Aug 28 '25 09:08 Tazoeur

tree-sitter-nu is not compatible with https://github.com/LhKipp/nvim-nu.

You probably don't need it if you know how to setup nu-lsp

blindFS avatar Aug 28 '25 09:08 blindFS

I am having the same issue I believe. @blindFS are you saying if I remove the LhKipp/nvim-nu plugin, then the tree sitter nu will install without this error? Because at the end of the day I am mainly interested in getting highlighting to work.

mig-hub avatar Oct 31 '25 06:10 mig-hub

I am having the same issue I believe. @blindFS are you saying if I remove the LhKipp/nvim-nu plugin, then the tree sitter nu will install without this error? Because at the end of the day I am mainly interested in getting highlighting to work.

Yes, install the latest main (not the master branch) of nvim-treesitter, then :TSInstall nu.

blindFS avatar Oct 31 '25 07:10 blindFS

@blindFS sorry I am not really familiar with tree sitter itself because I rarely have to do anything. Most languages are working out of the box. I have updated my tree sitter install to use the main branch. I have done :TSInstall nu. It seemed to have worked, because I had a feedback message and when I run :checkhealth I see it installed. However when I navigate to a file like "config.nu", it is not recognised. The text stays all white and :set ft? returns nothing. Setting this file type to "nu" or "nushell" does not seem to do the trick either.

Is there a setting I need to implement in order to make nvim+treesitter start handling these files?

mig-hub avatar Nov 03 '25 13:11 mig-hub

@mig-hub I use a nvim distro so I don't have to set it up manually.

But I guess this is what you're looking for.

blindFS avatar Nov 03 '25 14:11 blindFS

@blindFS Actually I had already something similar, but I had "*.nu" as a pattern instead of just "nu". It is all working fine now. Thank you for your feedbacks !

mig-hub avatar Nov 04 '25 08:11 mig-hub