-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved from zed-industries/zed#22293. - Fixes various issues with current syntax highlighting: modules and patterns are not highlighted, number literals are treated as constants etc. New highlights are mostly copied from [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/elm/highlights.scm) with some modifications and removals of things that are not supported by Zed. In particular, `@modules` are highlighted as `@title`, similarly to how it's done in Zed's Haskell extension. - Added `brackets.scm`. - Changed the default tab_size to 4 as that's how most of Elm projects are formatted and what elm-format uses.
- Loading branch information
Showing
3 changed files
with
196 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
("(" @open ")" @close) | ||
("[" @open "]" @close) | ||
("{" @open "}" @close) |
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,72 +1,210 @@ | ||
[ | ||
"if" | ||
"then" | ||
"else" | ||
"let" | ||
"in" | ||
(case) | ||
(of) | ||
(backslash) | ||
(as) | ||
(port) | ||
(exposing) | ||
(alias) | ||
(import) | ||
(module) | ||
(type) | ||
(arrow) | ||
] @keyword | ||
(line_comment) | ||
(block_comment) | ||
] @comment | ||
|
||
; Keywords | ||
;--------- | ||
[ | ||
(eq) | ||
(operator_identifier) | ||
(colon) | ||
] @operator | ||
|
||
(type_annotation(lower_case_identifier) @function) | ||
(port_annotation(lower_case_identifier) @function) | ||
(function_declaration_left(lower_case_identifier) @function.definition) | ||
(module) | ||
(import) | ||
(exposing) | ||
(port) | ||
(type) | ||
(alias) | ||
(infix) | ||
(as) | ||
(case) | ||
(of) | ||
"if" | ||
"then" | ||
"else" | ||
"let" | ||
"in" | ||
] @keyword | ||
|
||
(function_call_expr | ||
target: (value_expr | ||
name: (value_qid (lower_case_identifier) @function))) | ||
|
||
(exposed_value(lower_case_identifier) @function) | ||
(exposed_type(upper_case_identifier) @type) | ||
; Punctuation | ||
;------------ | ||
(double_dot) @punctuation.special | ||
|
||
(field_access_expr(value_expr(value_qid)) @identifier) | ||
(lower_pattern) @variable | ||
(record_base_identifier) @identifier | ||
[ | ||
"," | ||
"|" | ||
(dot) | ||
] @punctuation.delimiter | ||
|
||
[ | ||
"(" | ||
")" | ||
"(" | ||
")" | ||
"{" | ||
"}" | ||
"[" | ||
"]" | ||
] @punctuation.bracket | ||
|
||
[ | ||
"|" | ||
"," | ||
] @punctuation.delimiter | ||
; Variables | ||
;---------- | ||
(value_qid | ||
(lower_case_identifier) @variable) | ||
|
||
(value_declaration | ||
(function_declaration_left | ||
(lower_case_identifier) @variable)) | ||
|
||
(type_annotation | ||
(lower_case_identifier) @variable) | ||
|
||
(port_annotation | ||
(lower_case_identifier) @variable) | ||
|
||
(number_constant_expr) @constant | ||
(record_base_identifier | ||
(lower_case_identifier) @variable) | ||
|
||
(type_declaration(upper_case_identifier) @type) | ||
(type_ref) @type | ||
(type_alias_declaration name: (upper_case_identifier) @type) | ||
(lower_pattern | ||
(lower_case_identifier) @variable) | ||
|
||
(value_expr(upper_case_qid(upper_case_identifier)) @type) | ||
(exposed_value | ||
(lower_case_identifier) @variable) | ||
|
||
(value_qid | ||
((dot) | ||
(lower_case_identifier) @variable)) | ||
|
||
(field_access_expr | ||
((dot) | ||
(lower_case_identifier) @variable)) | ||
|
||
(function_declaration_left | ||
(lower_pattern | ||
(lower_case_identifier) @variable)) | ||
|
||
; Functions | ||
;---------- | ||
(value_declaration | ||
functionDeclarationLeft: (function_declaration_left | ||
(lower_case_identifier) @function | ||
(pattern))) | ||
|
||
(value_declaration | ||
functionDeclarationLeft: (function_declaration_left | ||
(lower_case_identifier) @function | ||
pattern: (_))) | ||
|
||
(value_declaration | ||
functionDeclarationLeft: (function_declaration_left | ||
(lower_case_identifier) @function) | ||
body: (anonymous_function_expr)) | ||
|
||
(type_annotation | ||
name: (lower_case_identifier) @function | ||
typeExpression: (type_expression | ||
(arrow))) | ||
|
||
(port_annotation | ||
name: (lower_case_identifier) @function | ||
typeExpression: (type_expression | ||
(arrow))) | ||
|
||
(function_call_expr | ||
target: (value_expr | ||
(value_qid | ||
(lower_case_identifier) @function))) | ||
|
||
; Operators | ||
;---------- | ||
[ | ||
(line_comment) | ||
(block_comment) | ||
] @comment | ||
(operator_identifier) | ||
(eq) | ||
(colon) | ||
(arrow) | ||
(backslash) | ||
"::" | ||
] @operator | ||
|
||
; Modules | ||
;-------- | ||
(module_declaration | ||
(upper_case_qid | ||
(upper_case_identifier) @title)) | ||
|
||
(import_clause | ||
(upper_case_qid | ||
(upper_case_identifier) @title)) | ||
|
||
(as_clause | ||
(upper_case_identifier) @title) | ||
|
||
(value_expr | ||
(value_qid | ||
(upper_case_identifier) @title)) | ||
|
||
; Types | ||
;------ | ||
(type_declaration | ||
(upper_case_identifier) @type) | ||
|
||
(type_ref | ||
(upper_case_qid | ||
(upper_case_identifier) @type)) | ||
|
||
(type_variable | ||
(lower_case_identifier) @type) | ||
|
||
(lower_type_name | ||
(lower_case_identifier) @type) | ||
|
||
(exposed_type | ||
(upper_case_identifier) @type) | ||
|
||
(type_alias_declaration | ||
(upper_case_identifier) @type) | ||
|
||
(string_escape) @string.escape | ||
(field_type | ||
name: (lower_case_identifier) @property) | ||
|
||
(field | ||
name: (lower_case_identifier) @property) | ||
|
||
(type_declaration | ||
(union_variant | ||
(upper_case_identifier) @constructor)) | ||
|
||
(nullary_constructor_argument_pattern | ||
(upper_case_qid | ||
(upper_case_identifier) @constructor)) | ||
|
||
(union_pattern | ||
(upper_case_qid | ||
(upper_case_identifier) @constructor)) | ||
|
||
(value_expr | ||
(upper_case_qid | ||
(upper_case_identifier)) @constructor) | ||
|
||
; Literals | ||
;--------- | ||
(number_constant_expr | ||
(number_literal) @number) | ||
|
||
(upper_case_qid | ||
((upper_case_identifier) @boolean | ||
(#any-of? @boolean "True" "False"))) | ||
|
||
[ | ||
(open_quote) | ||
(close_quote) | ||
(regular_string_part) | ||
(open_char) | ||
(close_char) | ||
(open_quote) | ||
(close_quote) | ||
(open_char) | ||
(close_char) | ||
] @string | ||
|
||
(string_constant_expr | ||
(string_escape) @string) | ||
|
||
(string_constant_expr | ||
(regular_string_part) @string) | ||
|
||
(char_constant_expr | ||
(string_escape) @string) | ||
|
||
(char_constant_expr | ||
(regular_string_part) @string) |