on master help sign in
add tree-sitter-gleam
commit7cd60502358440449935a50b4d95fa6527312037 authorMichael Davis <mcarsondavis@gmail.com> dateTue 29 Mar 2022, 21:13 (5 years ago) parent1819478
4 files changed+130
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/gleam/highlights.scm+101 runtime/queries/gleam/locals.scm+15
book/src/generated/lang-support.md+1
@@ -17,6 +17,7 @@
1717| git-config | ✓ | | | |
1818| git-diff | ✓ | | | |
1919| git-rebase | ✓ | | | |
20+| gleam | ✓ | | | |
2021| glsl | ✓ | | ✓ | |
2122| go | ✓ | ✓ | ✓ | `gopls` |
2223| graphql | ✓ | | | |
languages.toml+13
@@ -1003,3 +1003,16 @@ language-server = { command = "solc", args = ["--lsp"] }
10031003[[grammar]]
10041004name = "solidity"
10051005source = { git = "https://github.com/slinlee/tree-sitter-solidity", rev = "f3a002274744e859bf64cf3524985f8c31ea84fd" }
1006+
1007+[[language]]
1008+name = "gleam"
1009+scope = "source.gleam"
1010+injection-regex = "gleam"
1011+file-types = ["gleam"]
1012+roots = ["gleam.toml"]
1013+comment-token = "//"
1014+indent = { tab-width = 2, unit = " " }
1015+
1016+[[grammar]]
1017+name = "gleam"
1018+source = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "7159ce961592192b0e7cdf88782cda0fdf41a4cb" }
runtime/queries/gleam/highlights.scmnew file+101
@@ -0,0 +1,101 @@
1+; Comments
2+(module_comment) @comment
3+(statement_comment) @comment
4+(comment) @comment
5+
6+; Constants
7+(constant
8+ name: (identifier) @constant)
9+
10+; Modules
11+(module) @namespace
12+(import alias: (identifier) @namespace)
13+(remote_type_identifier
14+ module: (identifier) @namespace)
15+((field_access
16+ record: (identifier) @namespace
17+ field: (label) @function)
18+ (#is-not? local))
19+
20+; Functions
21+(unqualified_import (identifier) @function)
22+(function
23+ name: (identifier) @function)
24+(external_function
25+ name: (identifier) @function)
26+(function_parameter
27+ name: (identifier) @variable.parameter)
28+((function_call
29+ function: (identifier) @function)
30+ (#is-not? local))
31+((binary_expression
32+ operator: "|>"
33+ right: (identifier) @function)
34+ (#is-not? local))
35+
36+; "Properties"
37+; Assumed to be intended to refer to a name for a field; something that comes
38+; before ":" or after "."
39+; e.g. record field names, tuple indices, names for named arguments, etc
40+(label) @variable.other.member
41+(tuple_access
42+ index: (integer) @variable.other.member)
43+
44+; Type names
45+(remote_type_identifier) @type
46+(type_identifier) @type
47+
48+; Literals
49+(string) @string
50+(bit_string_segment_option) @function.builtin
51+(integer) @constant.numeric.integer
52+(float) @constant.numeric.float
53+
54+; Variables
55+(identifier) @variable
56+(discard) @comment.unused
57+
58+; Operators
59+(binary_expression
60+ operator: _ @operator)
61+
62+; Keywords
63+[
64+ (visibility_modifier) ; "pub"
65+ (opacity_modifier) ; "opaque"
66+ "as"
67+ "assert"
68+ "case"
69+ "const"
70+ "external"
71+ "fn"
72+ "if"
73+ "import"
74+ "let"
75+ "todo"
76+ "try"
77+ "type"
78+] @keyword
79+
80+; Punctuation
81+[
82+ "("
83+ ")"
84+ "["
85+ "]"
86+ "{"
87+ "}"
88+ "<<"
89+ ">>"
90+] @punctuation.bracket
91+[
92+ "."
93+ ","
94+ ;; Controversial -- maybe some are operators?
95+ ":"
96+ "#"
97+ "="
98+ "->"
99+ ".."
100+ "-"
101+] @punctuation.delimiter
runtime/queries/gleam/locals.scmnew file+15
@@ -0,0 +1,15 @@
1+; Scopes
2+(function_body) @local.scope
3+
4+(case_clause) @local.scope
5+
6+; Definitions
7+(let pattern: (identifier) @local.definition)
8+(function_parameter name: (identifier) @local.definition)
9+(list_pattern (identifier) @local.definition)
10+(list_pattern assign: (identifier) @local.definition)
11+(tuple_pattern (identifier) @local.definition)
12+(record_pattern_argument pattern: (identifier) @local.definition)
13+
14+; References
15+(identifier) @local.reference