Skip to content
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
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.
- Completion (`textDocument/completion`, `completionItem/resolve`; triggered by `.` and `:`), with
the rules of hover so that a completed name hovers as offered:
- Variables: the locals visible at the cursor (the innermost of each name, the implicit
`self` included), then the globals the document assigns (in any Lua chunk of a `.menu` file),
the Lua 5.2 library globals the engine opens, the EEex and game functions, and the keywords.
Each name once, from the first of these that has it. While a local `_ENV` is visible, only
locals and keywords. Keywords are the 22 reserved words (manual §3.1); in `.menu` expressions
(`enabled "…"`, …) only `nil`, `false`, `true`, `function`, `not`, `and` and `or` (§3.4).
- Members of globals (`_G.` prefixes removed): after `_G.` the globals; after `t.` and `t:` the
fields the document assigns on `t`; the manual's members of `string`, `table`, `math`,
`bit32` and `debug`, unless the document assigns the module table or defines that member;
EEex-Docs names after the operator they are documented with (`EEex_Options_Option.new`,
`C:AddGold`). After `("…"):`, the string library (§6.4). Nothing after locals, calls or
indexes (no type inference).
- Nothing in comments, strings and numbers, outside the Lua of a `.menu` file, or where a name
is declared (after `local`, `function`, `for`, `goto`, `::`, in their name lists and in
parameter lists). `io`, `os`, `package` (`require`) and `coroutine` are never offered.
- Each item has the hover's code line as `detail`; the manual text or EEex-Docs link is added
when the item is resolved, in Markdown or plain text as the client prefers
(`completionItem.documentationFormat`). The edit range is the name around the cursor, sent
once per list when the client supports `itemDefaults.editRange`, as an insert/replace edit
when it supports `insertReplaceSupport`.
- 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, UI strings and the language server's hover labels into all 14 VS
Expand Down
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, 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 |
| Purpose | Lua 5.2 language support (diagnostics, hover, completion, 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 @@ -33,6 +33,7 @@
│ │ ├── server.ts # Connection, capabilities, handlers
│ │ ├── features/ # completion.ts, diagnostics.ts, hover.ts, ...
│ │ ├── hover/ # Hover targets, library knowledge and rendering (pure, no LSP imports)
│ │ ├── completion/ # Completion candidates (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
Expand Down
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ server (port 6009).
| `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/completion/` | What completion offers at the cursor (pure; reuses the hover's knowledge and text) |
| `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 |
Expand Down Expand Up @@ -121,9 +122,10 @@ it from there. The Lua tarball is verified against the SHA-256 published on <htt

## 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`):
Hovers and completion items 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
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the

> [!NOTE]
> 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.
> **completion**, **document symbols**, **workspace symbols**, **folding**, and **go to definition**,
> **find references** and **rename** within a file; cross-file navigation, formatting and more are
> planned.

## Features

Expand Down Expand Up @@ -44,6 +44,11 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
`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.
- **Code completion** for the variables in scope, the globals your file defines, the Lua functions
the game provides (`string.` lists the string library), and EEex and game functions
(`Infinity_…`, `EEex_…`, and methods after `C:`), with the same documentation as on hover.
Nothing the game lacks is suggested (`io`, `os`, `require`, coroutines). In `.menu` files,
completion works inside the Lua only.
- **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
5 changes: 5 additions & 0 deletions docs/CHANGELOG.vsix.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ versions with an **even** middle number (for example 1.**2**.0) are stable relea
`Infinity_DisplayString` for a link to its EEex documentation, or over your own variables to
see how they are declared. Only the libraries the game provides are documented, and `print`
tells you that the game replaces it.
- **Code completion.** Suggestions for the variables in scope, the globals your file defines,
the Lua functions the game provides (type `string.` for the string library), and EEex and
game functions such as `Infinity_DisplayString`, or methods after `C:`. Lua functions show
their description from the Lua 5.2 manual, EEex and game functions a link to their
documentation. In `.menu` files, completion works inside the Lua.
- **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: 9 additions & 1 deletion docs/editors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ node /path/to/server.js --stdio
| Find references | `textDocument/references` | Every use of a local or global in the same file. |
| Rename | `textDocument/prepareRename`, `textDocument/rename` | Same file only; refused, with the reason as the error message, when the rename could change what the code does. |
| Hover | `textDocument/hover` | Markdown or plain text, whichever the editor prefers (`hover.contentFormat`); the server's own words follow the editor's `locale`. See below. |
| Completion | `textDocument/completion`, `completionItem/resolve` | Triggered by `.` and `:`. Documentation is sent on resolve, in the editor's preferred `completionItem.documentationFormat`. See below. |
| Workspace symbols | `workspace/symbol` | Every `*.lua` and `*.menu` file under the workspace folders, plus open files. See below. |

Workspace symbols need an editor that sends **workspace folders** when it starts the server;
Expand All @@ -88,6 +89,13 @@ others get plain text with the links written out. The few words of the server's
`parameter`) are translated when the editor sends a `locale` the extension supports (one of the
14 VS Code display languages, or its language alone: `de-AT` uses German); otherwise English.

Symbols, folding, hover and navigation always reflect the current text, whatever `validate.mode` is.
Completion offers the variables in scope, the globals the file assigns, the Lua 5.2 libraries the
game provides and the EEex and game functions, with the hover's declaration line as the item's
detail and its documentation on resolve. Members are offered after `.` and `:` on globals
(`string.`, `C:`) and after `("…"):`; there is no type inference, so fields of locals are not.
Each item replaces the name around the cursor (`insertReplaceSupport` and
`completionList.itemDefaults` are used when the editor has them).

Symbols, folding, hover, completion and navigation always reflect the current text, whatever `validate.mode` is.
Navigation works on variables: table fields (`t.x`) and `goto` labels are not followed, and in a
`.menu` file globals are shared by all its Lua, while locals stay in their own block or script.
Loading
Loading