mirror of https://github.com/helix-editor/helix
feat: Improved syntax highlighting for Gleam (#13807)
parent
c96642125f
commit
40a3fb9b92
|
@ -174,6 +174,7 @@ We use a similar set of scopes as
|
||||||
- `documentation` - Line documentation comments (e.g. `///` in Rust)
|
- `documentation` - Line documentation comments (e.g. `///` in Rust)
|
||||||
- `block` - Block comments (e.g. (`/* */`)
|
- `block` - Block comments (e.g. (`/* */`)
|
||||||
- `documentation` - Block documentation comments (e.g. `/** */` in Rust)
|
- `documentation` - Block documentation comments (e.g. `/** */` in Rust)
|
||||||
|
- `unused` - Unused variables and patterns, e.g. `_` and `_foo`
|
||||||
|
|
||||||
- `variable` - Variables
|
- `variable` - Variables
|
||||||
- `builtin` - Reserved language variables (`self`, `this`, `super`, etc.)
|
- `builtin` - Reserved language variables (`self`, `this`, `super`, etc.)
|
||||||
|
|
|
@ -2080,14 +2080,14 @@ scope = "source.gleam"
|
||||||
injection-regex = "gleam"
|
injection-regex = "gleam"
|
||||||
file-types = ["gleam"]
|
file-types = ["gleam"]
|
||||||
roots = ["gleam.toml"]
|
roots = ["gleam.toml"]
|
||||||
comment-token = "//"
|
comment-tokens = ["//", "///", "////"]
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
language-servers = [ "gleam" ]
|
language-servers = [ "gleam" ]
|
||||||
auto-format = true
|
auto-format = true
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "gleam"
|
name = "gleam"
|
||||||
source = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "6ece453acf8b14568c10f629f8cd25d3dde3794f" }
|
source = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "ee93c639dc82148d716919df336ad612fd33538e" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "quarto"
|
name = "quarto"
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
; Variables
|
; Variables
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
(discard) @comment.unused
|
(discard) @comment.unused ; `_` pattern
|
||||||
|
(hole) @comment.unused ; `_`, `_foo` unused variable
|
||||||
|
|
||||||
; Comments
|
; Comments
|
||||||
(module_comment) @comment
|
(module_comment) @comment.line.documentation
|
||||||
(statement_comment) @comment
|
(statement_comment) @comment.line.documentation
|
||||||
(comment) @comment
|
(comment) @comment.line
|
||||||
|
|
||||||
; Constants
|
; Constants
|
||||||
(constant
|
(constant
|
||||||
|
@ -23,7 +24,10 @@
|
||||||
field: (label) @function)
|
field: (label) @function)
|
||||||
(#is-not? local))
|
(#is-not? local))
|
||||||
|
|
||||||
|
; =========
|
||||||
; Functions
|
; Functions
|
||||||
|
; =========
|
||||||
|
|
||||||
(unqualified_import (identifier) @function)
|
(unqualified_import (identifier) @function)
|
||||||
(unqualified_import "type" (type_identifier) @type)
|
(unqualified_import "type" (type_identifier) @type)
|
||||||
(unqualified_import (type_identifier) @constructor)
|
(unqualified_import (type_identifier) @constructor)
|
||||||
|
@ -41,6 +45,10 @@
|
||||||
right: (identifier) @function)
|
right: (identifier) @function)
|
||||||
(#is-not? local))
|
(#is-not? local))
|
||||||
|
|
||||||
|
; =========
|
||||||
|
; Misc
|
||||||
|
; =========
|
||||||
|
|
||||||
; "Properties"
|
; "Properties"
|
||||||
; Assumed to be intended to refer to a name for a field; something that comes
|
; Assumed to be intended to refer to a name for a field; something that comes
|
||||||
; before ":" or after "."
|
; before ":" or after "."
|
||||||
|
@ -56,27 +64,55 @@
|
||||||
|
|
||||||
(attribute_value (identifier) @constant)
|
(attribute_value (identifier) @constant)
|
||||||
|
|
||||||
|
; =========
|
||||||
|
; Types
|
||||||
|
; =========
|
||||||
|
|
||||||
|
(type_hole) @comment.unused
|
||||||
|
|
||||||
; Type names
|
; Type names
|
||||||
(remote_type_identifier) @type
|
(remote_type_identifier) @type
|
||||||
(type_identifier) @type
|
(type_identifier) @type
|
||||||
|
|
||||||
|
; Generic types
|
||||||
|
[
|
||||||
|
; in `pub type Dict(key, value)` this is `key` and `value`
|
||||||
|
(type_parameter)
|
||||||
|
; in `pub fn size(dict: Dict(key, value)) -> Int` this is `key` and `value`
|
||||||
|
(type_var)
|
||||||
|
] @type
|
||||||
|
|
||||||
; Data constructors
|
; Data constructors
|
||||||
(constructor_name) @constructor
|
(constructor_name) @constructor
|
||||||
|
|
||||||
|
; built-ins
|
||||||
|
((constructor_name) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin "False" "True"))
|
||||||
|
((constructor_name) @constant.builtin
|
||||||
|
(#any-of? @constant.builtin "Nil"))
|
||||||
|
((constructor_name) @type.enum.variant.builtin
|
||||||
|
(#any-of? @type.enum.variant.builtin "Ok" "Error" "Some" "None"))
|
||||||
|
|
||||||
|
; =========
|
||||||
; Literals
|
; Literals
|
||||||
|
; =========
|
||||||
|
|
||||||
(string) @string
|
(string) @string
|
||||||
|
(escape_sequence) @constant.character.escape
|
||||||
((escape_sequence) @warning
|
((escape_sequence) @warning
|
||||||
(#eq? @warning "\\e")) ; deprecated escape sequence
|
(#eq? @warning "\\e")) ; deprecated escape sequence
|
||||||
(escape_sequence) @constant.character.escape
|
|
||||||
(bit_string_segment_option) @function.builtin
|
(bit_string_segment_option) @function.builtin
|
||||||
(integer) @constant.numeric.integer
|
(integer) @constant.numeric.integer
|
||||||
(float) @constant.numeric.float
|
(float) @constant.numeric.float
|
||||||
|
|
||||||
; Reserved identifiers
|
; Reserved identifiers
|
||||||
((identifier) @error
|
((identifier) @error
|
||||||
(#any-of? @error "auto" "delegate" "derive" "else" "implement" "macro" "test" "echo"))
|
(#any-of? @error "auto" "delegate" "derive" "else" "implement" "macro" "test"))
|
||||||
|
|
||||||
|
; =========
|
||||||
; Keywords
|
; Keywords
|
||||||
|
; =========
|
||||||
|
|
||||||
[
|
[
|
||||||
(visibility_modifier) ; "pub"
|
(visibility_modifier) ; "pub"
|
||||||
(opacity_modifier) ; "opaque"
|
(opacity_modifier) ; "opaque"
|
||||||
|
@ -94,15 +130,32 @@
|
||||||
"todo"
|
"todo"
|
||||||
"type"
|
"type"
|
||||||
"use"
|
"use"
|
||||||
|
"echo"
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
|
; =========
|
||||||
; Operators
|
; Operators
|
||||||
|
; =========
|
||||||
|
|
||||||
(binary_expression
|
(binary_expression
|
||||||
operator: _ @operator)
|
operator: _ @operator)
|
||||||
(boolean_negation "!" @operator)
|
(boolean_negation "!" @operator)
|
||||||
(integer_negation "-" @operator)
|
(integer_negation "-" @operator)
|
||||||
|
|
||||||
|
[
|
||||||
|
"->"
|
||||||
|
"-"
|
||||||
|
"="
|
||||||
|
".."
|
||||||
|
"<-"
|
||||||
|
; OR clause in patterns
|
||||||
|
"|"
|
||||||
|
] @operator
|
||||||
|
|
||||||
|
; ==========
|
||||||
; Punctuation
|
; Punctuation
|
||||||
|
; ==========
|
||||||
|
|
||||||
[
|
[
|
||||||
"("
|
"("
|
||||||
")"
|
")"
|
||||||
|
@ -113,15 +166,23 @@
|
||||||
"<<"
|
"<<"
|
||||||
">>"
|
">>"
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(tuple_type "#" @punctuation.bracket)
|
||||||
|
(tuple "#" @punctuation.bracket)
|
||||||
|
(tuple_pattern "#" @punctuation.bracket)
|
||||||
|
|
||||||
|
[
|
||||||
|
","
|
||||||
|
":"
|
||||||
|
] @punctuation.delimiter
|
||||||
|
|
||||||
|
; the `/` in `import gleam/list`
|
||||||
|
(import (module "/" @punctuation.delimiter))
|
||||||
|
|
||||||
[
|
[
|
||||||
"."
|
"."
|
||||||
","
|
] @punctuation
|
||||||
;; Controversial -- maybe some are operators?
|
|
||||||
":"
|
; affects e.g. `replace` in `string.replace("+", "-")`
|
||||||
"#"
|
; without this, it would be highlighted as a field instead of function
|
||||||
"="
|
(function_call (field_access (label) @function))
|
||||||
"->"
|
|
||||||
".."
|
|
||||||
"-"
|
|
||||||
"<-"
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
; Inject markdown into documentation comments
|
||||||
|
((doc_comment_content) @injection.content
|
||||||
|
(#set! injection.language "markdown")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
Loading…
Reference in New Issue