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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
(`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`.
- Semantic tokens (`textDocument/semanticTokens/full`, `/full/delta` and `/range`) for the names
in the Lua of `.lua` and `.menu` files, classified by the rules of hover so that a name is
colored as it hovers. Keywords, literals, comments and `.menu` syntax are left to the TextMate
grammars.
- Types (all standard): `namespace`, `function`, `method`, `variable`, `parameter`, `property`,
`label`. Modifiers: `declaration`, `modification`, `defaultLibrary`, and `global`, declared
in the manifest (`contributes.semanticTokenModifiers`) so that themes can style `*.global`.
No TextMate fallback scope is contributed: there is no conventional scope for globals, and
the predefined fallbacks of the token types still apply.
- Locals: parameters and the implicit `self` are `parameter`; `local function f`, and a local
declared with a function expression and never assigned again, are `function`.
- Globals have `global`. A global the document assigns is a `function` or `variable` from its
first assignment; otherwise it takes its kind from the Lua 5.2 manual (`namespace` for the
module tables) or EEex-Docs. `defaultLibrary` marks the manual's names, the engine's `print`
and the *EE Game Lua Functions*, not EEex functions. `_ENV`, and names resolved through a
local `_ENV`, are not globals.
- Fields are `property`, or `method` after `:`; library and EEex-Docs members (`string.format`,
`C:AddGold`) as documented. Assignment targets have `modification`, declared names
`declaration`, labels are `label`.
- 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, 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 |
| Purpose | Lua 5.2 language support (diagnostics, hover, completion, semantic tokens, 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 @@ -34,6 +34,7 @@
│ │ ├── 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)
│ │ ├── semanticTokens/ # Name classification for semantic tokens (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
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ server (port 6009).
| `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/semanticTokens/` | What each name is, for semantic highlighting (pure; follows the hover's rules) |
| `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
17 changes: 14 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**,
> **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.
> **completion**, **semantic highlighting**, **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 @@ -49,6 +49,17 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
(`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.
- **Colors that show what each name is.** Parameters, local and global variables, functions,
table fields and the functions the game provides can each have their own color: the extension
tells VS Code what every name in the Lua is, by the same rules as hover. This needs a theme
that uses semantic highlighting, such as VS Code's default theme. Globals carry a `global`
modifier that you can style yourself, for example in `settings.json`:

```json
"editor.semanticTokenColorCustomizations": {
"rules": { "*.global": { "bold": true } }
}
```
- **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
4 changes: 4 additions & 0 deletions docs/CHANGELOG.vsix.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ versions with an **even** middle number (for example 1.**2**.0) are stable relea
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.
- **Colors that show what each name is.** With a theme that uses semantic highlighting, such as
VS Code's default theme, parameters, local and global variables, functions, table fields and
the functions the game provides can be colored differently, in Lua files and the Lua of `.menu`
files. Themes can style globals with the `global` modifier.
- **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 @@ -70,6 +70,7 @@ node /path/to/server.js --stdio
| 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. |
| Semantic tokens | `textDocument/semanticTokens/full`, `/full/delta`, `/range` | Names only (keywords, strings and comments are left to the editor's highlighting). 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 @@ -96,6 +97,13 @@ detail and its documentation on resolve. Members are offered after `.` and `:` o
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.
Semantic tokens classify every name in the Lua with standard token types (`namespace`,
`function`, `method`, `variable`, `parameter`, `property`, `label`) and modifiers
(`declaration`, `modification`, `defaultLibrary`), plus a `global` modifier for global variables.
`defaultLibrary` marks the Lua 5.2 library and the game's own functions (`Infinity_…`), not EEex
functions. How the names are colored depends on the editor and its color scheme; an editor that
ignores the `global` modifier still gets the token type.

Symbols, folding, hover, completion, semantic tokens 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.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
}
}
],
"semanticTokenModifiers": [
{
"id": "global",
"description": "%semanticTokenModifiers.global.description%"
}
],
"commands": [
{
"command": "ieLua.validateDocument",
Expand Down
3 changes: 2 additions & 1 deletion package.nls.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Ověřovat při uložení souboru.",
"configuration.validate.mode.type": "Ověřovat během psaní, po `#ieLua.validate.debounce#` ms bez změn.",
"configuration.validate.mode.saveAndType": "Ověřovat během psaní a při uložení souboru.",
"configuration.validate.debounce.description": "Prodleva v milisekundách od poslední změny do ověření, když má `#ieLua.validate.mode#` hodnotu `type` nebo `saveAndType`."
"configuration.validate.debounce.description": "Prodleva v milisekundách od poslední změny do ověření, když má `#ieLua.validate.mode#` hodnotu `type` nebo `saveAndType`.",
"semanticTokenModifiers.global.description": "Globální proměnná (pole globálního prostředí), na rozdíl od místní proměnné."
}
3 changes: 2 additions & 1 deletion package.nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Beim Speichern einer Datei überprüfen.",
"configuration.validate.mode.type": "Während der Eingabe überprüfen, nachdem `#ieLua.validate.debounce#` Millisekunden lang keine Änderungen erfolgt sind.",
"configuration.validate.mode.saveAndType": "Während der Eingabe und beim Speichern einer Datei überprüfen.",
"configuration.validate.debounce.description": "Verzögerung in Millisekunden nach der letzten Änderung vor der Überprüfung, wenn `#ieLua.validate.mode#` auf `type` oder `saveAndType` festgelegt ist."
"configuration.validate.debounce.description": "Verzögerung in Millisekunden nach der letzten Änderung vor der Überprüfung, wenn `#ieLua.validate.mode#` auf `type` oder `saveAndType` festgelegt ist.",
"semanticTokenModifiers.global.description": "Eine globale Variable (ein Feld der globalen Umgebung), im Gegensatz zu einer lokalen Variable."
}
3 changes: 2 additions & 1 deletion package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Validar al guardar un archivo.",
"configuration.validate.mode.type": "Validar mientras se escribe, tras `#ieLua.validate.debounce#` milisegundos sin cambios.",
"configuration.validate.mode.saveAndType": "Validar mientras se escribe y al guardar un archivo.",
"configuration.validate.debounce.description": "Retraso en milisegundos tras el último cambio antes de validar, cuando `#ieLua.validate.mode#` es `type` o `saveAndType`."
"configuration.validate.debounce.description": "Retraso en milisegundos tras el último cambio antes de validar, cuando `#ieLua.validate.mode#` es `type` o `saveAndType`.",
"semanticTokenModifiers.global.description": "Una variable global (un campo del entorno global), a diferencia de una variable local."
}
3 changes: 2 additions & 1 deletion package.nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Valider lors de l'enregistrement d'un fichier.",
"configuration.validate.mode.type": "Valider pendant la saisie, après `#ieLua.validate.debounce#` millisecondes sans modification.",
"configuration.validate.mode.saveAndType": "Valider pendant la saisie et lors de l'enregistrement d'un fichier.",
"configuration.validate.debounce.description": "Délai en millisecondes après la dernière modification avant la validation, quand `#ieLua.validate.mode#` a la valeur `type` ou `saveAndType`."
"configuration.validate.debounce.description": "Délai en millisecondes après la dernière modification avant la validation, quand `#ieLua.validate.mode#` a la valeur `type` ou `saveAndType`.",
"semanticTokenModifiers.global.description": "Une variable globale (un champ de l'environnement global), par opposition à une variable locale."
}
3 changes: 2 additions & 1 deletion package.nls.hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Ellenőrzés fájl mentésekor.",
"configuration.validate.mode.type": "Ellenőrzés gépelés közben, ha `#ieLua.validate.debounce#` ezredmásodpercig nem történt módosítás.",
"configuration.validate.mode.saveAndType": "Ellenőrzés gépelés közben és fájl mentésekor.",
"configuration.validate.debounce.description": "Késleltetés ezredmásodpercben az utolsó módosítás és az ellenőrzés között, ha az `#ieLua.validate.mode#` értéke `type` vagy `saveAndType`."
"configuration.validate.debounce.description": "Késleltetés ezredmásodpercben az utolsó módosítás és az ellenőrzés között, ha az `#ieLua.validate.mode#` értéke `type` vagy `saveAndType`.",
"semanticTokenModifiers.global.description": "Globális változó (a globális környezet egy mezője), szemben a helyi változóval."
}
3 changes: 2 additions & 1 deletion package.nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Convalida al salvataggio di un file.",
"configuration.validate.mode.type": "Convalida durante la digitazione, dopo `#ieLua.validate.debounce#` millisecondi senza modifiche.",
"configuration.validate.mode.saveAndType": "Convalida durante la digitazione e al salvataggio di un file.",
"configuration.validate.debounce.description": "Ritardo in millisecondi dopo l'ultima modifica prima della convalida, quando `#ieLua.validate.mode#` è `type` o `saveAndType`."
"configuration.validate.debounce.description": "Ritardo in millisecondi dopo l'ultima modifica prima della convalida, quando `#ieLua.validate.mode#` è `type` o `saveAndType`.",
"semanticTokenModifiers.global.description": "Una variabile globale (un campo dell'ambiente globale), a differenza di una variabile locale."
}
3 changes: 2 additions & 1 deletion package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "ファイルの保存時に検証します。",
"configuration.validate.mode.type": "入力中に、変更がない状態が `#ieLua.validate.debounce#` ミリ秒続いた後で検証します。",
"configuration.validate.mode.saveAndType": "入力中およびファイルの保存時に検証します。",
"configuration.validate.debounce.description": "`#ieLua.validate.mode#` が `type` または `saveAndType` の場合に、最後の変更から検証までの遅延時間 (ミリ秒)。"
"configuration.validate.debounce.description": "`#ieLua.validate.mode#` が `type` または `saveAndType` の場合に、最後の変更から検証までの遅延時間 (ミリ秒)。",
"semanticTokenModifiers.global.description": "グローバル変数 (グローバル環境のフィールド)。ローカル変数とは異なります。"
}
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Validate when a file is saved.",
"configuration.validate.mode.type": "Validate while typing, after `#ieLua.validate.debounce#` milliseconds without changes.",
"configuration.validate.mode.saveAndType": "Validate while typing and when a file is saved.",
"configuration.validate.debounce.description": "Delay in milliseconds after the last change before validating, when `#ieLua.validate.mode#` is `type` or `saveAndType`."
"configuration.validate.debounce.description": "Delay in milliseconds after the last change before validating, when `#ieLua.validate.mode#` is `type` or `saveAndType`.",
"semanticTokenModifiers.global.description": "A global variable (a field of the global environment), as opposed to a local."
}
3 changes: 2 additions & 1 deletion package.nls.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "파일을 저장할 때 유효성을 검사합니다.",
"configuration.validate.mode.type": "입력하는 동안 `#ieLua.validate.debounce#`밀리초 동안 변경이 없으면 유효성을 검사합니다.",
"configuration.validate.mode.saveAndType": "입력하는 동안과 파일을 저장할 때 유효성을 검사합니다.",
"configuration.validate.debounce.description": "`#ieLua.validate.mode#`이(가) `type` 또는 `saveAndType`인 경우 마지막 변경 후 유효성 검사까지의 지연 시간(밀리초)입니다."
"configuration.validate.debounce.description": "`#ieLua.validate.mode#`이(가) `type` 또는 `saveAndType`인 경우 마지막 변경 후 유효성 검사까지의 지연 시간(밀리초)입니다.",
"semanticTokenModifiers.global.description": "전역 변수(전역 환경의 필드)로, 로컬 변수와 구별됩니다."
}
3 changes: 2 additions & 1 deletion package.nls.pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Sprawdzaj poprawność podczas zapisywania pliku.",
"configuration.validate.mode.type": "Sprawdzaj poprawność podczas pisania, po `#ieLua.validate.debounce#` ms bez zmian.",
"configuration.validate.mode.saveAndType": "Sprawdzaj poprawność podczas pisania i zapisywania pliku.",
"configuration.validate.debounce.description": "Opóźnienie w milisekundach od ostatniej zmiany do sprawdzenia poprawności, gdy ustawienie `#ieLua.validate.mode#` ma wartość `type` lub `saveAndType`."
"configuration.validate.debounce.description": "Opóźnienie w milisekundach od ostatniej zmiany do sprawdzenia poprawności, gdy ustawienie `#ieLua.validate.mode#` ma wartość `type` lub `saveAndType`.",
"semanticTokenModifiers.global.description": "Zmienna globalna (pole środowiska globalnego), w odróżnieniu od zmiennej lokalnej."
}
3 changes: 2 additions & 1 deletion package.nls.pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"configuration.validate.mode.save": "Validar quando um arquivo for salvo.",
"configuration.validate.mode.type": "Validar durante a digitação, após `#ieLua.validate.debounce#` milissegundos sem alterações.",
"configuration.validate.mode.saveAndType": "Validar durante a digitação e quando um arquivo for salvo.",
"configuration.validate.debounce.description": "Atraso em milissegundos após a última alteração antes da validação, quando `#ieLua.validate.mode#` for `type` ou `saveAndType`."
"configuration.validate.debounce.description": "Atraso em milissegundos após a última alteração antes da validação, quando `#ieLua.validate.mode#` for `type` ou `saveAndType`.",
"semanticTokenModifiers.global.description": "Uma variável global (um campo do ambiente global), ao contrário de uma variável local."
}
Loading
Loading