Improvements (#6)

* Add more tokens coloring

* Repurpose several token types

* Make it easier for users to change highlighting in settings

* Better align of types highlighting with popular languages token scheme

* Better rules arrangement and addition of comments

* Update readme
This commit is contained in:
Pavel 2021-06-01 13:57:57 +03:00 committed by GitHub
parent e756255578
commit bdb97b1788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 11 deletions

View File

@ -1,6 +1,34 @@
# aqua syntax highliting
# aqua syntax highlighting
Syntax highlighting for `aqua` programming language
## Installation
1. Install the extension
2. Configure colors for aqua-specific tokens (see below)
Add the following lines to the [settings.json](https://code.visualstudio.com/docs/getstarted/settings) file. Feel free to choose colors according to you favorite theme. In the example below services will be highlighted as green and all the keywords which affect the topology will be highlighted as red
```json
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.topology.aqua",
"settings": {
"foreground": "#FF0000",
}
},
{
"scope": "support.service.aqua",
"settings": {
"foreground": "#00FF00",
}
}
]
}
```
Syntax highliting for `aqua` programming language
## What is aqua?
@ -12,7 +40,7 @@ Aqua's runtime is heterogeneous: it includes browsers, servers, devices, all inv
## Features
Enables syntax highliting for `aqua` programming language
Enables syntax highlighting for `aqua` programming language
## Developing
@ -20,4 +48,4 @@ see [vsc-extension-quickstart.md](vsc-extension-quickstart.md)
## License
[Apache 2.0](LICENSE)
[Apache 2.0](LICENSE)

View File

@ -5,6 +5,9 @@
{
"include": "#keywords"
},
{
"include": "#constants"
},
{
"include": "#strings"
},
@ -19,23 +22,43 @@
"keywords": {
"patterns": [
{
"name": "keyword.control.aqua",
"match": "\\b(if|else|otherwise|use|try|catch|on|via|for|par|use|<-)\\b"
"name": "keyword.control.flow.aqua",
"match": "\\b(try|catch|par|if|else|otherwise|for)\\b"
},
{
"name": "keyword.control.other.aqua",
"match": "(<-|->|\\[\\]|\\*|\\?\\=|\\?)"
},
{
"name": "keyword.topology.aqua",
"match": "\\b(on|via|use|func|service|data|alias)\\b"
},
{
"name": "keyword.operator.logical.aqua",
"match": "\\b(eqs|neq)\\b"
},
{
"name": "keyword.declaration.aqua",
"match": "\\b(func|service|data|alias)\\b"
},
{
"name": "keyword.control.import",
"match": "\\b(import)\\b"
}
]
},
"constants": {
"patterns": [
{
"name": "constant.language.other.aqua",
"match": "%init_peer_id%"
},
{
"name": "constant.numeric.aqua",
"match": "\\b\\d+\\b"
},
{
"name": "constant.language.boolean.aqua",
"match": "\\b(true|false)\\b"
}
]
},
"strings": {
"name": "string.quoted.double.aqua",
"begin": "\"",
@ -55,8 +78,28 @@
"semantics": {
"patterns": [
{
"name": "storage.type.aqua",
"name": "support.type.primitive.aqua",
"match": "\\b(string|bool|u8|u16|u32|u64|s8|s16|s32|s64|f32|f64)\\b"
},
{
"//": "Defines tokens for data types in Aqua (declaration). Tokens are expected to have colon after them (`data Something:`)",
"name": "entity.name.type.struct.aqua",
"match": "\\b[A-Z][A-Za-z0-9_]+(?=:)"
},
{
"//": "Defines tokens for data types in Aqua (usage). Data types in aqua start with a captial letter and are followed by any space char.",
"name": "support.class.aqua",
"match": "\\b[A-Z][A-Za-z0-9_]+(?=\\s)"
},
{
"//": "Defines tokens for service methods calls. Token is located between dot and open bracket",
"name": "support.variable.method.aqua",
"match": "(?<=\\.)[a-z0-9_]+(?=\\()"
},
{
"//": "Defines tokens for service names both in declaration and in usage. Token starts with a capital letter and is followed by either dot (service usage) or open bracket (service declaratiokn)",
"name": "support.service.aqua",
"match": "\\b[A-Z][A-Za-z0-9_]+(?=[\\(\\.])"
}
]
}