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

highlights.scm errors #145

Open
fdncred opened this issue Nov 18, 2024 · 10 comments
Open

highlights.scm errors #145

fdncred opened this issue Nov 18, 2024 · 10 comments

Comments

@fdncred
Copy link
Collaborator

fdncred commented Nov 18, 2024

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)
@blindFS
Copy link
Contributor

blindFS commented Nov 18, 2024

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

@fdncred
Copy link
Collaborator Author

fdncred commented Nov 18, 2024

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

@blindFS
Copy link
Contributor

blindFS commented Nov 18, 2024

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.

@fdncred
Copy link
Collaborator Author

fdncred commented Nov 18, 2024

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

@blindFS
Copy link
Contributor

blindFS commented Nov 18, 2024

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
Copy link
Contributor

blindFS commented Nov 18, 2024

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.

@fdncred
Copy link
Collaborator Author

fdncred commented Nov 18, 2024

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?

@blindFS
Copy link
Contributor

blindFS commented Nov 18, 2024

@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.

@fdncred
Copy link
Collaborator Author

fdncred commented Nov 19, 2024

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

@blindFS
Copy link
Contributor

blindFS commented Nov 19, 2024

@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.

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

2 participants