Skip to content

Commit 8e86d0e

Browse files
committed
Update versions and readmes
1 parent 4bfcbd4 commit 8e86d0e

4 files changed

Lines changed: 63 additions & 10 deletions

File tree

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1-
# NMF Package Generator
1+
# NMF AnyText Generator
22

3-
This [Yeoman](https://yeoman.io) generator is used to create a new [GLSP](https://langium.org/) extension for VS Code.
3+
This [Yeoman](https://yeoman.io) generator is used to create a new [AnyText](https://github.com/NMFCode/NMF/) extension for VS Code. AnyText is a language workbench with an incremental packrat parser supporting left recursions, so you do not have to worry about left recursion or an interaction between lexer and parser when designing your language.
44

5-
Please read the documentation to get started, as soon as this becomes available.
5+
## Prerequisites
6+
7+
AnyText requires a .NET 8 or .NET 9 SDK to be installed. To install it, follow the [instructions](https://github.com/dotnet/core/blob/main/release-notes/9.0/install.md) provided by Microsoft. Then, the generator itself can be installed via NPM. We recommend a systemwide installation.
8+
9+
```bash
10+
npm install generator-anytext --global --save-dev
11+
```
12+
13+
## Using the generator
14+
15+
The code generator scaffolds a new AnyText project. You can start it via the command line as follows:
16+
17+
```bash
18+
yo anytext
19+
```
20+
21+
This will ask you a range of questions, like the name of your language and a repository link. Based on this information, the code generator will generate a new directory with the following artifacts already set up for you:
22+
23+
* An AnyText grammar document with an example grammar
24+
* A file to manually fine-tune editor services for the generated parser
25+
* A C# project that creates an LSP server of your grammar
26+
* A Visual Studio Code extension that integrates the LSP server
27+
* Visual Studio Code launch configurations such that you can easily debug your VS Code extension
28+
29+
These artifacts are set up such that they integrate with each other. For example, the build directory of the LSP server is exactly where the VS Code extension is expecting it. Because the code generator also compiles the sources, you can start the extension straight away. Also, you can immediately use `vsce` to pack your extension into a deployable VSIX file.
30+
31+
The extension project also contains scripts that allow you to easily regenerate the grammar and metamodel code once you did some changes.
32+
33+
## Launching the new extension
34+
35+
Because the code generator produces launch configurations for Visual Studio Code, you can easily start the extension via the *Run and Debug* section of Visual Studio Code when opening the newly created directory in Visual Studio Code.

packages/generator-anytext/templates/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ This folder contains two subdirectories:
1212
To get started with your VS Code Extension, we suggest the following steps:
1313

1414
1. **Create the grammar definition.** To support this task, download the Anytext extension from the marketplace, if you haven't already done so.
15-
2. **Generate the code.** To generate the code, download the code generator as a .NET tool
16-
`dotnet tool install nmf-anytextgen --global`
17-
Afterwards, the code generator can be executed anywhere using `anytextgen`. You can see the documentation how to generate the code using `anytextgen help`.
18-
3. **Adjust the grammar.** The template already contains a manual extension of the generated code. Use this file to override the default behavior of the LSP server and adjust it to your needs.
19-
4. **Debug the extension.** You can start your VS Code extension right from VS Code when opening the *vscode* folder. The template is configured to give you a *Run Extension* launch configuration. Running the extension in debug will pop up a window asking you which Visual Studio window you want to use to debug the LSP server.
15+
2. **Adjust the grammar.** The template already contains a manual extension of the generated code. Use this file to override the default behavior of the LSP server and adjust it to your needs. To generate the code, the generated `package.json` contains two NPM scripts:
16+
* `npm run generate-parser` regenerates the parser. Use this script whenever you make changes to your grammar for these changes to become effective.
17+
* `npm run generate-metamodel` regenerates the metamodel. Use this script whenever you make changes to the abstract syntax of your DSL.
18+
3. **Adjust the editor services.** AnyText is built in such a way that you can easily extend the functionality of the generated language code and extend or customize it. As an example, the template includes a custom code lens and a specification that the abstract syntax element `Person` should be rendered with the symbol kind object. Note that the LSP is strict on the possible symbol kinds, so you have to chose from what LSP provides.
19+
4. **Debug the extension.** You can start your VS Code extension right from VS Code. The template is configured to give you a *Run Extension* launch configuration. Running the extension in debug will pop up a window asking you which Visual Studio (or other IDE) window you want to use to debug the LSP server.
2020
5. **Repeat.** Your grammar will probably not fit all your needs on the first attempt. Repeat the previous steps until you are happy with the result.
2121

2222
## Install your extension
2323

2424
* To start using your extension with VS Code, copy it into the `<user home>/.vscode/extensions` folder and restart Code.
25-
* To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension.
25+
* To share your extension with the world, read the [VS Code documentation](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) about publishing an extension. The extension is already prepared to be packaged using `vsce pack`.
26+
27+
## Troubleshooting
28+
29+
The code generator should already have installed the AnyText code generator as a global .NET tool. If this did not work for some reason, you can install it manually:
30+
31+
`dotnet tool install nmf-anytextgen --global`
32+
33+
Afterwards, the code generator can be executed anywhere using `anytextgen`. You can see the documentation how to generate the code using `anytextgen help`.

packages/generator-anytext/templates/backend/LanguageName.manual.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,20 @@ public partial class PersonRule
88
{
99
public override SymbolKind SymbolKind => SymbolKind.Object;
1010
}
11+
12+
public partial class GreetingRule
13+
{
14+
protected override IEnumerable<CodeLensInfo<Greeting>> CodeLenses
15+
{
16+
get
17+
{
18+
yield return new CodeLensInfo<Greeting>
19+
{
20+
Title = "Greet",
21+
Action = (g, args) => _ = args.ShowNotification($"Hello, {g.Greeted.Name}!")
22+
};
23+
}
24+
}
25+
}
1126
}
1227
}

packages/generator-anytext/templates/backend/LanguageNameLspServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="NMF-AnyText-LSP" Version="2.0.416" />
14+
<PackageReference Include="NMF-AnyText-LSP" Version="2.0.420" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

0 commit comments

Comments
 (0)