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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Generated or vendored content: collapsed in diffs, excluded from language stats.
third_party/lua52/dist/** linguist-generated=true
data/eeex/**.json linguist-generated=true
data/lua52/**.json linguist-generated=true
package-lock.json linguist-generated=true -diff

# Third-party upstream sources.
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - One Linux runner per job; jobs that only matter for some paths are skipped
# by the `changes` job (workflow-level `paths:` filters are not used because a
# skipped workflow never reports, which blocks required status checks).
# - npm, VS Code test builds and emsdk are cached.
# - npm, VS Code test builds, emsdk and the Lua source tarball are cached.
# - Superseded pull request runs are cancelled.
# Failures are reported as file/line annotations (setup-node's tsc and ESLint
# problem matchers, and `::error` lines from scripts/).
Expand Down Expand Up @@ -33,6 +33,7 @@ jobs:
outputs:
code: ${{ steps.diff.outputs.code }}
wasm: ${{ steps.diff.outputs.wasm }}
manual: ${{ steps.diff.outputs.manual }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand All @@ -49,6 +50,7 @@ jobs:
echo "No usable base commit; running every job."
echo "code=true" >> "$GITHUB_OUTPUT"
echo "wasm=true" >> "$GITHUB_OUTPUT"
echo "manual=true" >> "$GITHUB_OUTPUT"
exit 0
fi
changed="$(git diff --name-only "$BASE" HEAD)"
Expand All @@ -64,6 +66,11 @@ jobs:
else
echo "wasm=false" >> "$GITHUB_OUTPUT"
fi
if printf '%s\n' "$changed" | grep -qE '^(scripts/lua-manual/|data/lua52/|third_party/lua52/tarball\.mts$|\.github/workflows/ci\.yml$)'; then
echo "manual=true" >> "$GITHUB_OUTPUT"
else
echo "manual=false" >> "$GITHUB_OUTPUT"
fi

checks:
name: Type-check, lint, unit tests, package
Expand Down Expand Up @@ -191,13 +198,17 @@ jobs:
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Cache emsdk and Lua sources
- name: Cache emsdk
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
.cache/emsdk
.cache/lua
path: .cache/emsdk
key: emsdk-${{ runner.os }}-${{ steps.emsdk.outputs.version }}
# Shared with the `manual` job; the key changes when the pinned tarball does.
- name: Cache the Lua source tarball
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache/lua
key: lua-src-${{ hashFiles('third_party/lua52/tarball.mts') }}
- name: Install emsdk ${{ steps.emsdk.outputs.version }}
env:
VERSION: ${{ steps.emsdk.outputs.version }}
Expand All @@ -211,3 +222,25 @@ jobs:
run: |
source .cache/emsdk/emsdk_env.sh
npm run build:wasm -- --check

manual:
name: Lua 5.2 manual data is current
needs: changes
if: needs.changes.outputs.manual == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# No `npm ci`: the generator uses only Node built-ins and `tar`.
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
- name: Cache the Lua source tarball
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .cache/lua
key: lua-src-${{ hashFiles('third_party/lua52/tarball.mts') }}
- name: Regenerate and compare
run: npm run lua-manual -- --check
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
!package.json
!package.nls.json
!package.nls.*.json
!l10n/**
!l10n/bundle.l10n*.json
!language-configuration/**
!syntaxes/**
!images/icon.png
Expand Down
24 changes: 22 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,30 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
`**/*.[mM][eE][nN][uU]`, and creates and deletes of folders), workspace folder changes and
document closes. `files.exclude` is honored as VS Code's explorer applies it, with an original
matcher checked against VS Code's own; changing it rescans.
- Hover (`textDocument/hover`), in Markdown or plain text as the client prefers:
- Lua 5.2 library functions, values and module tables, with the text of the
[Lua 5.2 manual](https://www.lua.org/manual/5.2/manual.html) verbatim and a link to the entry:
the basic functions and the `string`, `table`, `math`, `bit32` and `debug` libraries, the ones
the engine opens (IESDP), also as `_G.string.format` and `("x"):rep()`. The text is generated
from `doc/manual.html` of the checksum-verified Lua 5.2.4 tarball (`npm run lua-manual`, checked
in CI) and is identical to the online manual's. `io`, `os`, `package` (`require`) and
`coroutine` are not documented, as the engine does not provide them.
- `print`: a note that the engine replaces it, linking IESDP's *Engine Lua globals*, instead of
the manual's description.
- EEex and game functions (`EEex_*`, `Infinity_*`, `C:AddGold`, also called as `C.AddGold`):
the name and a link to EEex-Docs; no EEex-Docs text is copied.
- Locals and globals of the document: how they are declared (`local function f(a, b)`,
`(parameter) a`, `(for variable) i`, `(global) function G(x)`), from the first assignment for
a global, shared across the Lua chunks of a `.menu` file.
- No library text for names a local shadows (`local string = {}`), globals or library members the
document assigns itself (`string = …`, `string.format = …`, `function string.trim()`), or names
resolved through a local `_ENV`.
- The server's own labels are localized into the 14 VS Code display languages from the client's
`locale` (`InitializeParams.locale`), in every editor.
- 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).
- Localization of the manifest, UI strings and the language server's hover labels 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.
- EEex documentation index (`data/eeex/`): names and deep links only, synced from the published
Read the Docs build.
Expand Down
6 changes: 5 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, document and workspace symbols, folding, and same-file definition, references and rename 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, hover, document and workspace symbols, folding, and same-file definition, references and rename 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,8 @@
│ ├── server/ # Language server (separate Node process)
│ │ ├── server.ts # Connection, capabilities, handlers
│ │ ├── features/ # completion.ts, diagnostics.ts, hover.ts, ...
│ │ ├── hover/ # Hover targets, library knowledge and rendering (pure, no LSP imports)
│ │ ├── l10n.ts # Server messages in the client's locale (tables in l10n/server/)
│ │ ├── syntax/ # Lua 5.2 lexer, parser, scopes, symbols, folding (pure, no LSP imports)
│ │ ├── validation/ # Pure analysis logic (no LSP imports) — unit-tested directly
│ │ └── workspace/ # Workspace index, files.exclude glob matching (fs injected; no LSP)
Expand All @@ -42,6 +44,7 @@
│ └── fixtures/workspace/ # Original fixtures only — never copy game files
├── third_party/lua52/ # Official Lua 5.2.4 → WASM (reproducible build; dist/ is generated)
├── data/eeex/ # Generated EEex docs index (names + links only; see scripts/eeex-docs/)
├── data/lua52/ # Lua 5.2 manual library text, generated by scripts/lua-manual/ (CI-checked)
├── scripts/ # Repo tooling in TypeScript (`.mts`, run by Node's type stripping)
├── docs/editors/ # Setup guides for non-VS Code editors
├── dist/ # esbuild output — generated, never edit
Expand Down Expand Up @@ -71,6 +74,7 @@ The server runs in a separate process where the `vscode` module does not exist.
| Localization check | `npm run check-l10n` |
| Third-party notices | `npm run notices` (after `npm run package`; `-- --check` in CI) |
| Rebuild Lua WASM | `npm run build:wasm` (needs pinned emsdk; see CONTRIBUTING.md) |
| Regenerate Lua manual data | `npm run lua-manual` (`-- --check` in CI) |
| Build VSIX | `npx @vscode/vsce package --no-dependencies --changelog-path docs/CHANGELOG.vsix.md` |

**Definition of done for any change:** `check-types`, `lint` and `test:unit` all pass.
Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ 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/hover/` | What a hover describes and its text (pure; library data from `data/lua52/` and `data/eeex/`) |
| `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/server/workspace/` | Index of the workspace's Lua and `.menu` files, and `files.exclude` matching as VS Code applies it (file system injected, unit-tested with an in-memory one) |
| `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) |
| `data/lua52/` | Lua 5.2 library reference generated from the official manual (see below) |
| `l10n/server/` | The language server's own messages, per locale |
| `scripts/` | Repository tooling (TypeScript run directly by Node.js) |
| `test/unit/`, `test/integration/` | Mocha unit tests; VS Code integration tests |
| `docs/editors/` | Setup guides for other editors |
Expand All @@ -53,6 +56,7 @@ See [`CLAUDE.md`](CLAUDE.md) for the architecture rules.
| `npm run package` | Production bundle |
| `npm run notices` | Regenerate `THIRD_PARTY_NOTICES.md` (after `npm run package`) |
| `npm run build:wasm` | Rebuild the Lua 5.2 WebAssembly module (needs Emscripten, see below) |
| `npm run lua-manual` | Regenerate `data/lua52/manual.json` from the official Lua 5.2 manual (see below) |

**Definition of done:** `check-types`, `lint` and `test:unit` pass. Run `npm test` too when you
touch activation, commands, settings or the language client/server wiring.
Expand Down Expand Up @@ -91,6 +95,9 @@ The extension is translated into the 14 display languages VS Code offers
- Manifest strings: `package.nls.json` (English) and `package.nls.<locale>.json`.
- Runtime strings: `vscode.l10n.t('…')` in `src/client/`. After adding or changing one, run
`npx @vscode/l10n-dev export --outDir l10n src/client` and update every `l10n/bundle.l10n.<locale>.json`.
- Language server strings: `messages.t('key', …)` in `src/server/` (`src/server/l10n.ts`), with the
English text in `l10n/server/messages.json` and one `l10n/server/messages.<locale>.json` per
locale. The server picks the table from the client's `locale`, so they work in every editor.
- Keep code spans, setting links (`` `#ieLua.validate.mode#` ``) and `{0}` placeholders unchanged, and
refer to commands by the locale's translated title. `npm run check-l10n` enforces all of this.

