fix highlight

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-07 11:58:45 +03:00
parent 947900f03e
commit 1095c58b33
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
6 changed files with 65 additions and 1951 deletions

View file

@ -3,5 +3,9 @@
test: build
tree-sitter test
highlight:
tree-sitter highlight -t test/highlight/*.d2
build:
tree-sitter generate

View file

@ -1,7 +1,2 @@
a <- b -- b
foo: Hello world {
shape: oval
}
hello world- -- foo
a.shape: oval
b

1943
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,5 +4,14 @@
"description": "",
"main": "grammar.js",
"author": "",
"license": "ISC"
"license": "ISC",
"tree-sitter": [
{
"scope": "source.d2",
"file-types": [
"d2"
],
"injection-regex": "^d2$"
}
]
}

29
queries/highlights.scm Normal file
View file

@ -0,0 +1,29 @@
;-------------------------------------------------------------------------------
(identifier) @variable
(attr_key) @keyword
;-------------------------------------------------------------------------------
(string) @string
(label) @string
(attr_value) @string
;-------------------------------------------------------------------------------
(arrow) @operator
[
(dot)
":"
";"
] @punctuation.delimiter
[
"{"
"}"
] @punctuation.bracket
;-------------------------------------------------------------------------------
(ERROR) @error

20
test/highlight/shape.d2 Normal file
View file

@ -0,0 +1,20 @@
foo.baz.biz
# <- variable
# ^ delimiter
# ^ variable
# ^ delimiter
# ^ variable
foo: Foo Bar
# <- variable
# ^ delimiter
# ^ string
foo: Foo Bar {
# <- variable
# ^ label
bar.baz
# <- variable
# ^ variable
}