Skip to content

chore: add vscode highlight extension #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@typescript-eslint/quotes": "off",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/no-explicit-any": "off",
"arrow-body-style": "error",
"arrow-body-style": "off",
"brace-style": ["error", "1tbs"],
"curly": "error",
"eol-last": "error",
Expand Down
2 changes: 2 additions & 0 deletions projects/vscode-atl-render/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set default behavior to automatically normalize line endings.
* text=auto
2 changes: 2 additions & 0 deletions projects/vscode-atl-render/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.vsix
17 changes: 17 additions & 0 deletions projects/vscode-atl-render/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
4 changes: 4 additions & 0 deletions projects/vscode-atl-render/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
7 changes: 7 additions & 0 deletions projects/vscode-atl-render/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change Log

All notable changes to the "vscode-testing-library-render" extension will be documented in this file.

## 0.0.1

- Initial release
3 changes: 3 additions & 0 deletions projects/vscode-atl-render/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# vscode-atl-render

[Download link](https://marketplace.visualstudio.com/manage/publishers/timdeschryver/extensions/vscode-atl-render/hub?_a=acquisition)
30 changes: 30 additions & 0 deletions projects/vscode-atl-render/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"comments": {
"blockComment": ["<!--", "-->"]
},
"brackets": [
["<!--", "-->"],
["<", ">"],
["{", "}"],
["(", ")"],
["[", "]"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "'", "close": "'" },
{ "open": "\"", "close": "\"" },
{ "open": "<!--", "close": "-->", "notIn": ["comment", "string"] },
{ "open": "/**", "close": "*/", "notIn": ["string"] }
],
"surroundingPairs": [
{ "open": "'", "close": "'" },
{ "open": "\"", "close": "\"" },
{ "open": "`", "close": "`" },
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "<", "close": ">" }
]
}
46 changes: 46 additions & 0 deletions projects/vscode-atl-render/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "vscode-atl-render",
"displayName": "vscode-atl-render",
"description": "HTML highlighting in ATL the render method",
"version": "0.0.1",
"publisher": "timdeschryver",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/testing-library/angular-testing-library.git"
},
"homepage": "https://github.com/testing-library/angular-testing-library/blob/main/README.md",
"engines": {
"vscode": "^1.57.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"configuration": [
{
"id": "atl-render",
"title": "Angular Testing Library Render",
"properties": {
"atl-render.format.enabled": {
"type": "boolean",
"description": "Enable/disable formatting of render template strings.",
"default": true
}
}
}
],
"grammars": [
{
"scopeName": "atl.render",
"path": "./syntaxes/atl-render.json",
"injectTo": [
"source.ts"
],
"embeddedLanguages": {
"text.html": "html"
}
}
]
}
}
59 changes: 59 additions & 0 deletions projects/vscode-atl-render/syntaxes/atl-render.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"scopeName": "atl.render",
"injectionSelector": "L:source.ts -comment -(string -text.html)",
"name": "atl.render",
"patterns": [
{
"include": "#renderMethod"
}
],
"repository": {
"renderMethod": {
"name": "renderMethod",
"begin": "(?x)(\\b(?:\\w+\\.)*(?:render)\\s*)(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.ts"
},
"2": {
"name": "meta.brace.round.ts"
}
},
"end": "(\\))",
"endCaptures": {
"0": {
"name": "meta.brace.round.ts"
}
},
"patterns": [
{
"include": "#renderTemplate"
}
]
},
"renderTemplate": {
"contentName": "text.html",
"begin": "\\G\\s*([`|'|\"])",
Copy link
Contributor

@lacolaco lacolaco Jun 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it disallows line breaks between render( and the arguments.

Note that the regular expressions are matched against only a single line of the document at a time. That means it is not possible to use a pattern that matches multiple lines. The reason for this is technical: being able to restart the parser at an arbitrary line and having to re-parse only the minimal number of lines affected by an edit. In most situations it is possible to use the begin/end model to overcome this limitation.

https://macromates.com/manual/en/language_grammars

How about just

([`|'|\"])

?

BTW, inline-template.ng also disallows line breaks.
image

Copy link
Contributor

@lacolaco lacolaco Jun 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\\G is "matching start position", so maybe it means \\G is the same line of render(.

"beginCaptures": {
"1": {
"name": "string"
}
},
"end": "\\1",
"endCaptures": {
"0": {
"name": "string"
}
},
"patterns": [
{
"include": "text.html.derivative"
},
{
"include": "template.ng"
}
]
}
}
}