Add highlight query, remove property sheet

This commit is contained in:
Max Brunsfeld 2019-10-17 16:58:00 -07:00
parent 62903d8915
commit 827ebad900
4 changed files with 64 additions and 625 deletions

View File

@ -23,8 +23,7 @@
{ {
"scope": "source.css", "scope": "source.css",
"file-types": ["css"], "file-types": ["css"],
"injection-regex": "^css$", "injection-regex": "^css$"
"highlights": "src/highlights.json"
} }
] ]
} }

View File

@ -1,120 +0,0 @@
@schema "tree-sitter-highlight-schema";
comment {
highlight: 'comment';
}
tag_name,
nesting_selector,
universal_selector {
highlight: 'tag';
}
sibling_selector > [token="~"],
child_selector > [token=">"],
adjacent_sibling_selector > [token="+"] {
highlight: 'operator';
}
attribute_selector > {
& > [token="="],
& > [token="^="],
& > [token="|="],
& > [token="~="],
& > [token="$="],
& > [token="*="] {
highlight: 'operator';
}
}
attribute_selector > plain_value {
highlight: 'string';
}
pseudo_element_selector > tag_name,
pseudo_class_selector > class_name {
highlight: 'attribute';
}
class_name {
highlight: 'property';
}
id_name {
highlight: 'property';
}
namespace_name {
highlight: 'property';
}
function_name {
highlight: 'function';
}
property_name,
plain_value {
&[text='^--'] {
highlight: 'variable';
}
}
property_name {
highlight: 'property';
}
attribute_name {
highlight: 'attribute';
}
[token="@media"],
[token="@import"],
[token="@charset"],
[token="@namespace"],
[token="@supports"],
[token="@keyframes"],
at_keyword,
to,
from,
important {
highlight: 'keyword';
}
string_value {
highlight: 'string';
}
color_value {
highlight: 'string.special';
}
integer_value,
float_value {
highlight: 'number';
& > unit {
highlight: 'type';
}
}
feature_name {
highlight: 'property';
}
color_value > [token="#"],
id_selector > [token="#"],
selectors > [token=","] {
highlight: 'punctuation.delimiter';
}
[token="and"],
[token="or"],
[token="not"],
[token="only"],
keyword_query,
binary_expression > [token="+"],
binary_expression > [token="-"],
binary_expression > [token="/"],
binary_expression > [token="*"] {
highlight: 'operator';
}

63
queries/highlights.scm Normal file
View File

@ -0,0 +1,63 @@
(comment) @comment
(tag_name) @tag
(nesting_selector) @tag
(universal_selector) @tag
"~" @operator
">" @operator
"+" @operator
"-" @operator
"*" @operator
"/" @operator
"=" @operator
"^=" @operator
"|=" @operator
"~=" @operator
"$=" @operator
"*=" @operator
"and" @operator
"or" @operator
"not" @operator
"only" @operator
(attribute_selector (plain_value) @string)
(pseudo_element_selector (tag_name) @attribute)
(pseudo_class_selector (class_name) @attribute)
(class_name) @property
(id_name) @property
(namespace_name) @property
(property_name) @property
(feature_name) @property
(attribute_name) @attribute
(function_name) @function
((property_name) @variable
(match? @variable "^--"))
((plain_value) @variable
(match? @variable "^--"))
"@media" @keyword
"@import" @keyword
"@charset" @keyword
"@namespace" @keyword
"@supports" @keyword
"@keyframes" @keyword
(at_keyword) @keyword
(to) @keyword
(from) @keyword
(important) @keyword
(string_value) @string
(color_value) @string.special
(integer_value) @number
(float_value) @number
(unit) @type
"#" @punctuation.delimiter
"," @punctuation.delimiter

503
src/highlights.json vendored
View File

