-
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?
Changes from 5 commits
3c7a28d
7dd0bee
a6cb45d
b3a5184
081827e
f767133
3545170
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7704,6 +7704,12 @@ Tree-sitter Query: | |||||||||||||||||||||||||
- tsq | ||||||||||||||||||||||||||
extensions: | ||||||||||||||||||||||||||
- ".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 commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need these as they all share the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||||||||||||||
tm_scope: source.scm | ||||||||||||||||||||||||||
ace_mode: text | ||||||||||||||||||||||||||
language_id: 436081647 | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
; General | ||
(label | ||
[ | ||
(ident) | ||
(word) | ||
] @label) | ||
|
||
(reg) @variable.builtin | ||
|
||
(meta | ||
kind: (_) @function.builtin) | ||
|
||
(instruction | ||
kind: (_) @function.builtin) | ||
|
||
(const | ||
name: (word) @constant) | ||
|
||
; Comments | ||
[ | ||
(line_comment) | ||
(block_comment) | ||
] @comment @spell | ||
|
||
; Literals | ||
(int) @number | ||
|
||
(float) @number.float | ||
|
||
(string) @string | ||
|
||
; Keywords | ||
[ | ||
"byte" | ||
"word" | ||
"dword" | ||
"qword" | ||
"ptr" | ||
"rel" | ||
"label" | ||
"const" | ||
] @keyword | ||
|
||
; Operators & Punctuation | ||
[ | ||
"+" | ||
"-" | ||
"*" | ||
"/" | ||
"%" | ||
"|" | ||
"^" | ||
"&" | ||
] @operator | ||
|
||
[ | ||
"(" | ||
")" | ||
"[" | ||
"]" | ||
] @punctuation.bracket | ||
|
||
[ | ||
"," | ||
":" | ||
] @punctuation.delimiter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
([ | ||
(line_comment) | ||
(block_comment) | ||
] @injection.content | ||
(#set! injection.language "comment")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
; Include | ||
"#include" @keyword.import | ||
|
||
(include_path) @string | ||
|
||
; Preproc | ||
"#pragma" @keyword.directive | ||
|
||
(pragma_directive | ||
[ | ||
"version" | ||
"not-version" | ||
"test-version-set" | ||
] @keyword.directive) | ||
|
||
; Keywords | ||
[ | ||
"asm" | ||
"impure" | ||
"inline" | ||
"inline_ref" | ||
"method_id" | ||
"type" | ||
] @keyword | ||
|
||
"return" @keyword.return | ||
|
||
; Conditionals | ||
[ | ||
"if" | ||
"ifnot" | ||
"else" | ||
"elseif" | ||
"elseifnot" | ||
"until" | ||
] @keyword.conditional | ||
|
||
; Exceptions | ||
[ | ||
"try" | ||
"catch" | ||
] @keyword.exception | ||
|
||
; Repeats | ||
[ | ||
"do" | ||
"forall" | ||
"repeat" | ||
"while" | ||
] @keyword.repeat | ||
|
||
; Qualifiers | ||
[ | ||
"const" | ||
"global" | ||
(var) | ||
] @keyword.modifier | ||
|
||
; Variables | ||
(identifier) @variable | ||
|
||
; Constants | ||
(const_var_declarations | ||
name: (identifier) @constant) | ||
|
||
; Functions/Methods | ||
(function_definition | ||
name: (function_name) @function) | ||
|
||
(function_application | ||
function: (identifier) @function) | ||
|
||
(method_call | ||
method_name: (identifier) @function.method.call) | ||
|
||
; Parameters | ||
(parameter) @variable.parameter | ||
|
||
; Types | ||
(type_identifier) @type | ||
|
||
(primitive_type) @type.builtin | ||
|
||
; Operators | ||
[ | ||
"=" | ||
"+=" | ||
"-=" | ||
"*=" | ||
"/=" | ||
"~/=" | ||
"^/=" | ||
"%=" | ||
"~%=" | ||
"^%=" | ||
"<<=" | ||
">>=" | ||
"~>>=" | ||
"^>>=" | ||
"&=" | ||
"|=" | ||
"^=" | ||
"==" | ||
"<" | ||
">" | ||
"<=" | ||
">=" | ||
"!=" | ||
"<=>" | ||
"<<" | ||
">>" | ||
"~>>" | ||
"^>>" | ||
"-" | ||
"+" | ||
"|" | ||
"^" | ||
"*" | ||
"/" | ||
"%" | ||
"~/" | ||
"^/" | ||
"~%" | ||
"^%" | ||
"/%" | ||
"&" | ||
"~" | ||
] @operator | ||
|
||
; Literals | ||
[ | ||
(string) | ||
(asm_instruction) | ||
] @string | ||
|
||
[ | ||
(string_type) | ||
(underscore) | ||
] @character.special | ||
|
||
(number) @number | ||
|
||
; Punctuation | ||
[ | ||
"{" | ||
"}" | ||
] @punctuation.bracket | ||
|
||
[ | ||
"(" | ||
")" | ||
"()" | ||
] @punctuation.bracket | ||
|
||
[ | ||
"[" | ||
"]" | ||
] @punctuation.bracket | ||
|
||
[ | ||
";" | ||
"," | ||
"->" | ||
] @punctuation.delimiter | ||
|
||
; Comments | ||
(comment) @comment @spell |
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 🤷