diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/gleam | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/gleam')
| -rw-r--r-- | runtime/queries/gleam/folds.scm | 7 | ||||
| -rw-r--r-- | runtime/queries/gleam/highlights.scm | 200 | ||||
| -rw-r--r-- | runtime/queries/gleam/indents.scm | 30 | ||||
| -rw-r--r-- | runtime/queries/gleam/injections.scm | 7 | ||||
| -rw-r--r-- | runtime/queries/gleam/locals.scm | 31 |
5 files changed, 275 insertions, 0 deletions
diff --git a/runtime/queries/gleam/folds.scm b/runtime/queries/gleam/folds.scm new file mode 100644 index 000000000..b4cd225e7 --- /dev/null +++ b/runtime/queries/gleam/folds.scm @@ -0,0 +1,7 @@ +; Folds +[ + (case) + (function) + (anonymous_function) + (type_definition) +] @fold diff --git a/runtime/queries/gleam/highlights.scm b/runtime/queries/gleam/highlights.scm new file mode 100644 index 000000000..f80bda240 --- /dev/null +++ b/runtime/queries/gleam/highlights.scm @@ -0,0 +1,200 @@ +; Keywords +[ + "as" + "let" + "panic" + "todo" + "use" + "echo" +] @keyword + +"type" @keyword.type + +; Function Keywords +"fn" @keyword.function + +; Imports +"import" @keyword.import + +; Conditionals +[ + "case" + "if" +] @keyword.conditional + +; Exceptions +"assert" @keyword.exception + +; Punctuation +[ + "(" + ")" + "<<" + ">>" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + ":" + "->" +] @punctuation.delimiter + +"#" @punctuation.special + +; Operators +[ + "%" + "&&" + "*" + "*." + "+" + "+." + "-" + "-." + ".." + "/" + "/." + "<" + "<." + "<=" + "<=." + "=" + "==" + ">" + ">." + ">=" + ">=." + "|>" + "||" +] @operator + +; Identifiers +(identifier) @variable + +; Comments +(comment) @comment @spell + +[ + (module_comment) + (statement_comment) +] @comment.documentation @spell + +; Unused Identifiers +[ + (discard) + (hole) +] @comment + +; Modules & Imports +(module) @module + +(import + alias: ((identifier) @module)?) + +(remote_type_identifier + module: (identifier) @module) + +(unqualified_import + name: (identifier) @function) + +; Strings +(string) @string + +; Bit Strings +(bit_string_segment) @string.special + +; Numbers +(integer) @number + +(float) @number.float + +; Function Parameter Labels +(function_call + arguments: (arguments + (argument + label: (label) @label))) + +(function_parameter + label: (label)? @label + name: (identifier) @variable.parameter) + +; Records +(record + arguments: (arguments + (argument + label: (label) @variable.member)?)) + +(record_pattern_argument + label: (label) @variable.member) + +(record_update_argument + label: (label) @variable.member) + +(field_access + record: (identifier) @variable + field: (label) @variable.member) + +(data_constructor_argument + (label) @variable.member) + +; Types +[ + (type_identifier) + (type_parameter) + (type_var) +] @type + +; Type Qualifiers +[ + "const" + "external" + (opacity_modifier) + (visibility_modifier) +] @keyword.modifier + +; Tuples +(tuple_access + index: (integer) @operator) + +; Functions +(function + name: (identifier) @function) + +(function_call + function: (identifier) @function.call) + +(function_call + function: (field_access + field: (label) @function.call)) + +; External Functions +(external_function + name: (identifier) @function) + +(external_function_body + (string) @module + . + (string) @function) + +; Constructors +(constructor_name) @type @constructor + +([ + (type_identifier) + (constructor_name) +] @constant.builtin + (#any-of? @constant.builtin "Ok" "Error")) + +; Booleans +((constructor_name) @boolean + (#any-of? @boolean "True" "False")) + +; Pipe Operator +(binary_expression + operator: "|>" + right: (identifier) @function) diff --git a/runtime/queries/gleam/indents.scm b/runtime/queries/gleam/indents.scm new file mode 100644 index 000000000..3a44ea4c0 --- /dev/null +++ b/runtime/queries/gleam/indents.scm @@ -0,0 +1,30 @@ +; Gleam indents similar to Rust and JavaScript +[ + (anonymous_function) + (assert) + (case) + (case_clause) + (constant) + (external_function) + (function) + (let) + (list) + (constant) + (function) + (type_definition) + (type_alias) + (todo) + (tuple) + (unqualified_imports) +] @indent.begin + +[ + ")" + "]" + "}" +] @indent.end @indent.branch + +; Gleam pipelines are not indented, but other binary expression chains are +((binary_expression + operator: _ @_operator) @indent.begin + (#not-eq? @_operator "|>")) diff --git a/runtime/queries/gleam/injections.scm b/runtime/queries/gleam/injections.scm new file mode 100644 index 000000000..11d4f5d55 --- /dev/null +++ b/runtime/queries/gleam/injections.scm @@ -0,0 +1,7 @@ +; Comments +([ + (module_comment) + (statement_comment) + (comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/gleam/locals.scm b/runtime/queries/gleam/locals.scm new file mode 100644 index 000000000..0058b660e --- /dev/null +++ b/runtime/queries/gleam/locals.scm @@ -0,0 +1,31 @@ +; Let Binding Definition +(let + pattern: (identifier) @local.definition) + +; List Pattern Definitions +(list_pattern + (identifier) @local.definition) + +(list_pattern + assign: (identifier) @local.definition) + +; Tuple Pattern Definition +(tuple_pattern + (identifier) @local.definition) + +; Record Pattern Definition +(record_pattern_argument + pattern: (identifier) @local.definition) + +; Function Parameter Definition +(function_parameter + name: (identifier) @local.definition) + +; References +(identifier) @local.reference + +; Block Scope +(block) @local.scope + +; Case Scope +(case_clause) @local.scope |
