Unnamed repository; edit this file 'description' to name the repository.
Improve language support for Ada (#12131)
Co-authored-by: Michael Davis <[email protected]>
Ronan Desplanques 2024-11-27
parent 80709ce · commit 95e6c11
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml18
-rw-r--r--runtime/queries/gpr/highlights.scm51
3 files changed, 68 insertions, 2 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index d85cebf0..f51e9bb1 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 0acb7f42..df0a29cf 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 00000000..9d24928b
--- /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 .)])