Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
70 changes: 42 additions & 28 deletions packages/ide/vscode/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
# ZenStack VS Code Extension
# ZenStack V3 VS Code Extension

[ZenStack](https://zenstack.dev) is a toolkit that simplifies the development of a web app's backend. It enhances [Prisma ORM](https://prisma.io) with flexible Authorization and auto-generated, type-safe APIs/hooks, simplifying full-stack development.
[ZenStack](https://zenstack.dev) is the modern data layer for TypeScript applications. It provides a data modeling language, a type-safe ORM with built-in access control, and other utilities that help you streamline full-stack development. This VS Code extension provides code editing helpers for authoring ZenStack's schema files (`.zmodel` files).

This VS Code extension provides code editing helpers for authoring ZenStack's schema files (.zmodel files).
Use this extension if you are using ZenStack v3.x, otherwise use the [original extension](https://marketplace.visualstudio.com/items?itemName=zenstack.zenstack) that works with v2.x. See [Configuration](#configuration) for how to use both versions side by side.

## Features

- Syntax highlighting of `*.zmodel` files
- Syntax highlighting
- Inline error reporting
- Go-to definition
- Hover documentation
- Code section folding

- In case the schema file is not recognized automatically, add the following to your settings.json file:
## Configuration

```json
"files.associations": {
"*.zmodel": "zmodel"
},
```
### Side by side with the original ZenStack extension

- Auto formatting
If you have the [original ZenStack v2 extension](https://marketplace.visualstudio.com/items?itemName=zenstack.zenstack) installed, it may compete with this extension on handling `.zmodel` files. In this case, add the following settings to your `.vscode/settings.json` file to specify which extension should handle `.zmodel` files.

- To automatically format on save, add the following to your settings.json file:
To let this extension handle `.zmodel` files, add:

```json
"editor.formatOnSave": true
```
```json
"files.associations": {
"*.zmodel": "zmodel-v3"
},
```

- To enable formatting in combination with prettier, add the following to your settings.json file:
```json
"[zmodel]": {
"editor.defaultFormatter": "zenstack.zenstack"
},
```
To let the v2 extension handle `.zmodel` files, add:

- Inline error reporting
- Go-to definition
- Hover documentation
- Code section folding
```json
"files.associations": {
"*.zmodel": "zmodel"
},
```

### Auto formatting

To automatically format on save, add the following to your `.vscode/settings.json` file:

```json
"editor.formatOnSave": true
```

To enable formatting in combination with prettier, add the following to your `.vscode/settings.json` file:

```json
"[zmodel-v3]": {
"editor.defaultFormatter": "zenstack.zenstack-v3"
},
```

## Links

- [Home](https://zenstack.dev)
- [Documentation](https://zenstack.dev/docs)
- [Home](https://zenstack.dev/v3)
- [Documentation](https://zenstack.dev/docs/3.x)
- [Community chat](https://discord.gg/Ykhr738dUe)
- [Twitter](https://twitter.com/zenstackhq)
- [Blog](https://dev.to/zenstack)
- [Blog](https://zenstack.dev/blog)

## Community

Expand Down
18 changes: 9 additions & 9 deletions packages/ide/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "zenstack",
"name": "zenstack-v3",
"publisher": "zenstack",
"version": "3.0.0-alpha.33",
"displayName": "ZenStack Language Tools",
"description": "VSCode extension for ZenStack ZModel language",
"version": "3.0.2",
"displayName": "ZenStack V3 Language Tools",
"description": "VSCode extension for ZenStack (v3) ZModel language",
"private": true,
"repository": {
"type": "git",
Expand All @@ -12,7 +12,7 @@
"scripts": {
"build": "tsc --noEmit && tsup",
"lint": "eslint src --ext ts",
"vscode:publish": "pnpm build && vsce publish --no-dependencies --pre-release --follow-symlinks",
"vscode:publish": "pnpm build && vsce publish --no-dependencies --follow-symlinks",
"vscode:package": "pnpm build && vsce package --no-dependencies"
},
"homepage": "https://zenstack.dev",
Expand Down Expand Up @@ -49,15 +49,15 @@
],
"engines": {
"vscode": "^1.63.0",
"node": ">=18.0.0"
"node": ">=20.0.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "zmodel",
"id": "zmodel-v3",
"aliases": [
"ZenStack Model",
"zmodel"
Expand All @@ -74,14 +74,14 @@
],
"grammars": [
{
"language": "zmodel",
"language": "zmodel-v3",
"scopeName": "source.zmodel",
"path": "./syntaxes/zmodel.tmLanguage.json"
}
]
},
"activationEvents": [
"onLanguage:zmodel"
"onLanguage:zmodel-v3"
],
"main": "./dist/extension.js"
}
4 changes: 2 additions & 2 deletions packages/ide/vscode/src/extension/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ function startLanguageClient(context: vscode.ExtensionContext): LanguageClient {

// Options to control the language client
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: '*', language: 'zmodel' }],
documentSelector: [{ language: 'zmodel-v3' }],
};

// Create the language client and start the client.
const client = new LanguageClient('zmodel', 'ZModel', serverOptions, clientOptions);
const client = new LanguageClient('zmodel-v3', 'ZenStack Model V3', serverOptions, clientOptions);

// Start the client. This will also launch the server
client.start();
Expand Down
2 changes: 1 addition & 1 deletion packages/language/src/generated/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ZModelAstReflection } from './ast.js';
import { ZModelGrammar } from './grammar.js';

export const ZModelLanguageMetaData = {
languageId: 'zmodel',
languageId: 'zmodel-v3',
fileExtensions: ['.zmodel'],
caseInsensitive: false,
mode: 'development'
Expand Down
5 changes: 4 additions & 1 deletion scripts/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { glob } from 'glob';
import * as path from 'node:path';
import * as yaml from 'yaml';

const excludes = ['packages/ide/vscode/package.json'];

function getWorkspacePackageJsonFiles(workspaceFile: string): string[] {
const workspaceYaml = fs.readFileSync(workspaceFile, 'utf8');
const workspace = yaml.parse(workspaceYaml) as { packages?: string[] };
Expand All @@ -23,7 +25,8 @@ function getWorkspacePackageJsonFiles(workspaceFile: string): string[] {
// include root package.json
files.add(path.resolve(__dirname, '../package.json'));

return Array.from(files);
const result = Array.from(files).filter((f) => !excludes.some((e) => f.endsWith(e)));
return result;
}

function incrementVersion(version: string): string {
Expand Down