mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-02 02:17:44 +03:00
chore: Point OpenSCAD grammar to official repo (#13033)
This commit is contained in:
parent
d1e0891260
commit
430ce9c46b
2 changed files with 128 additions and 28 deletions
|
@ -2414,7 +2414,7 @@ indent = { tab-width = 2, unit = "\t" }
|
|||
|
||||
[[grammar]]
|
||||
name = "openscad"
|
||||
source = { git = "https://github.com/bollian/tree-sitter-openscad", rev = "5c3ce93df0ac1da7197cf6ae125aade26d6b8972" }
|
||||
source = { git = "https://github.com/openscad/tree-sitter-openscad", rev = "acc196e969a169cadd8b7f8d9f81ff2d30e3e253" }
|
||||
|
||||
[[language]]
|
||||
name = "prisma"
|
||||
|
|
|
@ -1,40 +1,68 @@
|
|||
(number) @constant.numeric
|
||||
(string) @string
|
||||
(boolean) @constant.builtin.boolean
|
||||
(include_path) @string.special.path
|
||||
|
||||
; Includes
|
||||
(identifier) @variable
|
||||
|
||||
(parameters_declaration (identifier) @variable.parameter)
|
||||
(function_declaration name: (identifier) @function)
|
||||
"include" @keyword.control.import
|
||||
|
||||
(function_call function: (identifier) @function)
|
||||
(module_call name: (identifier) @function)
|
||||
(include_path) @string.special.path
|
||||
|
||||
; Functions
|
||||
|
||||
(function_item
|
||||
(identifier) @function
|
||||
)
|
||||
(function_item
|
||||
parameters: (parameters (parameter (assignment value: (_) @constant)))
|
||||
)
|
||||
(function_call name: (identifier) @function)
|
||||
(function_call
|
||||
arguments: (arguments (assignment name: _ @variable.parameter))
|
||||
)
|
||||
; for the puroposes of distintion since modules are "coloured" impure functions, we will treat them as methods
|
||||
(module_item (identifier) @function.method)
|
||||
(module_item
|
||||
parameters: (parameters (parameter (assignment value: (_) @constant)))
|
||||
)
|
||||
(module_call name: (identifier) @function.method)
|
||||
(module_call
|
||||
arguments: (arguments (assignment name: _ @variable.parameter))
|
||||
)
|
||||
|
||||
; assertion statements/expression arguments behave similar to function calls
|
||||
(assert_expression
|
||||
arguments: (arguments (assignment name: _ @variable.parameter))
|
||||
)
|
||||
(assert_statement
|
||||
arguments: (arguments (assignment name: _ @variable.parameter))
|
||||
)
|
||||
|
||||
(echo_expression
|
||||
arguments: (arguments (assignment name: _ @variable.parameter))
|
||||
)
|
||||
(echo_expression "echo" @function.builtin)
|
||||
|
||||
; Variables
|
||||
(parameter
|
||||
[_ @variable.parameter (assignment name: _ @variable.parameter)]
|
||||
)
|
||||
(special_variable) @variable.builtin
|
||||
(undef) @constant.builtin
|
||||
|
||||
; Types/Properties/
|
||||
(dot_index_expression index: (_) @variable.other.member)
|
||||
|
||||
; Keywords
|
||||
[
|
||||
"module"
|
||||
"function"
|
||||
"let"
|
||||
"assign"
|
||||
"use"
|
||||
"each"
|
||||
(assert_statement "assert")
|
||||
(assert_expression "assert")
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"for"
|
||||
"each"
|
||||
"intersection_for"
|
||||
] @keyword.control.repeat
|
||||
|
||||
[
|
||||
"if"
|
||||
] @keyword.control.conditional
|
||||
|
||||
[
|
||||
"module"
|
||||
"use"
|
||||
"include"
|
||||
] @keyword.control.import
|
||||
|
||||
; Operators
|
||||
[
|
||||
"||"
|
||||
"&&"
|
||||
|
@ -50,15 +78,87 @@
|
|||
"/"
|
||||
"%"
|
||||
"^"
|
||||
"?"
|
||||
"!"
|
||||
":"
|
||||
"="
|
||||
] @operator
|
||||
|
||||
; Builtin modules
|
||||
(module_call
|
||||
name: (identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"circle"
|
||||
"color"
|
||||
"cube"
|
||||
"cylinder"
|
||||
"difference"
|
||||
"hull"
|
||||
"intersection"
|
||||
"linear_extrude"
|
||||
"minkowski"
|
||||
"mirror"
|
||||
"multmatrix"
|
||||
"offset"
|
||||
"polygon"
|
||||
"polyhedron"
|
||||
"projection"
|
||||
"resize"
|
||||
"rotate"
|
||||
"rotate_extrude"
|
||||
"scale"
|
||||
"sphere"
|
||||
"square"
|
||||
"surface"
|
||||
"text"
|
||||
"translate"
|
||||
"union"
|
||||
"echo"
|
||||
)
|
||||
)
|
||||
(
|
||||
(identifier) @identifier
|
||||
(#eq? @identifier "PI")
|
||||
) @constant.builtin
|
||||
|
||||
; Conditionals
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
] @keyword.control.conditional
|
||||
(ternary_expression
|
||||
["?" ":"] @keyword.control.conditional
|
||||
)
|
||||
|
||||
; Repeats
|
||||
[
|
||||
"for"
|
||||
"intersection_for"
|
||||
] @keyword.control.repeat
|
||||
|
||||
; Literals
|
||||
(integer) @constant.numeric.integer
|
||||
(float) @constant.numeric.float
|
||||
(string) @string
|
||||
(escape_sequence) @constant.character.escape
|
||||
(boolean) @constant.builtin.boolean
|
||||
|
||||
; Misc
|
||||
(modifier
|
||||
[
|
||||
"*"
|
||||
"!"
|
||||
"#"
|
||||
"%"
|
||||
] @keyword.storage.modifier
|
||||
)
|
||||
["{" "}"] @punctuation.bracket
|
||||
["(" ")"] @punctuation.bracket
|
||||
["[" "]"] @punctuation.bracket
|
||||
[
|
||||
";"
|
||||
","
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
(comment) @comment
|
||||
; Comments
|
||||
[(line_comment) (block_comment)] @comment
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue