-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump the git revision and use the queries from <https://github.com/IndianBoy42/tree-sitter-just/tree/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix> to update Helix's sources.
- Loading branch information
Showing
7 changed files
with
290 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
(body) @fold | ||
(recipe) @fold | ||
(interpolation) @fold | ||
(item (_) @fold) | ||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix/folds.scm> | ||
; | ||
; Define collapse points | ||
|
||
[ | ||
(recipe) | ||
(string) | ||
(external_command) | ||
] @fold | ||
(#trim! @fold) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,149 @@ | ||
(assignment (NAME) @variable) | ||
(alias (NAME) @variable) | ||
(value (NAME) @variable) | ||
(parameter (NAME) @variable) | ||
(setting (NAME) @keyword) | ||
(setting "shell" @keyword) | ||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix/highlights.scm> | ||
; | ||
; This file specifies how matched syntax patterns should be highlighted | ||
|
||
(call (NAME) @function) | ||
(dependency (NAME) @function) | ||
(depcall (NAME) @function) | ||
(recipeheader (NAME) @function) | ||
[ | ||
"export" | ||
"import" | ||
] @keyword.control.import | ||
|
||
(depcall (expression) @variable.parameter) | ||
(parameter) @variable.parameter | ||
(variadic_parameters) @variable.parameter | ||
"mod" @keyword.directive | ||
|
||
["if" "else"] @keyword.control.conditional | ||
[ | ||
"alias" | ||
"set" | ||
"shell" | ||
] @keyword | ||
|
||
(string) @string | ||
[ | ||
"if" | ||
"else" | ||
] @keyword.control.conditional | ||
|
||
(boolean ["true" "false"]) @constant.builtin.boolean | ||
; Variables | ||
|
||
(comment) @comment | ||
(value | ||
(identifier) @variable) | ||
|
||
; (interpolation) @string | ||
(alias | ||
left: (identifier) @variable) | ||
|
||
(shebang interpreter:(TEXT) @keyword ) @comment | ||
(assignment | ||
left: (identifier) @variable) | ||
|
||
["export" "alias" "set"] @keyword | ||
; Functions | ||
|
||
["@" "==" "!=" "+" ":="] @operator | ||
(recipe_header | ||
name: (identifier) @function) | ||
|
||
[ "(" ")" "[" "]" "{{" "}}" "{" "}"] @punctuation.bracket | ||
(dependency | ||
name: (identifier) @function) | ||
|
||
(dependency_expression | ||
name: (identifier) @function) | ||
|
||
(function_call | ||
name: (identifier) @function) | ||
|
||
; Parameters | ||
|
||
(parameter | ||
name: (identifier) @variable.parameter) | ||
|
||
; Namespaces | ||
|
||
(module | ||
name: (identifier) @namespace) | ||
|
||
; Operators | ||
|
||
[ | ||
":=" | ||
"?" | ||
"==" | ||
"!=" | ||
"=~" | ||
"@" | ||
"=" | ||
"$" | ||
"*" | ||
"+" | ||
"&&" | ||
"@-" | ||
"-@" | ||
"-" | ||
"/" | ||
":" | ||
] @operator | ||
|
||
; Punctuation | ||
|
||
"," @punctuation.delimiter | ||
|
||
[ | ||
"{" | ||
"}" | ||
"[" | ||
"]" | ||
"(" | ||
")" | ||
"{{" | ||
"}}" | ||
] @punctuation.bracket | ||
|
||
[ "`" "```" ] @punctuation.special | ||
|
||
; Literals | ||
|
||
(boolean) @constant.builtin.boolean | ||
|
||
[ | ||
(string) | ||
(external_command) | ||
] @string | ||
|
||
(escape_sequence) @constant.character.escape | ||
|
||
; Comments | ||
|
||
(comment) @comment.line | ||
|
||
(shebang) @keyword.directive | ||
|
||
; highlight known settings (filtering does not always work) | ||
(setting | ||
left: (identifier) @keyword | ||
(#any-of? @keyword | ||
"allow-duplicate-recipes" | ||
"dotenv-filename" | ||
"dotenv-load" | ||
"dotenv-path" | ||
"export" | ||
"fallback" | ||
"ignore-comments" | ||
"positional-arguments" | ||
"shell" | ||
"tempdi" | ||
"windows-powershell" | ||
"windows-shell")) | ||
|
||
; highlight known attributes (filtering does not always work) | ||
(attribute | ||
(identifier) @attribute | ||
(#any-of? @attribute | ||
"private" | ||
"allow-duplicate-recipes" | ||
"dotenv-filename" | ||
"dotenv-load" | ||
"dotenv-path" | ||
"export" | ||
"fallback" | ||
"ignore-comments" | ||
"positional-arguments" | ||
"shell" | ||
"tempdi" | ||
"windows-powershell" | ||
"windows-shell")) | ||
|
||
; Numbers are part of the syntax tree, even if disallowed | ||
(numeric_error) @error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix/indents.scm> | ||
; | ||
; This query specifies how to auto-indent logical blocks. | ||
; | ||
; Better documentation with diagrams is in https://docs.helix-editor.com/guides/indent.html | ||
|
||
[ | ||
(recipe_body) | ||
] @indent | ||
(recipe) | ||
(string) | ||
(external_command) | ||
] @indent @extend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,80 @@ | ||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix/injections.scm> | ||
; | ||
; Specify nested languages that live within a `justfile` | ||
|
||
; ================ Always applicable ================ | ||
|
||
((comment) @injection.content | ||
(#set! injection.language "comment")) | ||
(#set! injection.language "comment")) | ||
|
||
; Highlight the RHS of `=~` as regex | ||
((regex_literal | ||
(_) @injection.content) | ||
(#set! injection.language "regex")) | ||
|
||
; ================ Recipe language specified - Helix only ================ | ||
|
||
; Set highlighting for recipes that specify a language using builtin shebang matching | ||
(recipe_body | ||
(shebang) @injection.shebang | ||
(#set! injection.include-children)) @injection.content | ||
|
||
; ================ Global language specified ================ | ||
; Global language is set with something like one of the following: | ||
; | ||
; set shell := ["bash", "-c", ...] | ||
; set shell := ["pwsh.exe"] | ||
; | ||
; We can extract the first item of the array, but we can't extract the language | ||
; name from the string with something like regex. So instead we special case | ||
; two things: powershell, which is likely to come with a `.exe` attachment that | ||
; we need to strip, and everything else which hopefully has no extension. We | ||
; separate this with a `#match?`. | ||
; | ||
; Unfortunately, there also isn't a way to allow arbitrary nesting or | ||
; alternatively set "global" capture variables. So we can set this for item- | ||
; level external commands, but not for e.g. external commands within an | ||
; expression without getting _really_ annoying. Should at least look fine since | ||
; they default to bash. Limitations... | ||
; See https://github.com/tree-sitter/tree-sitter/issues/880 for more on that. | ||
|
||
(source_file | ||
(setting "shell" ":=" "[" (string) @_langstr | ||
(#match? @_langstr ".*(powershell|pwsh|cmd).*") | ||
(#set! injection.language "powershell")) | ||
[ | ||
(recipe | ||
(recipe_body (#set! injection.include-children)) @injection.content) | ||
|
||
(assignment | ||
(expression | ||
(value | ||
(external_command | ||
(command_body) @injection.content)))) | ||
]) | ||
|
||
(source_file | ||
(setting "shell" ":=" "[" (string) @injection.language | ||
(#not-match? @injection.language ".*(powershell|pwsh|cmd).*")) | ||
[ | ||
(recipe | ||
(recipe_body | ||
(#set! injection.include-children)) @injection.content) | ||
|
||
(assignment | ||
(expression | ||
(value | ||
(external_command | ||
(command_body) @injection.content)))) | ||
]) | ||
|
||
(shebang_recipe | ||
(shebang | ||
interpreter:(TEXT) @injection.language) | ||
(shebang_body) @injection.content | ||
) | ||
; ================ Global defaults ================ | ||
|
||
(source_file | ||
(item (setting lang:(NAME) @injection.language)) | ||
(item (recipe (body (recipe_body) @injection.content))) | ||
) | ||
; Default everything to be bash | ||
(recipe_body | ||
(#set! injection.language "bash") | ||
(#set! injection.include-children)) @injection.content | ||
|
||
; ((interpolation (expression) @injection.content) | ||
; (#set! injection.language "just")) | ||
(external_command | ||
(command_body) @injection.content | ||
(#set! injection.language "bash")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
(assignment (NAME) @local.definition) | ||
(alias left:(NAME) @local.definition) | ||
(alias right:(NAME) @local.reference) | ||
(value (NAME) @local.reference) | ||
(parameter (NAME) @local.definition) | ||
|
||
(call (NAME) @local.reference) | ||
(dependency (NAME) @local.reference) | ||
(depcall (NAME) @local.reference) | ||
(recipeheader (NAME) @local.definition) | ||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/80d612d198b8d6207416225c9fcea0fe86ffb96e/queries-flavored/helix/locals.scm> | ||
; | ||
; This file tells us about the scope of variables so e.g. local | ||
; variables override global functions with the same name | ||
|
||
; Scope | ||
|
||
(recipe) @local.scope | ||
|
||
; Definitions | ||
|
||
(alias | ||
left: (identifier) @local.definition.variable) | ||
|
||
(assignment | ||
left: (identifier) @local.definition.variable) | ||
|
||
(module | ||
name: (identifier) @local.definition.namespace) | ||
|
||
(parameter | ||
name: (identifier) @local.definition.variable) | ||
|
||
(recipe_header | ||
name: (identifier) @local.definition.function) | ||
|
||
; References | ||
|
||
(alias | ||
right: (identifier) @local.reference) | ||
|
||
(function_call | ||
name: (identifier) @local.reference) | ||
|
||
(dependency | ||
name: (identifier) @local.reference) | ||
|
||
(dependency_expression | ||
name: (identifier) @local.reference) | ||
|
||
(value | ||
(identifier) @local.reference) |
Oops, something went wrong.