Expand All @@ -112,6 +119,22 @@ npm run build:wasm -- --check # verify the committed files are reproducible
The Emscripten version is pinned in `third_party/lua52/build.mts` (`EMSCRIPTEN_VERSION`); CI reads
it from there. The Lua tarball is verified against the SHA-256 published on <https://www.lua.org/ftp/>.

## The Lua 5.2 manual data

Hovers quote the library reference of the Lua 5.2 manual from `data/lua52/manual.json`, which is
generated and committed. `npm run lua-manual` rebuilds it from `doc/manual.html` in the same
checksum-verified Lua 5.2.4 tarball as the WebAssembly module (downloaded once into `.cache/lua`):

```sh
npm run lua-manual # regenerate
npm run lua-manual -- --check # verify the committed file (CI does this)
npm run lua-manual -- --compare-online # audit: compare with https://www.lua.org/manual/5.2/
```

Only the libraries the game engine opens are included (see CLAUDE.md, section 7). The converter
in `scripts/lua-manual/convert.mts` accepts exactly the HTML the manual uses and fails on anything
else; its header lists the three places where Markdown cannot show the manual's formatting.

## Releases

Releases are private: VSIX files are attached to [GitHub Releases](https://github.com/4Luke4/IE-Lua-Language-Server/releases).
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ 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**, **document symbols**,
> **workspace symbols**, **folding**, and **go to definition**, **find references** and **rename**
> within a file; completion, hover, cross-file navigation, formatting and more are planned.
> This is an early version. It currently provides **syntax diagnostics**, **hover**,
> **document symbols**, **workspace symbols**, **folding**, and **go to definition**,
> **find references** and **rename** within a file; completion, cross-file navigation, formatting
> and more are planned.

## Features

Expand All @@ -36,6 +37,13 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
you haven't opened; files hidden with *Files: Exclude* are left out.
- **Folding that follows the code:** functions, loops, each `if`/`elseif`/`else` branch, tables,
comments, and every `{ … }` block and Lua script of a `.menu` file.
- **Documentation on hover.** Lua functions such as `string.format` show their description from
the [Lua 5.2 manual](https://www.lua.org/manual/5.2/manual.html), word for word, with a link to
it. Only the libraries the game provides are documented (`io`, `os`, `require` and coroutines
are not), and `print` tells you that the game replaces it. EEex and game functions such as
`Infinity_DisplayString` or `C:AddGold` link to the
[EEex documentation](https://eeex-docs.readthedocs.io/en/latest/), and your own variables show
how they are declared.
- **Go to Definition, Find All References and Rename Symbol** for variables within a file. Locals
follow Lua's scoping rules; globals are followed across all the Lua of a `.menu` file. Rename
refuses, and says why, when it could change what the code does: a name already in use nearby,
Expand Down
31 changes: 31 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,37 @@ obstacle to adoption, that text has been removed.
compiled object forms to be redistributed without the attribution conditions of sections
4(a), 4(b) and 4(d) of the Apache License 2.0.

## Lua 5.2 Reference Manual

Hovers quote the library reference of the Lua 5.2 Reference Manual (lua-5.2.4/doc/manual.html in
<https://www.lua.org/ftp/lua-5.2.4.tar.gz>), converted to Markdown by
[`scripts/lua-manual/`](scripts/lua-manual/). The manual reads:
"Copyright © 2011–2015 Lua.org, PUC-Rio. Freely available under the terms of the Lua license." The Lua license:

```text
Source: lua-5.2.4.tar.gz, doc/readme.html, section "License" (https://www.lua.org/ftp/lua-5.2.4.tar.gz).

Copyright © 1994–2015 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

## npm packages

### balanced-match 4.0.4
Expand Down
Loading
Loading