Add queries for syntax highlighting (#12)

* Add queries for syntax highlighting

* 🔥 property sheets
This commit is contained in:
Max Brunsfeld 2019-10-17 15:04:35 -07:00 committed by GitHub
parent d99b24e035
commit 47841b3f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 235 deletions

View File

@ -29,7 +29,6 @@
"file-types": [
"html"
],
"highlights": "src/highlights.json",
"injection-regex": "html"
}
]

View File

@ -1,26 +0,0 @@
@import "./injections.css";
tag_name {
highlight: 'tag';
}
/* TODO - highlight as an error? */
erroneous_end_tag_name {
highlight: 'tag';
}
doctype {
highlight: 'constant';
}
attribute_name {
highlight: 'attribute';
}
attribute_value {
highlight: 'string';
}
comment {
highlight: 'comment';
}

View File

@ -1,9 +0,0 @@
script_element {
injection-language: 'javascript';
injection-content: child(this(), 1);
}
style_element {
injection-language: 'css';
injection-content: child(this(), 1);
}

10
queries/highlights.scm Normal file
View File

@ -0,0 +1,10 @@
(tag_name) @tag
(erroneous_end_tag_name) @tag.error
(doctype) @constant
(attribute_name) @attribute
(attribute_value) @string
(comment) @comment
"<" @punctuation.bracket
">" @punctuation.bracket
"</" @punctuation.bracket

7
queries/injections.scm Normal file
View File

@ -0,0 +1,7 @@
((script_element
(raw_text) @injection.content) @injection.site
(set! injection.language "javascript"))
((style_element
(raw_text) @injection.content) @injection.site
(set! injection.language "css"))

View File

@ -1,137 +0,0 @@
{
"states": [
{
"id": 0,
"property_set_id": 0,
"transitions": [
{
"type": "comment",
"named": true,
"state_id": 1
},
{
"type": "attribute_value",
"named": true,
"state_id": 2
},
{
"type": "attribute_name",
"named": true,
"state_id": 3
},
{
"type": "doctype",
"named": true,
"state_id": 4
},
{
"type": "erroneous_end_tag_name",
"named": true,
"state_id": 5
},
{
"type": "tag_name",
"named": true,
"state_id": 5
},
{
"type": "style_element",
"named": true,
"state_id": 6
},
{
"type": "script_element",
"named": true,
"state_id": 7
}
],
"default_next_state_id": 0
},
{
"id": 1,
"property_set_id": 1,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 2,
"property_set_id": 2,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 3,
"property_set_id": 3,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 4,
"property_set_id": 4,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 5,
"property_set_id": 5,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 6,
"property_set_id": 6,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 7,
"property_set_id": 7,
"transitions": [],
"default_next_state_id": 0
}
],
"property_sets": [
{},
{
"highlight": "comment"
},
{
"highlight": "string"
},
{
"highlight": "attribute"
},
{
"highlight": "constant"
},
{
"highlight": "tag"
},
{
"injection-content": {
"args": [
{
"args": [],
"name": "this"
},
1
],
"name": "child"
},
"injection-language": "css"
},
{
"injection-content": {
"args": [
{
"args": [],
"name": "this"
},
1
],
"name": "child"
},
"injection-language": "javascript"
}
]
}

View File

@ -1,62 +0,0 @@
{
"states": [
{
"id": 0,
"property_set_id": 0,
"transitions": [
{
"type": "style_element",
"named": true,
"state_id": 1
},
{
"type": "script_element",
"named": true,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 1,
"property_set_id": 1,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 2,
"property_set_id": 2,
"transitions": [],
"default_next_state_id": 0
}
],
"property_sets": [
{},
{
"injection-content": {
"args": [
{
"args": [],
"name": "this"
},
1
],
"name": "child"
},
"injection-language": "css"
},
{
"injection-content": {
"args": [
{
"args": [],
"name": "this"
},
1
],
"name": "child"
},
"injection-language": "javascript"
}
]
}