From a2cc8287351c32dd2100375407fe94f630fd646b Mon Sep 17 00:00:00 2001 From: Gary Miller Date: Thu, 28 Mar 2024 14:13:41 +1100 Subject: [PATCH 1/3] feat: Add ADL language support --- book/src/generated/lang-support.md | 1 + languages.toml | 18 +++++++++++++ runtime/queries/adl/highlights.scm | 39 +++++++++++++++++++++++++++++ runtime/queries/adl/indents.scm | 12 +++++++++ runtime/queries/adl/textobjects.scm | 1 + 5 files changed, 71 insertions(+) create mode 100644 runtime/queries/adl/highlights.scm create mode 100644 runtime/queries/adl/indents.scm create mode 100644 runtime/queries/adl/textobjects.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index a4e2a84a2123..1d4bcb17fa70 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -1,6 +1,7 @@ | Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP | | --- | --- | --- | --- | --- | | ada | ✓ | ✓ | | `ada_language_server`, `ada_language_server` | +| adl | ✓ | ✓ | ✓ | | | agda | ✓ | | | | | astro | ✓ | | | | | awk | ✓ | ✓ | | `awk-language-server` | diff --git a/languages.toml b/languages.toml index b047b83ebe1d..f40547d2ec53 100644 --- a/languages.toml +++ b/languages.toml @@ -3460,3 +3460,21 @@ language-servers = ["earthlyls"] [[grammar]] name = "earthfile" source = { git = "https://github.com/glehmann/tree-sitter-earthfile", rev = "2a6ab191f5f962562e495a818aa4e7f45f8a556a" } + +[[language]] +name = "adl" +scope = "source.adl" +injection-regex = "adl" +file-types = ["adl"] +roots = [] +comment-token = "//" +indent = { tab-width = 2, unit = " " } + +[language.auto-pairs] +'"' = '"' +'{' = '}' +'<' = '>' + +[[grammar]] +name = "adl" +source = { git = "https://github.com/adl-lang/tree-sitter-adl", rev = "0399ed80b9fb88865a02259e7c11dc98de1d5ee5" } diff --git a/runtime/queries/adl/highlights.scm b/runtime/queries/adl/highlights.scm new file mode 100644 index 000000000000..f862c550bacf --- /dev/null +++ b/runtime/queries/adl/highlights.scm @@ -0,0 +1,39 @@ +; adl + +[ +"module" +"struct" +"union" +"type" +"newtype" +"annotation" +] @keyword + +(scoped_name) @variable +(comment) @comment +(doc_comment) @info +(name) @type + +(ERROR) @error + +(fname) @property + +(type_expr (scoped_name) @type) + +(type_expr (scoped_name) @generic (type_param) @type.param) + +; json +(key) @string.special.key + +(string) @string + +(number) @number + +[ + (null) + (true) + (false) +] @constant.builtin + +(escape_sequence) @escape + diff --git a/runtime/queries/adl/indents.scm b/runtime/queries/adl/indents.scm new file mode 100644 index 000000000000..1200d4d420ac --- /dev/null +++ b/runtime/queries/adl/indents.scm @@ -0,0 +1,12 @@ +[ + (struct) + (union) + + (array) + (object) +] @indent + +; [ +; "}" +; "]" +; ] @outdent diff --git a/runtime/queries/adl/textobjects.scm b/runtime/queries/adl/textobjects.scm new file mode 100644 index 000000000000..36e39a2d46d6 --- /dev/null +++ b/runtime/queries/adl/textobjects.scm @@ -0,0 +1 @@ +(struct (_) @function.inside) @funtion.around From 933715dbd44e5d233812c1bd16264c6461c2afb7 Mon Sep 17 00:00:00 2001 From: Gary Miller Date: Tue, 2 Apr 2024 14:11:17 +1100 Subject: [PATCH 2/3] removed error match & change captures to match https://docs.helix-editor.com/master/themes.html\#syntax-highlighting --- runtime/queries/adl/highlights.scm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/runtime/queries/adl/highlights.scm b/runtime/queries/adl/highlights.scm index f862c550bacf..634244380323 100644 --- a/runtime/queries/adl/highlights.scm +++ b/runtime/queries/adl/highlights.scm @@ -14,20 +14,18 @@ (doc_comment) @info (name) @type -(ERROR) @error - (fname) @property (type_expr (scoped_name) @type) -(type_expr (scoped_name) @generic (type_param) @type.param) +(type_expr (scoped_name) @generic (type_param) @type.parameter) ; json (key) @string.special.key (string) @string -(number) @number +(number) @constant.numeric [ (null) @@ -35,5 +33,5 @@ (false) ] @constant.builtin -(escape_sequence) @escape +(escape_sequence) @constant.character.escape From 754429a42d753728843bdd1005deb6c19a12ae60 Mon Sep 17 00:00:00 2001 From: Gary Miller Date: Wed, 3 Apr 2024 15:42:59 +1100 Subject: [PATCH 3/3] fixes to grammar, highlight changes based on PR and grammar fixes --- languages.toml | 2 +- runtime/queries/adl/highlights.scm | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/languages.toml b/languages.toml index f40547d2ec53..4e2be820c27d 100644 --- a/languages.toml +++ b/languages.toml @@ -3477,4 +3477,4 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "adl" -source = { git = "https://github.com/adl-lang/tree-sitter-adl", rev = "0399ed80b9fb88865a02259e7c11dc98de1d5ee5" } +source = { git = "https://github.com/adl-lang/tree-sitter-adl", rev = "2787d04beadfbe154d3f2da6e98dc45a1b134bbf" } diff --git a/runtime/queries/adl/highlights.scm b/runtime/queries/adl/highlights.scm index 634244380323..88e00ad7ff6f 100644 --- a/runtime/queries/adl/highlights.scm +++ b/runtime/queries/adl/highlights.scm @@ -9,19 +9,19 @@ "annotation" ] @keyword -(scoped_name) @variable +(adl (scoped_name)) @namespace (comment) @comment -(doc_comment) @info +(doc_comment) @comment.block.documentation (name) @type -(fname) @property +(fname) @variable.other.member (type_expr (scoped_name) @type) -(type_expr (scoped_name) @generic (type_param) @type.parameter) +(type_expr_params (param (scoped_name) @type.parameter)) ; json -(key) @string.special.key +(key) @string.special (string) @string