From 95e6c11ebc04dc5f54f755c77f7c4b9a39b516c7 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Tue, 26 Nov 2024 19:43:34 +0100 Subject: [PATCH] Improve language support for Ada (#12131) Co-authored-by: Michael Davis --- book/src/generated/lang-support.md | 1 + languages.toml | 18 +++++++++-- runtime/queries/gpr/highlights.scm | 51 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/gpr/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d85cebf06..f51e9bb1d 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -78,6 +78,7 @@ | gomod | ✓ | | | `gopls` | | gotmpl | ✓ | | | `gopls` | | gowork | ✓ | | | `gopls` | +| gpr | ✓ | | | `ada_language_server` | | graphql | ✓ | ✓ | | `graphql-lsp` | | groovy | ✓ | | | | | gts | ✓ | ✓ | ✓ | `typescript-language-server`, `vscode-eslint-language-server`, `ember-language-server` | diff --git a/languages.toml b/languages.toml index 0acb7f420..df0a29cf0 100644 --- a/languages.toml +++ b/languages.toml @@ -2540,11 +2540,11 @@ source = { git = "https://github.com/sourcegraph/tree-sitter-jsonnet", rev = "04 name = "ada" scope = "source.ada" injection-regex = "ada" -file-types = ["adb", "ads", "gpr"] +file-types = ["adb", "ads"] roots = ["alire.toml"] comment-token = "--" indent = { tab-width = 3, unit = " " } -language-servers = ["ada-language-server", "ada-gpr-language-server"] +language-servers = ["ada-language-server"] [[grammar]] @@ -3942,3 +3942,17 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "amber" source = { git = "https://github.com/amber-lang/tree-sitter-amber", rev = "c6df3ec2ec243ed76550c525e7ac3d9a10c6c814" } + +[[language]] +name = "gpr" +scope = "source.gpr" +injection-regex = "gpr" +file-types = ["gpr"] +roots = ["alire.toml"] +comment-token = "--" +indent = { tab-width = 3, unit = " " } +language-servers = ["ada-gpr-language-server"] + +[[grammar]] +name = "gpr" +source = { git = "https://github.com/brownts/tree-sitter-gpr", rev = "cea857d3c18d1385d1f5b66cd09ea1e44173945c" } diff --git a/runtime/queries/gpr/highlights.scm b/runtime/queries/gpr/highlights.scm new file mode 100644 index 000000000..9d24928b1 --- /dev/null +++ b/runtime/queries/gpr/highlights.scm @@ -0,0 +1,51 @@ +[ "abstract" "all" "at" + "case" + "end" "extends" "external" "external_as_list" + "for" + "is" + "limited" + "null" + "others" + "package" + ;; "project" + "renames" + "type" + "use" + "when" + "with" + ] @keyword + +;; Avoid highlighting Project in Project'Project_Dir +(project_declaration "project" @keyword) + +;; highlight qualifiers as keywords (not all qualifiers are actual keywords) +(project_qualifier _ @keyword) + +[":=" "&" "|" "=>"] @operator + +(comment) @comment +(string_literal) @string +(numeric_literal) @constant.numeric + +;; Type +(typed_string_declaration name: (identifier) @type) +(variable_declaration type: (name (identifier) @type .)) + +;; Variable +(variable_declaration name: (identifier) @variable) +(variable_reference (name (identifier) @variable .) .) + +;; Function +(builtin_function_call name: _ @function.builtin) + +;; Attribute +(attribute_declaration name: (identifier) @attribute) +(attribute_reference (identifier) @attribute) + +;; Package +(variable_reference (name (identifier) @function .) "'") +(package_declaration + [ name: (identifier) @function + endname: (identifier) @function + origname: (name (identifier) @function .) + basename: (name (identifier) @function .)])