@ -1,503 +0,0 @@
{
"states": [
{
"id": 0,
"property_set_id": 0,
"transitions": [
{
"type": "plain_value",
"named": true,
"text": "^--",
"state_id": 1
},
{
"type": "property_name",
"named": true,
"text": "^--",
"state_id": 1
},
{
"type": "and",
"named": false,
"state_id": 2
},
{
"type": "binary_expression",
"named": true,
"state_id": 3
},
{
"type": "keyword_query",
"named": true,
"state_id": 2
},
{
"type": "not",
"named": false,
"state_id": 2
},
{
"type": "only",
"named": false,
"state_id": 2
},
{
"type": "or",
"named": false,
"state_id": 2
},
{
"type": "color_value",
"named": true,
"state_id": 4
},
{
"type": "id_selector",
"named": true,
"state_id": 5
},
{
"type": "selectors",
"named": true,
"state_id": 6
},
{
"type": "feature_name",
"named": true,
"state_id": 7
},
{
"type": "float_value",
"named": true,
"state_id": 8
},
{
"type": "integer_value",
"named": true,
"state_id": 8
},
{
"type": "string_value",
"named": true,
"state_id": 9
},
{
"type": "@charset",
"named": false,
"state_id": 10
},
{
"type": "@import",
"named": false,
"state_id": 10
},
{
"type": "@keyframes",
"named": false,
"state_id": 10
},
{
"type": "@media",
"named": false,
"state_id": 10
},
{
"type": "@namespace",
"named": false,
"state_id": 10
},
{
"type": "@supports",
"named": false,
"state_id": 10
},
{
"type": "at_keyword",
"named": true,
"state_id": 10
},
{
"type": "from",
"named": true,
"state_id": 10
},
{
"type": "important",
"named": true,
"state_id": 10
},
{
"type": "to",
"named": true,
"state_id": 10
},
{
"type": "attribute_name",
"named": true,
"state_id": 11
},
{
"type": "property_name",
"named": true,
"state_id": 7
},
{
"type": "function_name",
"named": true,
"state_id": 12
},
{
"type": "namespace_name",
"named": true,
"state_id": 7
},
{
"type": "id_name",
"named": true,
"state_id": 7
},
{
"type": "class_name",
"named": true,
"state_id": 7
},
{
"type": "pseudo_class_selector",
"named": true,
"state_id": 13
},
{
"type": "pseudo_element_selector",
"named": true,
"state_id": 14
},
{
"type": "attribute_selector",
"named": true,
"state_id": 15
},
{
"type": "adjacent_sibling_selector",
"named": true,
"state_id": 16
},
{
"type": "child_selector",
"named": true,
"state_id": 17
},
{
"type": "sibling_selector",
"named": true,
"state_id": 18
},
{
"type": "nesting_selector",
"named": true,
"state_id": 19
},
{
"type": "tag_name",
"named": true,
"state_id": 19
},
{
"type": "universal_selector",
"named": true,
"state_id": 19
},
{
"type": "comment",
"named": true,
"state_id": 20
}
],
"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": 0,
"transitions": [
{
"type": "*",
"named": false,
"state_id": 2
},
{
"type": "+",
"named": false,
"state_id": 2
},
{
"type": "-",
"named": false,
"state_id": 2
},
{
"type": "/",
"named": false,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 4,
"property_set_id": 3,
"transitions": [
{
"type": "#",
"named": false,
"state_id": 21
}
],
"default_next_state_id": 0
},
{
"id": 5,
"property_set_id": 0,
"transitions": [
{
"type": "#",
"named": false,
"state_id": 21
}
],
"default_next_state_id": 0
},
{
"id": 6,
"property_set_id": 0,
"transitions": [
{
"type": ",",
"named": false,
"state_id": 21
}
],
"default_next_state_id": 0
},
{
"id": 7,
"property_set_id": 4,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 8,
"property_set_id": 5,
"transitions": [
{
"type": "unit",
"named": true,
"state_id": 22
}
],
"default_next_state_id": 0
},
{
"id": 9,
"property_set_id": 6,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 10,
"property_set_id": 7,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 11,
"property_set_id": 8,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 12,
"property_set_id": 9,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 13,
"property_set_id": 0,
"transitions": [
{
"type": "class_name",
"named": true,
"state_id": 11
}
],
"default_next_state_id": 0
},
{
"id": 14,
"property_set_id": 0,
"transitions": [
{
"type": "tag_name",
"named": true,
"state_id": 11
}
],
"default_next_state_id": 0
},
{
"id": 15,
"property_set_id": 0,
"transitions": [
{
"type": "plain_value",
"named": true,
"state_id": 9
},
{
"type": "$=",
"named": false,
"state_id": 2
},
{
"type": "*=",
"named": false,
"state_id": 2
},
{
"type": "=",
"named": false,
"state_id": 2
},
{
"type": "^=",
"named": false,
"state_id": 2
},
{
"type": "|=",
"named": false,
"state_id": 2
},
{
"type": "~=",
"named": false,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 16,
"property_set_id": 0,
"transitions": [
{
"type": "+",
"named": false,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 17,
"property_set_id": 0,
"transitions": [
{
"type": ">",
"named": false,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 18,
"property_set_id": 0,
"transitions": [
{
"type": "~",
"named": false,
"state_id": 2
}
],
"default_next_state_id": 0
},
{
"id": 19,
"property_set_id": 10,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 20,
"property_set_id": 11,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 21,
"property_set_id": 12,
"transitions": [],
"default_next_state_id": 0
},
{
"id": 22,
"property_set_id": 13,
"transitions": [],
"default_next_state_id": 0
}
],
"property_sets": [
{},
{
"highlight": "variable"
},
{
"highlight": "operator"
},
{
"highlight": "string.special"
},
{
"highlight": "property"
},
{
"highlight": "number"
},
{
"highlight": "string"
},
{
"highlight": "keyword"
},
{
"highlight": "attribute"
},
{
"highlight": "function"
},
{
"highlight": "tag"
},
{
"highlight": "comment"
},
{
"highlight": "punctuation.delimiter"
},
{
"highlight": "type"
}
]
}