Merge pull request #3 from tree-sitter/highlighting-properties

Add property sheet for syntax highlighting
This commit is contained in:
Max Brunsfeld 2019-03-12 12:31:42 -07:00 committed by GitHub
commit 339e040a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11528 additions and 6242 deletions

View File

@ -13,7 +13,7 @@ install:
- npm install - npm install
test_script: test_script:
- npm test - npm run test-windows
build: off build: off

View File

@ -13,9 +13,18 @@
"nan": "^2.11.1" "nan": "^2.11.1"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.13.10" "tree-sitter-cli": "^0.14.5"
}, },
"scripts": { "scripts": {
"test": "tree-sitter test && tree-sitter parse examples --quiet --time" "test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time",
} "test-windows": "tree-sitter test"
},
"tree-sitter": [
{
"scope": "source.css",
"file-types": ["css"],
"injection-regex": "^css$",
"highlights": "src/highlights.json"
}
]
} }

140
properties/highlights.css Normal file
View File

@ -0,0 +1,140 @@
@schema "tree-sitter-highlight-schema";
comment {
scope: 'comment';
}
tag_name,
nesting_selector,
universal_selector {
scope: 'tag';
}
sibling_selector > [token="~"],
child_selector > [token=">"],
adjacent_sibling_selector > [token="+"] {
scope: 'operator';
}
attribute_selector > {
& > [token="="],
& > [token="^="],
& > [token="|="],
& > [token="~="],
& > [token="$="],
& > [token="*="] {
scope: 'operator';
}
}
attribute_selector > plain_value {
scope: 'string';
}
pseudo_element_selector > tag_name,
pseudo_class_selector > class_name {
scope: 'attribute';
}
class_name {
scope: 'property';
}
id_name {
scope: 'property';
}
namespace_name {
scope: 'property';
}
function_name {
scope: 'function';
}
property_name,
plain_value {
&[text='^--'] {
scope: 'variable';
}
}
property_name {
scope: 'property';
}
attribute_name {
scope: 'attribute';
}
[token="@media"],
[token="@import"],
[token="@charset"],
[token="@namespace"],
[token="@supports"],
[token="@keyframes"],
at_keyword,
to,
from,
important {
scope: 'keyword';
}
string_value {
scope: 'string';
}
color_value {
scope: 'string.special';
}
integer_value,
float_value {
scope: 'number';
& > unit {
scope: 'type';
}
}
/* plain_value': [
{match:'^(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)$', scopes:'support.constant.color.w3c-standard'}
{match:'^(aliceblue|antiquewhite|aquamarine|azure|beige|bisque|blanchedalmond|blueviolet|brown|burlywood
|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan
|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange
|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise
|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen
|gainsboro|ghostwhite|gold|goldenrod|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki
|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow
|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray
|lightslategrey|lightsteelblue|lightyellow|limegreen|linen|magenta|mediumaquamarine|mediumblue
|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise
|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|oldlace|olivedrab|orangered
|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum
|powderblue|rebeccapurple|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell
|sienna|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|thistle|tomato
|transparent|turquoise|violet|wheat|whitesmoke|yellowgreen)$', scopes: 'support.constant.color.w3c-extended'}
'support.constant.property-value.css'
] */
feature_name {
scope: 'property';
}
color_value > [token="#"],
id_selector > [token="#"],
selectors > [token=","] {
scope: 'punctuation.delimiter';
}
[token="and"],
[token="or"],
[token="not"],
[token="only"],
keyword_query,
binary_expression > [token="+"],
binary_expression > [token="-"],
binary_expression > [token="/"],
binary_expression > [token="*"] {
scope: 'operator';
}

3
src/grammar.json vendored
View File

@ -1739,4 +1739,5 @@
"_top_level_item", "_top_level_item",
"_block_item" "_block_item"
] ]
} }

5058
src/highlights.json vendored Normal file

File diff suppressed because it is too large Load Diff

12550
src/parser.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ extern "C" {
#define ts_builtin_sym_end 0 #define ts_builtin_sym_end 0
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
#ifndef TREE_SITTER_RUNTIME_H_ #ifndef TREE_SITTER_API_H_
typedef uint16_t TSSymbol; typedef uint16_t TSSymbol;
typedef struct TSLanguage TSLanguage; typedef struct TSLanguage TSLanguage;
#endif #endif