From 920f745b6be70ac1a9c24aa308debcbf0d3f81e6 Mon Sep 17 00:00:00 2001 From: "Paul W." Date: Sat, 24 Oct 2026 17:26:25 -0400 Subject: [PATCH] update highlight.scm and add tags.scm --- package.json | 2 +- queries/highlights.scm | 44 +++++++++++++++++++++++++++--------------- queries/tags.scm | 5 +++++ tree-sitter.json | 4 +++- 4 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 queries/tags.scm diff --git a/package.json b/package.json index 392d4d2..ef52baa 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ "generate": "tree-sitter generate", "test": "tree-sitter test", "test:fixtures": "sh ./scripts/check-fixtures.sh", - "test:queries": "tree-sitter query -p . --quiet queries/highlights.scm test/fixtures/valid/*.ls" + "test:queries": "tree-sitter query -p . --quiet queries/highlights.scm test/fixtures/valid/*.ls && tree-sitter query -p . --quiet queries/tags.scm test/fixtures/valid/*.ls" } } diff --git a/queries/highlights.scm b/queries/highlights.scm index f53223f..45c3caa 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -18,33 +18,45 @@ "use" ] @keyword -(primitive_type) @type.builtin -(identifier) @variable (comment) @comment -(default_expression) @keyword -(boolean_literal) @constant.builtin (string_literal) @string (character_literal) @character (integer_literal) @number (float_literal) @number.float -(label (identifier) @label) +(boolean_literal) @constant.builtin +(default_expression) @keyword -(declaration name: (identifier) @variable.definition) -(typed_parameter pattern: (identifier) @variable.parameter) -(typed_tuple_component pattern: (identifier) @variable.parameter) -(product_field name: (identifier) @property) -(product_entry (identifier) @property) -(sum_variant name: (identifier) @constructor) -(sum_constructor variant: (identifier) @constructor) -(sum_pattern variant: (identifier) @constructor) -(bits_member (identifier) @constant) +(primitive_type) @type.builtin +(type_name) @type +(binder_entry type: (identifier) @type) +(module_path) @module + +(declaration name: (identifier) @function value: (function_literal)) +(declaration name: (identifier) @function type: (function_type)) +(declaration name: (identifier) @type.definition value: (type_definition)) +(pipeline_callable (identifier) @function.call .) +(aggregate_pipeline_callable (identifier) @function.call .) (constraint_entry name: (identifier) @function) (output_type function: (identifier) @function) (output_type function: (qualified_name (identifier) @function .)) +(postfix_expression member: (identifier) @variable.member) +(product_constructor (type_name) @type) +(sum_constructor variant: (identifier) @constructor) +(sum_pattern variant: (identifier) @constructor) +(label (identifier) @label) + +(typed_parameter pattern: (identifier) @variable.parameter) +(typed_tuple_component pattern: (identifier) @variable.parameter) +(product_field name: (identifier) @variable.member) +(product_entry (identifier) @property) +(sum_variant name: (identifier) @constructor) +(bits_member (identifier) @constant) [ - "=" "+=" "-=" "*=" "/=" "%=" "&=" "^=" "|=" + "=" "+=" "-=" "*=" "/=" "%=" "&=" "^=" "|=" "::" ":=" "==" "<" "<=" ">" ">=" "+" "-" "*" "/" "%" "&" "|" "^" "~" - "->" "=>" "|>" "..<" "..=" "@" + "->" "=>" "|>" "..<" "..=" "@" "?" "..." ] @operator + +["(" ")" "[" "]" "{" "}" ":" ";" "," "."] @punctuation diff --git a/queries/tags.scm b/queries/tags.scm new file mode 100644 index 0000000..da3140a --- /dev/null +++ b/queries/tags.scm @@ -0,0 +1,5 @@ +; The picker resolves overlapping definitions in favor of function/type tags. +(declaration name: (identifier) @name) @definition.variable +(declaration name: (identifier) @name value: (function_literal)) @definition.function +(declaration name: (identifier) @name type: (function_type)) @definition.function +(declaration name: (identifier) @name value: (type_definition)) @definition.type diff --git a/tree-sitter.json b/tree-sitter.json index 8c69187..23583f0 100644 --- a/tree-sitter.json +++ b/tree-sitter.json @@ -6,8 +6,10 @@ "scope": "source.lscript", "path": ".", "file-types": [ - "ls" + "ls", + "lscript" ], + "tags": "queries/tags.scm", "highlights": "queries/highlights.scm" } ],