From 1f6809c9ce8f4b864b3754111b8673ca282f67f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Delafargue?= Date: Fri, 13 Jan 2023 11:29:40 +0100 Subject: [PATCH] Language support for dhall https://dhall-lang.org/ --- book/src/generated/lang-support.md | 1 + languages.toml | 15 ++++++++ runtime/queries/dhall/highlights.scm | 52 +++++++++++++++++++++++++++ runtime/queries/dhall/textobjects.scm | 23 ++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 runtime/queries/dhall/highlights.scm create mode 100644 runtime/queries/dhall/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a506e6a5..00e6a91e 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -22,6 +22,7 @@ | d | ✓ | ✓ | ✓ | `serve-d` | | dart | ✓ | | ✓ | `dart` | | devicetree | ✓ | | | | +| dhall | ✓ | ✓ | | `dhall-lsp-server` | | diff | ✓ | | | | | dockerfile | ✓ | | | `docker-langserver` | | dot | ✓ | | | `dot-language-server` | diff --git a/languages.toml b/languages.toml index 9029c94e..51b4efb2 100644 --- a/languages.toml +++ b/languages.toml @@ -2092,3 +2092,18 @@ comment-token = "//" [[grammar]] name = "ponylang" source = { git = "https://github.com/mfelsche/tree-sitter-ponylang", rev = "ef66b151bc2604f431b5668fcec4747db4290e11" } + +[[language]] +name = "dhall" +scope = "source.dhall" +injection-regex = "dhall" +file-types = ["dhall"] +roots = [] +comment-token = "--" +indent = { tab-width = 2, unit = " " } +language-server = { command = "dhall-lsp-server" } +formatter = { command = "dhall" , args = ["format"] } + +[[grammar]] +name = "dhall" +source = { git = "https://github.com/jbellerb/tree-sitter-dhall", rev = "affb6ee38d629c9296749767ab832d69bb0d9ea8" } \ No newline at end of file diff --git a/runtime/queries/dhall/highlights.scm b/runtime/queries/dhall/highlights.scm new file mode 100644 index 00000000..52ede310 --- /dev/null +++ b/runtime/queries/dhall/highlights.scm @@ -0,0 +1,52 @@ +;; Literals + +(integer_literal) @constant.numeric.integer +(natural_literal) @constant.numeric.integer +(double_literal) @constant.numeric.float +(boolean_literal) @constant.builtin.boolean +(text_literal) @string +(local_import) @string.special.path +(http_import) @string.special.url +(import_hash) @string + +;; Comments +[ + (line_comment) + (block_comment) +] @comment + +;; Keywords +[ + ("let") + ("in") + (assign_operator) + (type_operator) + (lambda_operator) + (arrow_operator) + (infix_operator) + (completion_operator) + ("using") + ("assert") + (assert_operator) + ("as") + (forall_operator) + ("with") +] @keyword + +;; Builtins +[ + (builtin_function) + (missing_import) +] @function.builtin + +[ + (builtin) + (import_as_text) +] @type.builtin + +;; Conditionals +[ + ("if") + ("then") + ("else") +] @keyword.control.conditional diff --git a/runtime/queries/dhall/textobjects.scm b/runtime/queries/dhall/textobjects.scm new file mode 100644 index 00000000..c840c758 --- /dev/null +++ b/runtime/queries/dhall/textobjects.scm @@ -0,0 +1,23 @@ +(lambda_expression + (label) @parameter.inside + (expression) @function.inside +) @function.around + +(forall_expression + (label) @parameter.inside + (expression) @function.inside +) @function.around + +(assert_expression + (expression) @test.inside +) @test.around + +[ + (block_comment_content) + (line_comment_content) +] @comment.inside + +[ + (block_comment) + (line_comment) +] @comment.around