From 6e3ed7f0fa91a3adc01f33e182999f606b48ce6a Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 4 Feb 2024 02:10:20 +0100 Subject: [PATCH] Update Unison tree-sitter grammar for type changes and add indent queries (#9505) * Update Unison tree-sitter grammar for type changes * Add indent queries for Unison * Improve Unison indent queries --- book/src/generated/lang-support.md | 2 +- languages.toml | 2 +- runtime/queries/unison/highlights.scm | 4 +--- runtime/queries/unison/indents.scm | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 runtime/queries/unison/indents.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index e7d29cc7340c..ddd480536dc3 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -174,7 +174,7 @@ | typescript | ✓ | ✓ | ✓ | `typescript-language-server` | | typst | ✓ | | | `typst-lsp` | | ungrammar | ✓ | | | | -| unison | ✓ | | | | +| unison | ✓ | | ✓ | | | uxntal | ✓ | | | | | v | ✓ | ✓ | ✓ | `v-analyzer` | | vala | ✓ | | | `vala-language-server` | diff --git a/languages.toml b/languages.toml index e601c20d95e3..11afea0cad29 100644 --- a/languages.toml +++ b/languages.toml @@ -2940,7 +2940,7 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "unison" -source = { git = "https://github.com/kylegoetz/tree-sitter-unison", rev = "aaec316774c8b50d367ec7cf26523aac5ef0cfc5" } +source = { git = "https://github.com/kylegoetz/tree-sitter-unison", rev = "1f505e2447fa876a87aee47ff3d70b9e141c744f" } [[language]] name = "todotxt" diff --git a/runtime/queries/unison/highlights.scm b/runtime/queries/unison/highlights.scm index d58285ed8a90..711779295f26 100644 --- a/runtime/queries/unison/highlights.scm +++ b/runtime/queries/unison/highlights.scm @@ -9,8 +9,6 @@ ;; Keywords [ (kw_forall) - (unique_kw) - (structural_kw) (type_kw) (kw_equals) (do) @@ -51,7 +49,7 @@ (blank_pattern) @variable.builtin ;; Types -(record_field name: (wordy_id) @variable.other.member type: (wordy_id) @type) +(record_field name: (wordy_id) @variable.other.member type: (_) @type) (type_constructor (type_name (wordy_id) @constructor)) (ability_declaration type_name: (wordy_id) @type type_arg: (wordy_id) @variable.parameter) (effect (wordy_id) @special) ;; NOTE: an effect is just like a type, but in signature we special case it diff --git a/runtime/queries/unison/indents.scm b/runtime/queries/unison/indents.scm new file mode 100644 index 000000000000..6cb15517cfdc --- /dev/null +++ b/runtime/queries/unison/indents.scm @@ -0,0 +1,15 @@ +[ + (term_definition) + (type_declaration) + (pattern) + (tuple_or_parenthesized) + (literal_list) + (tuple_pattern) + (function_application) + (exp_if) + (constructor) + (delay_block) + (type_signature) +] @indent + +[(kw_then) (kw_else) (cases)] @indent.always @extend