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

highlights.scm errors

Open fdncred opened this issue 1 year ago • 10 comments

A report this morning in editor-support in discord had me reinstalling/recompiling tree-sitter-nu. I was presented with errors. image

This changed stopped the errors but I'm not sure it's a valid change.

;(long_flag ["="] @punctuation.special)
;(short_flag ["="] @punctuation.special)

fdncred avatar Nov 18 '24 15:11 fdncred

I think your highlights.scm is the latest while the grammar is not up-to-date.

blindFS avatar Nov 18 '24 15:11 blindFS

TSUpdate nu says "Parsers are up-to-date!"

fdncred avatar Nov 18 '24 15:11 fdncred

TSUpdate nu says "Parsers are up-to-date!"

Yes, because neovim-ts has its own copy of the parser, which is several days behind this repo.

blindFS avatar Nov 18 '24 15:11 blindFS

ah, that makes sense. sorry i'm such a noob on this nvim stuff. trying to get up to speed.

fdncred avatar Nov 18 '24 15:11 fdncred

3 solutions here:

  1. remove tree-sitter-nu completely, use all files hosted by neovim-ts
  2. manually specify to use the local version (which is my config for debugging) here:
    config = function(_, opts)
      local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
      parser_config.nu = {
        install_info = {
          url = "~/.config/nushell/tree-sitter-nu", -- local path or git repo
          files = { "src/parser.c" }, -- note that some parsers also require src/scanner.c or src/scanner.cc
          branch = "pr", -- default branch in case of git repo if different from master
          generate_requires_npm = false, -- if stand-alone parser without npm dependencies
          requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
        },
        filetype = "nu", -- if filetype does not match the parser name
      }
      require("nvim-treesitter.configs").setup(opts)
    end,
  1. simply wait for some days, and they will sync :-).

blindFS avatar Nov 18 '24 16:11 blindFS

ah, that makes sense. sorry i'm such a noob on this nvim stuff. trying to get up to speed.

This nvim-ts config is really confusing, I still don't know how to specify local queries in install_info, and updating the grammar locally is also weird.

And please keep this issue open for others facing the same problem.

blindFS avatar Nov 18 '24 16:11 blindFS

After doing step 2, I still get the error. So, I copied the scm files to nvim-data and things seem to be working fine. Is there a way to tell what version of tree-sitter-nu I'm running?

fdncred avatar Nov 18 '24 17:11 fdncred

@fdncred Sorry for not making it clear, actually these are exclusive solutions, not steps to follow. If you choose method 2, you still need to install tree-sitter-nu (using a plugin manager or as a dependency of nvim-ts) for its latest highlights.scm. Otherwise you're using grammar > highlight.scm, which will also cause similar problems.

And I suppose even after they upgrade the nu parser, method 1 will become problematic since it still use old highlights.scm, I may need to create a PR to nvim-ts for the change.

blindFS avatar Nov 18 '24 23:11 blindFS

ya, i understood that they weren't steps. I did option 2 and got it working after i copied the scm files.

fdncred avatar Nov 19 '24 00:11 fdncred

@fdncred that's weird, if you don't remove tree-sitter-nu, it should work fine (need to update to the latest) without requiring to manually copy the scm files. Manually copying just solves everything though.

blindFS avatar Nov 19 '24 00:11 blindFS