-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
base: main
Are you sure you want to change the base?
Conversation
negative_pattern: | ||
- '\([+\-:<>\/=~\)]' | ||
- language: Scheme |
There was a problem hiding this comment.
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 🤷
lib/linguist/languages.yml
Outdated
filenames: | ||
- folds.scm | ||
- highlights.scm | ||
- indents.scm | ||
- injections.scm | ||
- locals.scm |
There was a problem hiding this comment.
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.
filenames: | |
- folds.scm | |
- highlights.scm | |
- indents.scm | |
- injections.scm | |
- locals.scm | |
filenames: | |
- folds.scm | |
- highlights.scm | |
- indents.scm | |
- injections.scm | |
- locals.scm |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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:

Description
Checklist: