From 4163a3a246fea4c7cfe263ae249e1bda777ade14 Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 24 Jul 2023 18:32:08 +0200 Subject: [PATCH 1/7] Add Unison LSP support --- languages.toml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/languages.toml b/languages.toml index 7f77429635cc..3da9c4c8815d 100644 --- a/languages.toml +++ b/languages.toml @@ -68,6 +68,7 @@ swipl = { command = "swipl", args = [ "-g", "use_module(library(lsp_server))", " taplo = { command = "taplo", args = ["lsp", "stdio"] } terraform-ls = { command = "terraform-ls", args = ["serve"] } texlab = { command = "texlab" } +ucm = { command = "ncat", args = ["localhost", "5757"] } vala-language-server = { command = "vala-language-server" } vhdl_ls = { command = "vhdl_ls", args = [] } vlang-language-server = { command = "v", args = ["ls"] } @@ -2698,3 +2699,27 @@ file-types = ["webc"] roots = [] indent = { tab-width = 2, unit = " " } grammar = "html" + +[[language]] +name = "unison" +scope = "source.unison" +injection-regex = "unison" +file-types = ["u"] +shebangs = [] +roots = [] +auto-format = false +comment-token = "--" +indent = { tab-width = 4, unit = " " } +language-servers = ["ucm"] + +[language.auto-pairs] +'(' = ')' +'{' = '}' +'[' = ']' +'"' = '"' +'`' = '`' + +[[grammar]] +name = "unison" +source = { git = "https://github.com/kylegoetz/tree-sitter-unison", rev = "f27f42e8df457508d2dbffd6ca60b289f5d6fe2d" } + From 60a6601530f182f74427fe45db0d78dcc433865c Mon Sep 17 00:00:00 2001 From: zetashift Date: Mon, 24 Jul 2023 18:40:56 +0200 Subject: [PATCH 2/7] Add some basic highlighting for Unison --- runtime/queries/unison/highlights.scm | 72 +++++++++++++++++++++++++++ runtime/queries/unison/injections.scm | 1 + 2 files changed, 73 insertions(+) create mode 100644 runtime/queries/unison/highlights.scm create mode 100644 runtime/queries/unison/injections.scm diff --git a/runtime/queries/unison/highlights.scm b/runtime/queries/unison/highlights.scm new file mode 100644 index 000000000000..8ec2b6ff2b1e --- /dev/null +++ b/runtime/queries/unison/highlights.scm @@ -0,0 +1,72 @@ +;; Primitives +(comment) @comment +(nat) @constant.numeric +(unit) @constant.builtin +(literal_char) @constant.character +(literal_text) @string +(literal_boolean) @constant.builtin.boolean + +;; Keywords +[ + (kw_forall) + (unique_kw) + (type_kw) + (kw_equals) + (do) +] @keyword + +(kw_let) @keyword.function +(type_kw) @keyword.storage.type +(unique) @keyword.storage.modifier +("use") @keyword.control.import + + +[ + (type_constructor) +] @constructor + +[ + (operator) + (pipe) + (arrow_symbol) + (">") + (or) + (bang) +] @operator + +[ + "if" + "else" + "then" + (match) + (with) + (cases) +] @keyword.control.conditional + +(blank_pattern) @variable.builtin + +;; Types +(record_field name: (wordy_id) @variable.other.member type: (wordy_id) @type) +[ + (type_name) + (type_signature) + (effect) +] @type + +(term_definition) @variable + +;; Punctuation +[ + (type_signature_colon) + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + diff --git a/runtime/queries/unison/injections.scm b/runtime/queries/unison/injections.scm new file mode 100644 index 000000000000..4f0cc44c9df0 --- /dev/null +++ b/runtime/queries/unison/injections.scm @@ -0,0 +1 @@ +((doc_block) @injection.content (#set! injection.language "markdown")) From 5fd03e52b6bb606ddb0ec92ab3a00b823453ce09 Mon Sep 17 00:00:00 2001 From: zetashift Date: Thu, 27 Jul 2023 09:18:17 +0200 Subject: [PATCH 3/7] Add tree-sitter-unison branch with parser.c --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 3da9c4c8815d..be2911dc7164 100644 --- a/languages.toml +++ b/languages.toml @@ -2721,5 +2721,5 @@ language-servers = ["ucm"] [[grammar]] name = "unison" -source = { git = "https://github.com/kylegoetz/tree-sitter-unison", rev = "f27f42e8df457508d2dbffd6ca60b289f5d6fe2d" } +source = { git = "https://github.com/kylegoetz/tree-sitter-unison", branch = "deploy", rev = "1df9e35477b4261abb7cd9d3ab5b2f565fc3fd8a" } From 8d344fbc90557c5118db8c50084580c8cf823d01 Mon Sep 17 00:00:00 2001 From: zetashift Date: Thu, 27 Jul 2023 09:31:11 +0200 Subject: [PATCH 4/7] Add autogenerated docs for Unison --- book/src/generated/lang-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 8941f735f20b..cf9e69071f41 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -155,6 +155,7 @@ | twig | ✓ | | | | | typescript | ✓ | ✓ | ✓ | `typescript-language-server` | | ungrammar | ✓ | | | | +| unison | ✓ | | | `ncat` | | uxntal | ✓ | | | | | v | ✓ | ✓ | ✓ | `v` | | vala | ✓ | | | `vala-language-server` | From 4cd543e1eb54d2a4567b988c783ecf6ca75ba189 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sat, 5 Aug 2023 16:31:08 +0200 Subject: [PATCH 5/7] Remove netcat LSP for Unison --- languages.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/languages.toml b/languages.toml index 618ad3ef3f84..8c422a215bb9 100644 --- a/languages.toml +++ b/languages.toml @@ -70,7 +70,6 @@ swipl = { command = "swipl", args = [ "-g", "use_module(library(lsp_server))", " taplo = { command = "taplo", args = ["lsp", "stdio"] } terraform-ls = { command = "terraform-ls", args = ["serve"] } texlab = { command = "texlab" } -ucm = { command = "ncat", args = ["localhost", "5757"] } vala-language-server = { command = "vala-language-server" } vhdl_ls = { command = "vhdl_ls", args = [] } vlang-language-server = { command = "v-analyzer" } @@ -2725,7 +2724,6 @@ roots = [] auto-format = false comment-token = "--" indent = { tab-width = 4, unit = " " } -language-servers = ["ucm"] [language.auto-pairs] '(' = ')' From a04074520968c9ded161aab43d6a70f7eb846e9d Mon Sep 17 00:00:00 2001 From: zetashift Date: Sat, 5 Aug 2023 16:31:34 +0200 Subject: [PATCH 6/7] Fixup tree-sitter-unison source --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 8c422a215bb9..5eca6f9273c6 100644 --- a/languages.toml +++ b/languages.toml @@ -2734,5 +2734,5 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "unison" -source = { git = "https://github.com/kylegoetz/tree-sitter-unison", branch = "deploy", rev = "1df9e35477b4261abb7cd9d3ab5b2f565fc3fd8a" } +source = { git = "https://github.com/kylegoetz/tree-sitter-unison", rev = "98c4e8bc5c9f5989814a720457cf36963cf4043d" } From 4a6bfdd8417a187277d79b86eb519d95090361b5 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sat, 5 Aug 2023 17:07:18 +0200 Subject: [PATCH 7/7] Update docs --- book/src/generated/lang-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index b0ee325090e1..64e3042ba5c5 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -155,7 +155,7 @@ | twig | ✓ | | | | | typescript | ✓ | ✓ | ✓ | `typescript-language-server` | | ungrammar | ✓ | | | | -| unison | ✓ | | | `ncat` | +| unison | ✓ | | | | | uxntal | ✓ | | | | | v | ✓ | ✓ | ✓ | `v-analyzer` | | vala | ✓ | | | `vala-language-server` |