cbarrete / tree-sitter-ledger

Ledger grammar for tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't get latest parser...

boydkelly opened this issue · comments

I was researching how I can get red negative numbers and coming here I find that its done! However no matter what I do within nvim-treesitter it won't grab the hightlight query I see in this repo.

I found the highlighs.scm file under share/lazy/nvim-treesitter/queries/ledger

But doing a TSUpdate ledger seems only to rebuild the parser. If I remove the queries directory then a TSInstall ledger wll not update/replace it.

OK I took out the hatchet and nuked the entire treesiter plugin.

But when it reinstalles ledger i still have the "old" query containing:

[
    (quantity)
    (negative_quantity)
] @number

Lazy of course installs the treesitter package but does not have anything that I can see related to treesitter parsers.
Is this something between you and treesitter?

Thanks a lot for this work for leger/hledger.

Yeah just an addendum here. It is that the scm files belong to nvim-treesitter. Is there some mechanism to get this updated?

 toolbox …/nvim-treesitter/queries/ledger master   38% | 4%  ❯ git remote -v
origin	https://github.com/nvim-treesitter/nvim-treesitter.git (fetch) [blob:none]
origin	https://github.com/nvim-treesitter/nvim-treesitter.git (push)

 toolbox …/nvim-treesitter/queries/ledger master   38% | 4%  ❯ git ls-files
folds.scm
highlights.scm
indents.scm
injections.scm

Hi, as you've noted, the query files that are actually used live in nvim-treesitter. Highlight queries are editor-specific, as discussed here.

I only provide queries here for reference, sort of as clues for maintainers of the integrations (nvim-treesitter, the emacs equivalent, helix, etc.). I also typically update the ones in nvim-treesitter, which end up being the same as in this repo, which can be confusing.

Since nvim-treesitter/nvim-treesitter#4697, the query files are actually different (you can read about the reasoning in the PR), but you can use the queries in this repo as a starting point for your own config, e.g. to get special highlighting for negative quantities. I'm sure there's some documentation somewhere in nvim-treesitter for how to extend/override queries, I've never done it myself.

Let me know if I can provide further clarification. In the meantime, I'll update the README to hopefully make all of this a little more obvious.

Thanks for the clear explanation. Yes I have already figured out how to override/extend the queries in nvim. just add a queries/lang/ direatory anywhere in the runtime path and it will pick them up. But I can sure see that maybe its a general architecture improvement that needs to be made by nvim-treesitter. (does vcode and others have the same issue?) There are constantly updates to various treesitter parsers. And it is kinda logical to think if the parsers are being updated they are getting updated with the latest higlighting (and other) fixes. But I see thats not the case. Now I know....

I fully agree.

I believe that other editors have the same issues, but I don't know much about the specifics.

It seems that the TS community (i.e. tree-sitter, nvim-treesitter, helix and I think some people from Emacs) are trying to harmonize the queries so that they can eventually be upstreamed and/or versioned, which would solve the issue that you're describing. If/when that happens, I'll move the queries back into tree-sitter-ledger and we'll be in a much better place, both for users and contributors.