diff --git a/.gitmodules b/.gitmodules index ae2b9e6..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "syntaxes"] - path = syntaxes - url = https://github.com/textualize/tcss-textmate-grammar diff --git a/.vscode/settings.json b/.vscode/settings.json index 30bf8c2..2d208bc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,6 @@ "out": true // set this to false to include "out" folder in search results }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts - "typescript.tsc.autoDetect": "off" -} \ No newline at end of file + "typescript.tsc.autoDetect": "off", + "editor.fontLigatures": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 89db75b..f3f4a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log -## [0.1.0] + +## 0.2.0 + +- Add highlighting for all types of values +- Add highlighting for variable use and assignment + +## 0.1.0 - Initial release diff --git a/README.md b/README.md index a8bc0d0..1713252 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,16 @@ Does syntax highlighting for Textual CSS files (files with the extension `.tcss`). ![A view of a highlighted file.](./tcss.png) -## Known Issues -This extension does not support highlighting variables or selectors. + +## Grammar dependency + +This extension uses the grammar `tcss.tmGrammar.json` that is converted from the YAML grammar in the [TCSS TextMate grammar repository](https://github.com/Textualize/tcss-textmate-grammar). +To convert the YAML grammar into this JSON grammar, use + +```bash +npx js-yaml ../tcss-textmate-grammar/grammar.yaml > syntaxes/tcss.tmGrammar.json +``` ## Release Notes diff --git a/package-lock.json b/package-lock.json index 8c54d9d..9ca2462 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "first-highlighter", - "version": "0.0.1", + "name": "textual-css-syntax-highlighter", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "first-highlighter", - "version": "0.0.1", + "name": "textual-css-syntax-highlighter", + "version": "0.1.0", "devDependencies": { "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", @@ -17,6 +17,7 @@ "@vscode/test-electron": "^2.3.2", "eslint": "^8.41.0", "glob": "^8.1.0", + "js-yaml": "^4.1.0", "mocha": "^10.2.0", "typescript": "^5.1.3" }, diff --git a/package.json b/package.json index fb8fb25..97272f9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "languages": [ { "id": "Textual CSS", - "extensions": [".tcss"] + "extensions": [ + ".tcss" + ] } ], "grammars": [ @@ -38,16 +40,17 @@ "test": "node ./out/test/runTest.js" }, "devDependencies": { - "@types/vscode": "^1.79.0", "@types/glob": "^8.1.0", "@types/mocha": "^10.0.1", "@types/node": "20.2.5", + "@types/vscode": "^1.79.0", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.59.8", + "@vscode/test-electron": "^2.3.2", "eslint": "^8.41.0", "glob": "^8.1.0", + "js-yaml": "^4.1.0", "mocha": "^10.2.0", - "typescript": "^5.1.3", - "@vscode/test-electron": "^2.3.2" + "typescript": "^5.1.3" } } diff --git a/syntaxes b/syntaxes deleted file mode 160000 index 0d74784..0000000 --- a/syntaxes +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0d74784f44ee6fd225ccc21f7665fc22b3d22876 diff --git a/syntaxes/tcss.tmGrammar.json b/syntaxes/tcss.tmGrammar.json new file mode 100644 index 0000000..aa91bdc --- /dev/null +++ b/syntaxes/tcss.tmGrammar.json @@ -0,0 +1,371 @@ +{ + "scopeName": "source.tcss", + "name": "Textual CSS", + "fileTypes": [ + "tcss" + ], + "patterns": [ + { + "include": "#comment-block" + }, + { + "include": "#comment-line" + }, + { + "include": "#combinators" + }, + { + "include": "#selector" + }, + { + "include": "#rule-list" + }, + { + "include": "#variable-definition" + } + ], + "repository": { + "color-keywords": { + "patterns": [ + { + "match": "(?", + "name": "keyword.operator.combinator.tcss" + } + ] + }, + "commas": { + "patterns": [ + { + "match": ",", + "name": "punctuation.separator.list.comma.tcss" + } + ] + }, + "comment-block": { + "begin": "/\\*", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin.tcss" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end.tcss" + } + }, + "name": "comment.block.tcss" + }, + "comment-line": { + "begin": "\\# ", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin.tcss" + } + }, + "end": "$", + "name": "comment.line.tcss" + }, + "functions": { + "begin": "(?]|/\\*|# ))(?:[-a-zA-Z_0-9])*", + "name": "invalid.illegal.bad-identifier.tcss" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.entity.tcss" + } + }, + "match": "(\\.)(?:[-a-zA-Z_0-9])+(?=$|[\\s,.\\#:{>]|/\\*|# )", + "name": "entity.other.attribute-name.class.css" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.entity.tcss" + } + }, + "match": "(\\#)(?:[-a-zA-Z0-9])+(?=$|[\\s,.\\#:{>]|/\\*|# )", + "name": "entity.other.attribute-name.id.tcss" + }, + { + "include": "#pseudo-classes" + }, + { + "match": "(?