Skip to content

Commit

Permalink
Use latest tree-sitter-bicep, support bicepparams (helix-editor#11525)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
  • Loading branch information
2 people authored and rongyi committed Jan 8, 2025
1 parent bfb0657 commit 63a8c9e
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 50 deletions.
4 changes: 2 additions & 2 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,7 @@ source = { git = "https://github.com/inko-lang/tree-sitter-inko", rev = "7860637
[[language]]
name = "bicep"
scope = "source.bicep"
file-types = ["bicep"]
file-types = ["bicep","bicepparam"]
auto-format = true
comment-token = "//"
block-comment-tokens = { start = "/*", end = "*/" }
Expand All @@ -2820,7 +2820,7 @@ language-servers = [ "bicep-langserver" ]

[[grammar]]
name = "bicep"
source = { git = "https://github.com/the-mikedavis/tree-sitter-bicep", rev = "d8e097fcfa143854861ef737161163a09cc2916b" }
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-bicep", rev = "0092c7d1bd6bb22ce0a6f78497d50ea2b87f19c0" }

[[language]]
name = "qml"
Expand Down
255 changes: 207 additions & 48 deletions runtime/queries/bicep/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,73 +1,232 @@
; Keywords
; Includes
[
"import"
"provider"
"with"
"as"
"from"
] @keyword.control.import

; Namespaces
(module_declaration
(identifier) @namespace)

; Builtins
(primitive_type) @type.builtin

((member_expression
object: (identifier) @type.builtin)
(#eq? @type.builtin "sys"))

; Functions
(call_expression
function: (identifier) @function)

(user_defined_function
name: (identifier) @function)

; Properties
(object_property
(identifier) @function.method
":" @punctuation.delimiter
(_))

(object_property
(compatible_identifier) @function.method
":" @punctuation.delimiter
(_))

(property_identifier) @function.method

; Attributes
(decorator
"@" @attribute)

(decorator
(call_expression
(identifier) @attribute))

(decorator
(call_expression
(member_expression
object: (identifier) @attribute
property: (property_identifier) @attribute)))

; Types
(type_declaration
(identifier) @type)

(type_declaration
(identifier)
"="
(identifier) @type)

(type
(identifier) @type)

(resource_declaration
(identifier) @type)

(resource_expression
(identifier) @type)

; Parameters
(parameter_declaration
(identifier) @variable.parameter
(_))

(call_expression
function: (_)
(arguments
(identifier) @variable.parameter))

(call_expression
function: (_)
(arguments
(member_expression
object: (identifier) @variable.parameter)))

(parameter
.
(identifier) @variable.parameter)

; Variables
(variable_declaration
(identifier) @variable
(_))

(metadata_declaration
(identifier) @variable
(_))

(output_declaration
(identifier) @variable
(_))

(object_property
(_)
":"
(identifier) @variable)

(for_statement
"for"
(for_loop_parameters
(loop_variable) @variable
(loop_enumerator) @variable))

; Conditionals
"if" @keyword.conditional

(ternary_expression
"?" @keyword.control.conditional
":" @keyword.control.conditional)

; Loops
(for_statement
"for" @keyword.control.repeat
"in"
":" @punctuation.delimiter)

; Keywords
[
"module"
"var"
"metadata"
"output"
"param"
"import"
"resource"
"existing"
"if"
"targetScope"
"output"
"type"
"var"
"using"
"test"
] @keyword

; Functions
"func" @keyword.function

(decorator) @function.builtin
"assert" @keyword.control.exception

(functionCall) @function
; Operators
[
"+"
"-"
"*"
"/"
"%"
"||"
"&&"
"|"
"=="
"!="
"=~"
"!~"
">"
">="
"<="
"<"
"??"
"="
"!"
".?"
] @operator

(functionCall
(functionArgument
(variableAccess) @variable))
(subscript_expression
"?" @operator)

; Literals/Types
(nullable_type
"?" @operator)

[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
"in" @keyword.operator

(resourceDeclaration
(string
(stringLiteral) @string.special))
; Literals
(string) @string

(moduleDeclaration
(string
(stringLiteral) @string.special))
(escape_sequence) @constant.character

[
(string)
(stringLiteral)
] @string
(number) @constant.number

(nullLiteral) @keyword
(booleanLiteral) @constant.builtin.boolean
(integerLiteral) @constant.numeric.integer
(comment) @comment
(boolean) @constant.builtin.boolean

(string
(variableAccess
(identifier) @variable))
(null) @constant.builtin

(type) @type
; Misc
(compatible_identifier
"?" @punctuation.special)

; Variables
(nullable_return_type) @punctuation.special

[
"{"
"}"
] @punctuation.bracket

(localVariable) @variable
[
"["
"]"
] @punctuation.bracket

; Statements
[
"("
")"
] @punctuation.bracket

(object
(objectProperty
(identifier) @identifier))
[
"."
":"
"::"
"=>"
] @punctuation.delimiter

(propertyAccess
(identifier) @identifier)

(ifCondition) @keyword.control.conditional
; Interpolation
(interpolation
"${" @punctuation.special
"}" @punctuation.special)

(interpolation
(identifier) @variable)

; Comments
[
(comment)
(diagnostic_comment)
] @comment

0 comments on commit 63a8c9e

Please sign in to comment.