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
2 changes: 1 addition & 1 deletion .github/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Scoped notes for workflows, Dependabot and templates. The root `CLAUDE.md` still
| `ci.yml` | PR, push to main, dispatch | checks, VSIX artifact, integration tests (min + stable VS Code), WASM reproducibility |
| `commitlint.yml` | PR, dispatch | Conventional Commits for commits and PR title (Dependabot exempt) |
| `codeql.yml` | PR, push, weekly | code scanning (`actions`, `javascript-typescript`) |
| `release.yml` | dispatch → PR; push of `VERSION` | prepare release PR; publish GitHub release (environment `release`) |
| `release.yml` | dispatch → PR; push of `VERSION` by a `chore(release):` merge | prepare release PR; publish GitHub release (environment `release`) |
| `dependabot-automerge.yml` | Dependabot PR | auto-merge low-risk updates after required checks |
| `eeex-docs-sync*.yml` | weekly, staggered | refresh `data/eeex/*.json` from the published EEex docs |
| `stale.yml` | weekly | stale issues/PRs |
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ body:
attributes:
label: Extension version
description: "VS Code: Extensions view › IE Lua Language Server. Other editors: the version of the release you downloaded."
placeholder: "0.1.0"
placeholder: "1.0.0"
validations:
required: true
- type: dropdown
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ jobs:
with:
path: .vscode-test
key: vscode-test-${{ runner.os }}-${{ steps.vscode.outputs.version }}
# `npm test` runs this as its `pretest` script; calling vscode-test directly
# (to pick one label) skips it, and without the bundled tests in
# out/test/integration/ the run would find no test files.
- name: Build extension and integration tests
run: npm run pretest
- name: Run integration tests
run: xvfb-run -a npx vscode-test --label "${{ matrix.label }}"

Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
# CHANGELOG.md and docs/CHANGELOG.vsix.md, and opens a release pull request.
# 2. Merging that pull request changes VERSION on main → job `publish`
# (environment `release`): verifies the version, runs the checks, packages the
# VSIX and creates the tag and the GitHub (pre-)release.
# VSIX and creates the tag and the GitHub (pre-)release. Other pushes that
# touch VERSION (for example a manual version reset) skip `publish`: it runs
# only for the squash commit of a `chore(release): …` pull request.
#
# Version rules (VS Code): plain major.minor.patch; even minor = stable,
# odd minor = pre-release (packaged with `vsce package --pre-release`).
Expand Down Expand Up @@ -85,7 +87,12 @@ jobs:

publish:
name: Publish GitHub release
if: github.event_name == 'push'
# `prepare` opens release pull requests with one commit and a title that are
# both `chore(release): vX.Y.Z`; the squash merge (title: COMMIT_OR_PR_TITLE)
# therefore starts with that prefix. Any other push touching VERSION is skipped.
if: >-
github.event_name == 'push' &&
startsWith(github.event.head_commit.message, 'chore(release): ')
runs-on: ubuntu-latest
timeout-minutes: 15
environment: release
Expand Down
1 change: 1 addition & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"extension": ["ts"],
"reporter": "spec",
"forbidOnly": true,
"fail-zero": true,
"timeout": 5000
}
3 changes: 2 additions & 1 deletion .vscode-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const config = (label, version) => ({
workspaceFolder: 'test/fixtures/workspace',
// Isolated user data and extensions: never depend on the developer's own setup.
launchArgs: ['--disable-extensions', '--disable-workspace-trust'],
mocha: { ui: 'tdd', timeout: 20000, forbidOnly: true },
// failZero: a run that finds no tests (e.g. tests not built) fails instead of passing.
mocha: { ui: 'tdd', timeout: 20000, forbidOnly: true, failZero: true },
});

