From 827ebad9001584c88dc7a6f6b1cd2c692818c37b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 17 Oct 2019 16:58:00 -0700 Subject: [PATCH] Add highlight query, remove property sheet --- package.json | 3 +- properties/highlights.css | 120 --------- queries/highlights.scm | 63 +++++ src/highlights.json | 503 -------------------------------------- 4 files changed, 64 insertions(+), 625 deletions(-) delete mode 100644 properties/highlights.css create mode 100644 queries/highlights.scm delete mode 100644 src/highlights.json diff --git a/package.json b/package.json index cc02de2..d9ab3bc 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,7 @@ { "scope": "source.css", "file-types": ["css"], - "injection-regex": "^css$", - "highlights": "src/highlights.json" + "injection-regex": "^css$" } ] } diff --git a/properties/highlights.css b/properties/highlights.css deleted file mode 100644 index 2104b85..0000000 --- a/properties/highlights.css +++ /dev/null @@ -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'; -} diff --git a/queries/highlights.scm b/queries/highlights.scm new file mode 100644 index 0000000..bda95b0 --- /dev/null +++ b/queries/highlights.scm @@ -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 diff --git a/src/highlights.json b/src/highlights.json deleted file mode 100644 index ac8832b..0000000 --- a/src/highlights.json +++ /dev/null @@ -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" - } - ] -} \ No newline at end of file