languages: create dedicated language for json-ld (#13925)

pull/13922/head
Kristoffer Plagborg Bak Sørensen 2025-07-10 15:49:33 +02:00 committed by GitHub
parent 16d06643a4
commit 8e0f326ebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 1 deletions

View File

@ -120,6 +120,7 @@
| jq | ✓ | ✓ | | `jq-lsp` |
| jsdoc | ✓ | | | |
| json | ✓ | ✓ | ✓ | `vscode-json-language-server` |
| json-ld | ✓ | ✓ | ✓ | `vscode-json-language-server` |
| json5 | ✓ | | | |
| jsonc | ✓ | | ✓ | `vscode-json-language-server` |
| jsonnet | ✓ | | | `jsonnet-language-server` |

View File

@ -514,7 +514,6 @@ file-types = [
"css.map",
{ glob = ".jslintrc" },
"jsonl",
"jsonld",
{ glob = ".vuerc" },
{ glob = "composer.lock" },
{ glob = ".watchmanconfig" },
@ -555,6 +554,17 @@ language-servers = [ "vscode-json-language-server" ]
auto-format = true
indent = { tab-width = 2, unit = " " }
# https://www.w3.org/TR/json-ld/
[[language]]
name = "json-ld"
scope = "source.json-ld"
injection-regex = "json-ld"
grammar = "json"
file-types = ["jsonld"]
language-servers = ["vscode-json-language-server"]
auto-format = true
indent = { tab-width = 2, unit = " " }
[[language]]
name = "json5"
scope = "source.json5"

View File

@ -0,0 +1,43 @@
; inherits: json
; https://www.w3.org/TR/json-ld/#syntax-tokens-and-keywords
((string (string_content) @keyword)
(#any-of? @keyword
"@base"
"@container"
"@context"
"@direction"
"@graph"
"@id"
"@import"
"@included"
"@index"
"@json"
"@language"
"@list"
"@nest"
"@none"
"@prefix"
"@propagate"
"@protected"
"@reverse"
"@set"
"@type"
"@value"
"@version"
"@vocab"))
((pair
value: (string (string_content) @string.special.url))
(#match? @string.special.url "^https?://"))
((array
(string (string_content) @string.special.url))
(#match? @string.special.url "^https?://"))
; https://www.w3.org/TR/json-ld/#dfn-base-direction
((pair
key: (string (string_content) @keyword)
value: (string (string_content) @type.enum.variant))
(#eq? @keyword "@direction")
(#any-of? @type.enum.variant "ltr" "rtl"))

View File

@ -0,0 +1 @@
; inherits: json

View File

@ -0,0 +1 @@
; inherits: json