export default defineConfig([
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
- Settings `ieLua.validate.mode` (`manual`, `save` (default), `type`, `saveAndType`) and
`ieLua.validate.debounce` (default 300 ms).
- Command **IE Lua: Validate Current File** (`ieLua.validateDocument`).
- Document symbols (`textDocument/documentSymbol`; outline, breadcrumbs, *Go to Symbol in
Editor*): functions and methods at any depth, top-level locals, the first assignment to each
global, and named table fields; in `.menu` files, each `menu` block by its `name`, holding the
Lua symbols inside it. Flat `SymbolInformation` for clients without hierarchical support.
- Folding ranges (`textDocument/foldingRange`): function bodies, `do`/`while`/`for`/`repeat`,
each `if`/`elseif`/`else` clause, multi-line tables, call arguments and long strings, long
comments and runs of `--` lines; in `.menu` files every `{ … }` block, `` `…` `` blocks and
`"…"` scripts, plus the Lua inside them. The closing line stays visible. Honors the client's
`rangeLimit` and supported kinds.
- Error-tolerant Lua 5.2 parser and scope analysis (`src/server/syntax/`), checked against the
official compiler by a differential test; it publishes no diagnostics of its own.
- Localization of the manifest and UI strings into all 14 VS Code display languages
(machine-produced; review welcome).
- Setup guides for Sublime Text, Neovim, Emacs, JetBrains IDEs, Helix, Zed, Kate, Notepad++ and Geany.
Expand All @@ -35,3 +46,9 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
### Changed

- Minimum VS Code version is 1.91.0 (required by `vscode-languageclient` 10 and later).
- Versioning starts at 1.0.0: when no release exists yet, the Release workflow ships the
committed `VERSION` as the first stable release (a pre-release before it would be 1.1.0).
- The Release workflow publishes only for merged `chore(release): …` pull requests, not for any
other push that changes `VERSION`.
- CI integration jobs build the tests before running them, and a test run that finds no tests now
fails. Until now the CI integration jobs ran 0 tests and passed.
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
|---|---|
| Name | `IE Lua Language Server` |
| Publisher | `infinity-engine-tools` |
| Purpose | Lua 5.2 language support (diagnostics now; more LSP features planned) for Infinity Engine EE `.lua` files and the Lua embedded in `.menu` files, usable from VS Code and other LSP editors |
| Purpose | Lua 5.2 language support (diagnostics, document symbols and folding now; more LSP features planned) for Infinity Engine EE `.lua` files and the Lua embedded in `.menu` files, usable from VS Code and other LSP editors |
| Language | TypeScript (strict) |
| Bundler | esbuild (two bundles: client + language server) |
| Minimum VS Code | `^1.91.0` (see `engines.vscode` in `package.json`; required by `vscode-languageclient` ≥ 10) |
Expand All @@ -32,6 +32,7 @@
│ ├── server/ # Language server (separate Node process)
│ │ ├── server.ts # Connection, capabilities, handlers
│ │ ├── features/ # completion.ts, diagnostics.ts, hover.ts, ...
│ │ ├── syntax/ # Lua 5.2 lexer, parser, scopes, symbols, folding (pure, no LSP imports)
│ │ └── validation/ # Pure analysis logic (no LSP imports) — unit-tested directly
│ └── shared/ # Types/constants used by BOTH sides — no vscode imports
├── test/
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ server (port 6009).
| `src/client/` | VS Code extension host code: activation, command, settings, language client |
| `src/server/` | Language server (separate Node process; no `vscode` import) |
| `src/server/validation/` | Pure validation logic, unit-tested without LSP or VS Code |
| `src/server/syntax/` | Error-tolerant Lua 5.2 parser, scope analysis, document symbols and folding (pure; checked against the official compiler by `test/unit/server/syntax/differential.test.ts`) |
| `src/shared/` | Types and constants used by both sides |
| `third_party/lua52/` | Reproducible build of the official Lua 5.2.4 compiler to WebAssembly |
| `data/eeex/` | Generated EEex documentation index (names and links) |
Expand Down Expand Up @@ -118,7 +119,8 @@ Nothing is ever published to a marketplace (`"private": true`; `vsce publish` is
1. Make sure both changelogs describe the changes under `## [Unreleased]`.
2. Run the **Release** workflow (*Actions › Release › Run workflow*) and choose **pre-release** or
**stable**. It computes the next version (odd minor for pre-releases, even minor for stable,
always higher than every earlier release), updates `VERSION`, `package.json`, `package-lock.json`
always higher than every earlier release; the very first stable release is the committed
`VERSION`, 1.0.0, and a pre-release before it would be 1.1.0), updates `VERSION`, `package.json`, `package-lock.json`
and both changelogs, and opens a `chore(release): vX.Y.Z` pull request.
3. Review and merge that pull request. The workflow then verifies the version, runs the checks,
packages the VSIX and creates the tag and the GitHub release (environment `release`).
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
`.menu` files such as `UI.MENU`.

> [!NOTE]
> This is an early version. It currently provides **syntax diagnostics**; completion, hover,
> navigation, formatting and more are planned.
> This is an early version. It currently provides **syntax diagnostics**, **document symbols**
> and **folding**; completion, hover, navigation, formatting and more are planned.

## Features

Expand All @@ -22,6 +22,11 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
`enabled "…"` and `<property> lua "…"` expressions is checked, and errors point to the right line
of the `.menu` file. Upper-case names like `UI.MENU` are recognized, with Lua highlighting.
- **You decide when files are checked:** on save (default), while typing, both, or only on request.
- **Outline and breadcrumbs.** Functions, methods, top-level variables and table fields of Lua files,
and each menu of a `.menu` file by its `name`, in the Outline view, the breadcrumbs and
**Go to Symbol in Editor**. Works while the file still has syntax errors.
- **Folding that follows the code:** functions, loops, each `if`/`elseif`/`else` branch, tables,
comments, and every `{ … }` block and Lua script of a `.menu` file.
- **Available in 14 languages**, following your VS Code display language.
- **Works in other editors** through the Language Server Protocol.

Expand Down Expand Up @@ -70,8 +75,9 @@ Start with the [common steps](docs/editors/README.md).

## Release channels

Versions follow VS Code's convention: an **even** middle number (0.**2**.0) is a stable release,
an **odd** one (0.**1**.0) is a pre-release. See [CHANGELOG.md](CHANGELOG.md).
Versions follow VS Code's convention: an **even** middle number (1.**2**.0) is a stable release,
an **odd** one (1.**1**.0) is a pre-release. The first stable release is 1.0.0.
See [CHANGELOG.md](CHANGELOG.md).

## Contributing and support

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0
1.0.0
9 changes: 7 additions & 2 deletions docs/CHANGELOG.vsix.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
All notable changes for users of the extension. The format is based on
[Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).

Versions with an **odd** middle number (for example 0.**1**.0) are pre-releases;
versions with an **even** middle number (for example 0.**2**.0) are stable releases.
Versions with an **odd** middle number (for example 1.**1**.0) are pre-releases;
versions with an **even** middle number (for example 1.**2**.0) are stable releases.

## [Unreleased]

Expand All @@ -17,6 +17,11 @@ versions with an **even** middle number (for example 0.**2**.0) are stable relea
- **Choose when files are checked** with the *IE Lua › Validate: Mode* setting: on save
(the default), while typing, both, or only on request.
- **Check a file on request** with the **IE Lua: Validate Current File** command.
- **Outline and breadcrumbs.** Functions, variables and table fields of Lua files, and each menu
of a `.menu` file by name, appear in the Outline view, the breadcrumbs and
**Go to Symbol in Editor**.
- **Code folding that follows the code.** Fold functions, loops, each branch of an `if`, tables,
comments, and every block and script of a `.menu` file.
- **Available in 14 languages**, following your VS Code display language.
- **Works in other editors too**: setup guides for Sublime Text, Neovim, Emacs, JetBrains
IDEs, Helix, Zed, Kate, Notepad++ and Geany are on the project page.
10 changes: 10 additions & 0 deletions docs/editors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@ node /path/to/server.js --stdio
| `saveAndType` | both |

Outside VS Code there is no "Validate Current File" command, so prefer `type` or `saveAndType`.

## 4. What you get

| Feature | LSP request | Notes |
| --- | --- | --- |
| Syntax errors | `textDocument/publishDiagnostics` | When `validate.mode` says so (see above). |
| Document symbols (outline) | `textDocument/documentSymbol` | Nested when the editor supports it, otherwise a flat list with container names. |
| Folding | `textDocument/foldingRange` | Whole lines; the closing line of each construct stays visible. |

Symbols and folding always reflect the current text, whatever `validate.mode` is.
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
Expand Up @@ -2,7 +2,7 @@
"name": "ie-lua-language-server",
"displayName": "%displayName%",
"description": "%description%",
"version": "0.0.0",
"version": "1.0.0",
"private": true,
"publisher": "infinity-engine-tools",
"author": "4Luke4",
Expand Down
15 changes: 10 additions & 5 deletions scripts/release/cli.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Release automation used by .github/workflows/release.yml (also runnable locally).
//
// node scripts/release/cli.mts prepare --channel <pre-release|stable>
// Computes the next version from git tags + Conventional Commits, then updates
// VERSION, package.json, package-lock.json, CHANGELOG.md and docs/CHANGELOG.vsix.md.
// Computes the next version from git tags + Conventional Commits (the first
// stable release is VERSION itself), then updates VERSION, package.json,
// package-lock.json, CHANGELOG.md and docs/CHANGELOG.vsix.md.
// node scripts/release/cli.mts verify [--notes <file>]
// Checks that the committed version is consistent and not yet released, and
// optionally writes the CHANGELOG.md section of that version to <file>.
Expand All @@ -19,8 +20,8 @@ import {
compareVersions,
formatVersion,
latestTaggedVersion,
nextVersion,
parseVersion,
releaseVersion,
type Channel,
type Version,
} from './version.mts';
Expand Down Expand Up @@ -87,7 +88,6 @@ function prepare(channel: Channel): void {
const current = committedVersion();
const allTags = tags();
const latest = latestTaggedVersion(allTags);
const baseline = latest ?? current;
if (latest && compareVersions(current, latest) !== 0) {
fail(`VERSION is ${formatVersion(current)} but the latest tag is v${formatVersion(latest)}. Run prepare only from a commit where they match.`);
}
Expand All @@ -106,7 +106,12 @@ function prepare(channel: Channel): void {
if (!bump) {
fail(`No feat/fix/perf/revert or breaking commit since ${latest ? `v${formatVersion(latest)}` : 'the first commit'}; there is nothing to release.`);
}
const next = formatVersion(nextVersion(baseline, bump, channel));
let next: string;
try {
next = formatVersion(releaseVersion(latest, current, bump, channel));
} catch (error) {
fail(error instanceof Error ? error.message : String(error));
}
const date = new Date().toISOString().slice(0, 10);
const previousTag = latest ? `v${formatVersion(latest)}` : undefined;

Expand Down
28 changes: 28 additions & 0 deletions scripts/release/version.mts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,31 @@ export function nextVersion(latest: Version, bump: Bump, channel: Channel): Vers
}
return { ...latest, patch: latest.patch + 1 };
}

/**
* Version of the next release.
*
* - First release (no `vX.Y.Z` tag yet), stable: the committed version itself, so
* the first stable release is whatever VERSION says (1.0.0). It must already
* have an even minor; the bump only proves that there is something to release.
* - First release, pre-release: the next odd line above the committed version
* (1.0.0 → 1.1.0), so a later stable release can never be lower than it.
* - Otherwise: `nextVersion` from the highest tag.
*
* Throws a `RangeError` with an actionable message when the committed version
* cannot be released on the stable channel as is.
*/
export function releaseVersion(latestTag: Version | undefined, committed: Version, bump: Bump, channel: Channel): Version {
if (latestTag !== undefined) {
return nextVersion(latestTag, bump, channel);
}
if (channel === 'pre-release') {
return nextVersion(committed, bump, channel);
}
if (channelOf(committed) !== 'stable') {
throw new RangeError(
`The first stable release uses VERSION as is, but ${formatVersion(committed)} has an odd minor (pre-release). Set VERSION to a version with an even minor, for example ${formatVersion({ major: committed.major, minor: committed.minor + 1, patch: 0 })}.`,
);
}
return committed;
}
38 changes: 38 additions & 0 deletions src/server/documentCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { parseDocument, type ParsedDocument } from './syntax/document.ts';
import { documentKind } from './validation/validateText.ts';

/** The parts of an LSP `TextDocument` the cache needs. */
export interface VersionedDocument {
readonly uri: string;
readonly languageId: string;
readonly version: number;
getText(): string;
}

/**
* Parse results per document, keyed by URI and reused while the version is
* unchanged, so that every feature parses a document version at most once.
* Call `delete` when the document is closed.
*/
export class ParsedDocumentCache {
private readonly entries = new Map<string, { readonly version: number; readonly parsed: ParsedDocument }>();

get(document: VersionedDocument): ParsedDocument {
const cached = this.entries.get(document.uri);
if (cached?.version === document.version) {
return cached.parsed;
}
const parsed = parseDocument(document.getText(), documentKind(document.uri, document.languageId));
this.entries.set(document.uri, { version: document.version, parsed });
return parsed;
}

delete(uri: string): void {
this.entries.delete(uri);
}

/** Number of cached documents (for logging and tests). */
get size(): number {
return this.entries.size;
}
}
Loading
Loading