Skip to content

Tweaked tree-sitter query classification #7431

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Jun 7, 2025

Updated Tree-sitter Query filename detection and heuristics such that all previously classified as Scheme languages are now properly identified as Tree-sitter Query in https://github.com/nvim-treesitter/nvim-treesitter:
image

Description

Checklist:

@mkatychev mkatychev requested a review from a team as a code owner June 7, 2025 00:45
negative_pattern:
- '\([+\-:<>\/=~\)]'
- language: Scheme
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving TSQ above Scheme somehow increased classification hit-rate 🤷

Comment on lines 7707 to 7712
filenames:
- folds.scm
- highlights.scm
- indents.scm
- injections.scm
- locals.scm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need these as they all share the .scm extension which should be sufficient.

Suggested change
filenames:
- folds.scm
- highlights.scm
- indents.scm
- injections.scm
- locals.scm
filenames:
- folds.scm
- highlights.scm
- indents.scm
- injections.scm
- locals.scm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it out, it seems those lines change classification, before deletion for nvim-tresitter:

$ ./bin/github-linguist $doc/nvim-treesitter | rg '(Tree-sitter|Scheme)'
69.59%  1128396    Tree-sitter Query

After deleting those lines:

$ ./bin/github-linguist $doc/nvim-treesitter | rg '(Tree-sitter|Scheme)'
69.52%  1127317    Tree-sitter Query
0.07%   1079       Scheme

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would then indicate the heuristics are missing a scenario specifically in your repo or the samples are not sufficiently teaching the classifier. Keep in mind we’re aiming for good enough, not perfection as every repo is different. It’s also why we have overrides.

The use of specific files is for cases where a specific filename is always used by that language, and generally doesn’t have an extension or has a generic or very common extension associated with another language. Using a filename will mean every instance of that filename will be classified as that language, even if the file is legitimately written in another language. So if a Scala developer creates a file called locals.scm, they’ll be forced to use an override because you decided all files with this name should be Tree-sitter query.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, the changed turned out to be a rather small tweak.

@mkatychev mkatychev requested a review from lildude June 17, 2025 15:22
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

Successfully merging this pull request may close these issues.

2 participants