Skip to content

Commit

Permalink
chore: Enable comment commands feature [release] (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrydowning authored Sep 15, 2024
1 parent cd873b1 commit 7ad5050
Show file tree
Hide file tree
Showing 6 changed files with 7,757 additions and 57 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

## [1.2.0] - 2024-09-15

### Added

- Ability to highlight all blocks from a point onwards
- Comment snippet
- Feature & settings documentation

Expand All @@ -19,7 +22,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Added

- Ability highlight all blocks from a point onwards
- Ability to highlight all blocks from a point onwards

## [1.0.6] - 2024-09-12

Expand Down Expand Up @@ -160,7 +163,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Highlighting support for 40 languages in YAML block-scalars

[unreleased]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.0.6...HEAD
[unreleased]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.2.0...HEAD
[1.2.0]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.0.6...v1.1.0
[1.0.6]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/harrydowning/vscode-yaml-embedded-languages/compare/v1.0.4...v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yaml-embedded-languages",
"version": "1.1.0",
"version": "1.2.0",
"displayName": "YAML Embedded Languages",
"description": "Support for syntax highlighting within YAML block-scalars.",
"icon": "images/icon.png",
Expand Down
96 changes: 44 additions & 52 deletions src/injection-grammar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import packageJson from "@package";
import { Languages, PRE_RELEASE } from "./constants";
import { Languages } from "./constants";
import { Writable } from "./writable";

export class InjectionGrammar extends Writable {
Expand All @@ -17,58 +17,51 @@ export class InjectionGrammar extends Writable {

#getPatterns() {
const entries = Object.entries(this.languages);
const patterns = [];

if (PRE_RELEASE) {
patterns.push(
{
begin: `#\\s*${packageJson.name}\\s*$`,
beginCaptures: {
0: { name: "entity.name.type.yaml" },
},
patterns: [{ include: this.injectionScopeName }],
const patterns = [
{
begin: `#\\s*${packageJson.name}\\s*$`,
beginCaptures: {
0: { name: "entity.name.type.yaml" },
},
...entries.map(([id, { scopeName, stripIndent }]) => ({
begin: `#\\s*${packageJson.name}\\s*:\\s*${id}\\s*$`,
beginCaptures: {
0: { name: "entity.name.type.yaml" },
},
patterns: [
{
begin: `(?i)(?:(\\|)|(>))([1-9])?([-+])?(.*)\\s*$`,
beginCaptures: {
1: { name: "keyword.control.flow.block-scalar.literal.yaml" },
2: { name: "keyword.control.flow.block-scalar.folded.yaml" },
3: { name: "constant.numeric.indentation-indicator.yaml" },
4: { name: "storage.modifier.chomping-indicator.yaml" },
5: {
patterns: [
{ include: `${this.injectionScopeName}#comment` },
{
match: ".+",
name: "invalid.illegal.expected-comment-or-newline.yaml",
},
],
},
patterns: [{ include: this.injectionScopeName }],
},
...entries.map(([id, { scopeName, stripIndent }]) => ({
begin: `#\\s*${packageJson.name}\\s*:\\s*${id}\\s*$`,
beginCaptures: {
0: { name: "entity.name.type.yaml" },
},
patterns: [
{
begin: `(?i)(?:(\\|)|(>))([1-9])?([-+])?(.*)\\s*$`,
beginCaptures: {
1: { name: "keyword.control.flow.block-scalar.literal.yaml" },
2: { name: "keyword.control.flow.block-scalar.folded.yaml" },
3: { name: "constant.numeric.indentation-indicator.yaml" },
4: { name: "storage.modifier.chomping-indicator.yaml" },
5: {
patterns: [
{ include: `${this.injectionScopeName}#comment` },
{
match: ".+",
name: "invalid.illegal.expected-comment-or-newline.yaml",
},
],
},
end: "^(?=\\S)|(?!\\G)",
patterns: [
{
begin: "(?>^|\\G)([ ]+)(?! )",
end: "^(?!\\1|\\s*$)",
while: stripIndent ? "^$|\\1" : undefined,
name: `${this.embeddedScopeNamePrefix}.${id}`,
patterns: [{ include: scopeName }],
},
],
},
{ include: this.injectionScopeName },
],
})),
);
}

patterns.push(
end: "^(?=\\S)|(?!\\G)",
patterns: [
{
begin: "(?>^|\\G)([ ]+)(?! )",
end: "^(?!\\1|\\s*$)",
while: stripIndent ? "^$|\\1" : undefined,
name: `${this.embeddedScopeNamePrefix}.${id}`,
patterns: [{ include: scopeName }],
},
],
},
{ include: this.injectionScopeName },
],
})),
...entries.map(([id, { scopeName, stripIndent }]) => ({
begin: `(?i)(?:(\\|)|(>))([1-9])?([-+])?\\s+(#\\s*(?:${id})\\s*)$`,
beginCaptures: {
Expand All @@ -89,8 +82,7 @@ export class InjectionGrammar extends Writable {
},
],
})),
);

];
return patterns;
}

Expand Down
Loading

0 comments on commit 7ad5050

Please sign in to comment.