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

Highlighting doesn't work out of the box #3

Open
Philogy opened this issue Oct 26, 2023 · 1 comment
Open

Highlighting doesn't work out of the box #3

Philogy opened this issue Oct 26, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Philogy
Copy link

Philogy commented Oct 26, 2023

Hey, I've opened an issue previously which you've kindly resolved with #2, the tree-sitter parser is now installed with no problems, however, there's two follow-up issues:

  1. .nr files aren't detected as "noir" files by neovim out-of-the-box, I'd recommend adding the tip "add vim.filetype.add({ extension = { nr = 'noir' } }) in your config to have noir detected
  2. More importantly I can't seem to get the highlighting to actually work, when I open up a .nr file it doesn't show any highlighting on its own, am I missing something (after I got Neovim to recognize .nr files as noir)? Here's my treesitter config file:
local status, ts = pcall(require, 'nvim-treesitter.configs')
if (not status) then print('no tree') return end

local parser_config = require 'nvim-treesitter.parsers'.get_parser_configs()

parser_config.noir = {
  install_info = {
    url = "https://github.com/hhamud/tree-sitter-noir", -- the url for this tree-sitter grammar
    files = { "src/parser.c", "src/scanner.c" },
    branch = "main",
  },
  filetype = "noir",
}

ts.setup {
  highlight = {
    enable = true
  },
  indent = {
    enable = true,
    disable = { "python" }
  },
  ensure_installed = {
    'javascript',
    'tsx',
    'json',
    'css',
    'toml',
    'solidity',
    'python',
    'beancount',
    'rust',
    'noir'
  }
}

Thanks again! 🙏

@hhamud hhamud self-assigned this Oct 26, 2023
@hhamud hhamud added the bug Something isn't working label Oct 26, 2023
@hhamud
Copy link
Owner

hhamud commented Oct 27, 2023

I ended up missing this part. I assumed that nvim-treesitter would have been able to detect the queries from the package itself but turns out you would need to copy it over.

Thanks for the find on the filetype as well.

Note that neither :TSInstall nor :TSInstallFromGrammar copy query files from the grammar repository. If you want your installed grammar to be useful, you must manually add query files to your local nvim-treesitter installation. Note also that module functionality is only triggered if your language's filetype is correctly identified. If Neovim does not detect your language's filetype by default, you can use Neovim's vim.filetype.add() to add a custom detection rule.

If you use a git repository for your parser and want to use a specific version, you can set the revision key in the install_info table for you parser config.

Could you try copying over the queries from queries/highlights.scm in the tree-sitter-noir package and seeing what it outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants