Skip to content

Commit

Permalink
Update VSCode plugin (#1895)
Browse files Browse the repository at this point in the history
* Update VSCode plugin NPM package
* Update VSCode syntax
  * Rewrite the `definition` rule to make it simpler and work with multiline types
    * Use shared `#types` group with added support for `rec`
  * Refactor groups to use ordered include `patterns` and unordered `repository` of named subgroups
  * Add escape sequences to strings
* Fix a typo in a regular expression that broke syntax highlighting
* Generate the syntax JSON file from YAML
---

* Closes #1887
  • Loading branch information
xsebek authored Jun 9, 2024
1 parent c3f5690 commit 478b62c
Show file tree
Hide file tree
Showing 21 changed files with 1,638 additions and 2,993 deletions.
1 change: 1 addition & 0 deletions .github/workflows/vscode-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
npm clean-install && \
tsc --build . && \
cd .. && \
npm run gen-syntax && \
npm clean-install && \
npm run build --if-present
- run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/vscode-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
npm clean-install && \
tsc --build . && \
cd .. && \
npm run gen-syntax && \
npm clean-install && \
npm run build --if-present
- name: Publish to Visual Studio Marketplace
Expand Down
1 change: 1 addition & 0 deletions editors/vscode/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/**
.vscode-test/**
.gitignore
test/**
DEVELOPING.md
17 changes: 13 additions & 4 deletions editors/vscode/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@

### Updating the syntax highlighting

Whenever swarm language adds new features, the highlighting needs to be updated.
Whenever swarm language adds new features, the highlighting might need to be updated.

To save some time, get the current reserved words by running `swarm-docs`:
```bash
cabal run swarm:swarm-docs -- editors
cabal run -O0 swarm:swarm-docs -- editors
```

You still have to add for example types manually.

You still have to add for example type keywords (`rec`, `forall`) manually.

### Add more language features

Expand All @@ -54,9 +53,16 @@ npm install
If you want to include the LSP client then after the previous install do:
```sh
cd client
npm update
npm install
tsc --build
```

To generate the JSON TextMate grammar do:
```sh
npm run gen-syntax
```

To build the VSIX package do:
```sh
vsce package --baseImagesUrl "https://raw.githubusercontent.com/swarm-game/swarm/editors/vscode"
Expand All @@ -76,3 +82,6 @@ Then you may have to update the test snapshot as follows:
```
npm test vscode-tmgrammar-snap -- --updateSnapshot
```

**WARNING:** Always run the snapshot test to see if half of the
syntax is not suddenly missing because of a typo.
Loading

0 comments on commit 478b62c

Please sign in to comment.