mirror of
https://github.com/helix-editor/helix.git
synced 2024-09-11 18:58:00 +03:00
just: Use updated grammar with recent language changes and correct highlighting (#11380)
This commit is contained in:
parent
8851031449
commit
68f495b023
@ -3105,7 +3105,7 @@ indent = { tab-width = 4, unit = " " }
|
||||
|
||||
[[grammar]]
|
||||
name = "just"
|
||||
source = { git = "https://github.com/IndianBoy42/tree-sitter-just", rev = "379fbe36d1e441bc9414ea050ad0c85c9d6935ea" }
|
||||
source = { git = "https://github.com/poliorcetics/tree-sitter-just", rev = "f58a8fd869035ac4653081401e6c2030251240ab" }
|
||||
|
||||
[[language]]
|
||||
name = "gn"
|
||||
|
@ -1,5 +1,3 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/queries-flavored/helix/folds.scm>
|
||||
|
||||
; Define collapse points
|
||||
|
||||
([
|
||||
|
@ -1,5 +1,3 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/queries-flavored/helix/highlights.scm>
|
||||
|
||||
; This file specifies how matched syntax patterns should be highlighted
|
||||
|
||||
[
|
||||
@ -26,35 +24,57 @@
|
||||
(identifier) @variable)
|
||||
|
||||
(alias
|
||||
left: (identifier) @variable)
|
||||
name: (identifier) @variable)
|
||||
|
||||
(assignment
|
||||
left: (identifier) @variable)
|
||||
name: (identifier) @variable)
|
||||
|
||||
(shell_variable_name) @variable
|
||||
|
||||
; Functions
|
||||
|
||||
(recipe_header
|
||||
(recipe
|
||||
name: (identifier) @function)
|
||||
|
||||
(dependency
|
||||
name: (identifier) @function)
|
||||
|
||||
(dependency_expression
|
||||
name: (identifier) @function)
|
||||
(recipe_dependency
|
||||
name: (identifier) @function.call)
|
||||
|
||||
(function_call
|
||||
name: (identifier) @function)
|
||||
name: (identifier) @function.builtin)
|
||||
|
||||
; Parameters
|
||||
|
||||
(parameter
|
||||
(recipe_parameter
|
||||
name: (identifier) @variable.parameter)
|
||||
|
||||
; Namespaces
|
||||
|
||||
(module
|
||||
(mod
|
||||
name: (identifier) @namespace)
|
||||
|
||||
; Paths
|
||||
|
||||
(mod
|
||||
(path) @string.special.path)
|
||||
|
||||
(import
|
||||
(path) @string.special.path)
|
||||
|
||||
; Shebangs
|
||||
|
||||
(shebang_line) @keyword.directive
|
||||
(shebang_line
|
||||
(shebang_shell) @string.special)
|
||||
|
||||
|
||||
(shell_expanded_string
|
||||
[
|
||||
(expansion_short_start)
|
||||
(expansion_long_start)
|
||||
(expansion_long_middle)
|
||||
(expansion_long_end)
|
||||
] @punctuation.special)
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
@ -95,55 +115,31 @@
|
||||
|
||||
; Literals
|
||||
|
||||
(boolean) @constant.builtin.boolean
|
||||
; Booleans are not allowed anywhere except in settings
|
||||
(setting
|
||||
(boolean) @constant.builtin.boolean)
|
||||
|
||||
[
|
||||
(string)
|
||||
(external_command)
|
||||
] @string
|
||||
|
||||
(escape_sequence) @constant.character.escape
|
||||
[
|
||||
(escape_sequence)
|
||||
(escape_variable_end)
|
||||
] @constant.character.escape
|
||||
|
||||
; Comments
|
||||
|
||||
(comment) @comment.line
|
||||
|
||||
(shebang) @keyword.directive
|
||||
|
||||
; highlight known settings (filtering does not always work)
|
||||
; highlight known settings
|
||||
(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"))
|
||||
name: (_) @keyword.function)
|
||||
|
||||
; highlight known attributes (filtering does not always work)
|
||||
; highlight known attributes
|
||||
(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"))
|
||||
name: (identifier) @attribute)
|
||||
|
||||
; Numbers are part of the syntax tree, even if disallowed
|
||||
(numeric_error) @error
|
||||
|
@ -1,5 +1,3 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/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
|
||||
|
@ -1,5 +1,3 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/queries-flavored/helix/injections.scm>
|
||||
;
|
||||
; Specify nested languages that live within a `justfile`
|
||||
|
||||
; ================ Always applicable ================
|
||||
@ -8,7 +6,7 @@
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; Highlight the RHS of `=~` as regex
|
||||
((regex_literal
|
||||
((regex
|
||||
(_) @injection.content)
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
@ -21,7 +19,7 @@
|
||||
(#set! injection.include-children)) @injection.content
|
||||
|
||||
(external_command
|
||||
(command_body) @injection.content
|
||||
(content) @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
; ================ Global language specified ================
|
||||
@ -43,7 +41,7 @@
|
||||
; they default to bash. Limitations...
|
||||
; See https://github.com/tree-sitter/tree-sitter/issues/880 for more on that.
|
||||
|
||||
(source_file
|
||||
(file
|
||||
(setting "shell" ":=" "[" (string) @_langstr
|
||||
(#match? @_langstr ".*(powershell|pwsh|cmd).*")
|
||||
(#set! injection.language "powershell"))
|
||||
@ -57,10 +55,10 @@
|
||||
(expression
|
||||
(value
|
||||
(external_command
|
||||
(command_body) @injection.content))))
|
||||
(content) @injection.content))))
|
||||
])
|
||||
|
||||
(source_file
|
||||
(file
|
||||
(setting "shell" ":=" "[" (string) @injection.language
|
||||
(#not-match? @injection.language ".*(powershell|pwsh|cmd).*"))
|
||||
[
|
||||
@ -73,12 +71,12 @@
|
||||
(expression
|
||||
(value
|
||||
(external_command
|
||||
(command_body) @injection.content))))
|
||||
(content) @injection.content))))
|
||||
])
|
||||
|
||||
; ================ Recipe language specified - Helix only ================
|
||||
|
||||
; Set highlighting for recipes that specify a language using builtin shebang matching
|
||||
(recipe_body
|
||||
(shebang) @injection.shebang
|
||||
(shebang_line) @injection.shebang
|
||||
(#set! injection.include-children)) @injection.content
|
||||
|
@ -1,5 +1,3 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/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
|
||||
|
||||
@ -10,32 +8,29 @@
|
||||
; Definitions
|
||||
|
||||
(alias
|
||||
left: (identifier) @local.definition)
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(assignment
|
||||
left: (identifier) @local.definition)
|
||||
|
||||
(module
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(parameter
|
||||
(mod
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(recipe_header
|
||||
(recipe_parameter
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(recipe
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
; References
|
||||
|
||||
(alias
|
||||
right: (identifier) @local.reference)
|
||||
name: (identifier) @local.reference)
|
||||
|
||||
(function_call
|
||||
name: (identifier) @local.reference)
|
||||
|
||||
(dependency
|
||||
name: (identifier) @local.reference)
|
||||
|
||||
(dependency_expression
|
||||
(recipe_dependency
|
||||
name: (identifier) @local.reference)
|
||||
|
||||
(value
|
||||
|
@ -1,18 +1,19 @@
|
||||
; From <https://github.com/IndianBoy42/tree-sitter-just/blob/6c2f018ab1d90946c0ce029bb2f7d57f56895dff/queries-flavored/helix/textobjects.scm>
|
||||
;
|
||||
; Specify how to navigate around logical blocks in code
|
||||
|
||||
(assert_parameters
|
||||
((_) @parameter.inside . ","? @parameter.around)) @parameter.around
|
||||
|
||||
(recipe
|
||||
(recipe_body) @function.inside) @function.around
|
||||
|
||||
(parameters
|
||||
(recipe_parameters
|
||||
((_) @parameter.inside . ","? @parameter.around)) @parameter.around
|
||||
|
||||
(dependency_expression
|
||||
(recipe_dependency
|
||||
(_) @parameter.inside) @parameter.around
|
||||
|
||||
(function_call
|
||||
arguments: (sequence
|
||||
(expression) @parameter.inside) @parameter.around) @function.around
|
||||
(function_parameters
|
||||
((_) @parameter.inside . ","? @parameter.around)) @parameter.around) @function.around
|
||||
|
||||
(comment) @comment.around
|
||||
|
Loading…
Reference in New Issue
Block a user