Unnamed repository; edit this file 'description' to name the repository.
languages: add Java .properties file support (#13874)
Kristoffer Plagborg Bak Sørensen 8 months ago
parent 6c6607e · commit 9789b27
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml11
-rw-r--r--runtime/queries/properties/highlights.scm40
-rw-r--r--runtime/queries/properties/injections.scm2
-rw-r--r--runtime/queries/properties/locals.scm5
-rw-r--r--runtime/queries/properties/textobjects.scm4
6 files changed, 63 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 4f1191b3..0df25dc9 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -184,6 +184,7 @@
| powershell | ✓ | | | |
| prisma | ✓ | ✓ | | `prisma-language-server` |
| prolog | ✓ | | ✓ | `swipl` |
+| properties | ✓ | ✓ | | |
| protobuf | ✓ | ✓ | ✓ | `buf`, `pb`, `protols` |
| prql | ✓ | | | |
| pug | ✓ | | | |
diff --git a/languages.toml b/languages.toml
index 032fbc0b..55584791 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4450,3 +4450,14 @@ auto-format = true
[[grammar]]
name = "caddyfile"
source = { git = "https://github.com/caddyserver/tree-sitter-caddyfile", rev = "b04bdb4ec53e40c44afbf001e15540f60a296aef" }
+
+[[language]]
+name = "properties"
+scope = "source.properties"
+injection-regex = "properties"
+file-types = ["properties", "prefs"]
+comment-tokens = ["#"]
+
+[[grammar]]
+name = "properties"
+source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-properties", rev = "579b62f5ad8d96c2bb331f07d1408c92767531d9" }
diff --git a/runtime/queries/properties/highlights.scm b/runtime/queries/properties/highlights.scm
new file mode 100644
index 00000000..d3c6ed79
--- /dev/null
+++ b/runtime/queries/properties/highlights.scm
@@ -0,0 +1,40 @@
+(comment) @comment
+
+(key) @attribute
+
+(value) @string
+
+(value (escape) @constant.character.escape)
+
+((index) @constant.numeric.integer
+ (#match? @constant.numeric.integer "^[0-9]+$"))
+
+((substitution (key) @constant)
+ (#match? @constant "^[A-Z0-9_]+"))
+
+((value) @constant.builtin.boolean
+ (#any-of? @constant.builtin.boolean "true" "false" "enabled" "disabled"))
+
+((value) @constant.numeric.integer
+ (#match? @constant.numeric.integer "^-?[0-9]+$"))
+
+((value) @constant.numeric.float
+ (#match? @constant.numeric.float "^-?[0-9]+\.[0-9]$"))
+
+((value) @string.special.path
+ (#match? @string.special.path "^(\.{1,2})?/"))
+
+(substitution
+ (key) @function
+ "::" @punctuation.special
+ (secret) @string.special.symbol)
+
+(property [ "=" ":" ] @keyword.operator)
+
+[ "${" "}" ] @punctuation.special
+
+(substitution ":" @punctuation.special)
+
+[ "[" "]" ] @punctuation.bracket
+
+[ "." "\\" ] @punctuation.delimiter
diff --git a/runtime/queries/properties/injections.scm b/runtime/queries/properties/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/properties/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/properties/locals.scm b/runtime/queries/properties/locals.scm
new file mode 100644
index 00000000..7a07220d
--- /dev/null
+++ b/runtime/queries/properties/locals.scm
@@ -0,0 +1,5 @@
+(property
+ (key) @local.definition.attribute)
+
+(substitution
+ (key) @local.reference)
diff --git a/runtime/queries/properties/textobjects.scm b/runtime/queries/properties/textobjects.scm
new file mode 100644
index 00000000..9be538ac
--- /dev/null
+++ b/runtime/queries/properties/textobjects.scm
@@ -0,0 +1,4 @@
+(comment) @comment.inside
+(comment)+ @comment.around
+
+(property (key) @parameter.inside) @parameter.around