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
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,32 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
- Every result is lexed again and must have the same tokens and comments, or nothing changes.
- Registered dynamically for Lua documents only (language `lua`, or `*.lua` in any letter case)
when the client supports it, so `.menu` files have no formatter; static otherwise.
- Quick fixes (`textDocument/codeAction`) for three `.menu` diagnostics, with the remedy
[IESDP](https://gibberlings3.github.io/iesdp/file_formats/ie_formats/menu_v1.htm) states:
- `menu-unquoted-underscore`: *Enclose in quotes* (`My_Menu` → `"My_Menu"`; "Always quote
names"). A run without a letter (`10_0`) gets no fix: it is not a name, and quoting would
make a number a string.
- `menu-word-too-long`: *Enclose in quotes* ("Quoted strings are not limited"); the whole run
when the word is joined to `_`.
- `menu-inline-lua-last-character`: *Insert a space before the closing backtick* ("end every
inline block with a line break or a space"), so the engine drops the space instead of code.
- Each fix is preferred (`isPreferred`) and linked to its diagnostic; when the file has several
problems of the code, *Fix all `<code>` problems* fixes them together.
- `source.fixAll.ieLua` applies every fix of the file, also from `editor.codeActionsOnSave`
(`{ "source.fixAll.ieLua": "explicit" }`) and whether or not diagnostics were published
(`ieLua.validate.mode` `manual`). The kind is stable: settings refer to it.
- No fix for `lua-syntax`, `menu-unterminated-string` or `menu-unterminated-block`: where the
text should end, or how to repair the Lua, would be a guess.
- The current text is analyzed again for every request: a diagnostic from an older version of
the file (published on save, before later edits) gets no fix rather than an edit in the wrong
place. Every set of edits is checked by lexing the result: the remaining problems must be
exactly those no fix touches, or nothing is offered (and an error is logged).
- The fixes change the Lua the engine compiles, as intended: the character it dropped before
the backtick now runs, and a quoted property value is compiled whole (`enabled "My_Var"` is
`My_Var`, not `My`). The Lua is validated as usual afterwards; it may report an error the
dropped or split text hid.
- Titles are localized like the hover labels. Advertised only to clients that accept
`CodeAction` literals (`codeActionLiteralSupport`).
- 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, semantic tokens, formatting of `.lua` files, 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, formatting of `.lua` files, `.menu` quick fixes, 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 @@ -35,6 +35,7 @@
│ │ ├── 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)
│ │ ├── codeActions/ # Quick fixes for .menu diagnostics (pure, no LSP imports)
│ │ ├── formatting/ # Layout-preserving Lua formatting edits (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)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ server (port 6009).
| `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/codeActions/` | Quick fixes for `.menu` diagnostics (pure; every set of edits re-lexed and checked) |
| `src/server/formatting/` | Layout-preserving formatting edits for Lua (pure; every result re-lexed and checked) |
| `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) |
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,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**, **semantic highlighting**, **formatting** (Lua files), **document symbols**,
> **workspace symbols**, **folding**, and **go to definition**, **find references** and **rename**
> within a file; cross-file navigation, formatting of `.menu` files and more are planned.
> **workspace symbols**, **folding**, **quick fixes** (`.menu` files), and **go to definition**,
> **find references** and **rename** within a file; cross-file navigation, formatting of `.menu`
> files and more are planned.

## Features

Expand Down Expand Up @@ -70,6 +71,11 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
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,
a reserved word, or a global that is defined outside the file.
- **Quick fixes for `.menu` text the game misreads.** Put an unquoted name such as `My_Menu`, or
a word too long for the game, in quotes, or add the space the game needs before the closing
backtick of a Lua block, from the light bulb (Ctrl+.). *Fix all IE Lua auto-fixable problems*
fixes the whole file; to do it on every save, add
`"editor.codeActionsOnSave": { "source.fixAll.ieLua": "explicit" }` to your settings.
- **Available in 14 languages**, following your VS Code display language.
- **Works in other editors** through the Language Server Protocol.

Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.vsix.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ versions with an **even** middle number (for example 1.**2**.0) are stable relea
editor's tab and indentation settings, and with *Editor: Format On Type* it re-indents `end`,
`else` and closing brackets as you type them. Files with syntax errors are left as they are;
`.menu` files are not formatted yet.
- **Quick fixes for `.menu` text the game misreads.** Click the light bulb (or press Ctrl+.)
on a warning to put an unquoted name such as `My_Menu` or a too-long word in quotes, or to add
the space the game needs before the closing backtick of a Lua block. Fix them all at once with
*Fix all IE Lua auto-fixable problems*, or on every save with
`"editor.codeActionsOnSave": { "source.fixAll.ieLua": "explicit" }`.
- **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.
14 changes: 13 additions & 1 deletion docs/editors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ node /path/to/server.js --stdio
| 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. |
| Formatting | `textDocument/formatting`, `/rangeFormatting`, `/onTypeFormatting` | `.lua` files only. Keeps your line breaks; uses the editor's tab size and spaces/tabs option. See below. |
| Quick fixes | `textDocument/codeAction` | `.menu` files only: kinds `quickfix` and `source.fixAll.ieLua`. Needs `codeActionLiteralSupport`. 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 Down Expand Up @@ -117,6 +118,17 @@ turned on; see its documentation). When the editor supports dynamic registration
offered for Lua documents only (language `lua`, or `*.lua` in any letter case), so `.menu` files
have no formatter; other editors get no edits for `.menu` files.

Symbols, folding, hover, completion, semantic tokens, formatting and navigation always reflect the current text, whatever `validate.mode` is.
Quick fixes cover three `.menu` diagnostics, with the remedy IESDP gives:
`menu-unquoted-underscore` and `menu-word-too-long` put the text in `"…"`, and
`menu-inline-lua-last-character` inserts a space before the closing backtick. The action is
offered for a diagnostic only while its problem is still at the same place in the current text.
A fix changes the Lua the game compiles, as intended: the character it dropped before the
backtick now runs, and a quoted Lua property value is compiled whole, so validation may then
report an error the misread text hid.
The `source.fixAll.ieLua` action applies every fix of the file, whether or not diagnostics were
published; ask for that kind (or `source.fixAll`) to run it on save, if your editor can request
code actions on save. Action titles follow the editor's `locale`, like hover.

Symbols, folding, hover, completion, semantic tokens, formatting, quick fixes 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: 5 additions & 1 deletion l10n/server/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parametr",
"hover.kind.forVariable": "proměnná for",
"hover.kind.global": "globální",
"hover.engineReplaced": "Herní engine nahrazuje {0} vlastní funkcí, takže popis v příručce Lua 5.2 neplatí. Viz {1}."
"hover.engineReplaced": "Herní engine nahrazuje {0} vlastní funkcí, takže popis v příručce Lua 5.2 neplatí. Viz {1}.",
"codeAction.quote": "Uzavřít do uvozovek",
"codeAction.insertSpace": "Vložit mezeru před uzavírací zpětný apostrof",
"codeAction.fixAllOfCode": "Opravit všechny problémy {0}",
"codeAction.fixAll": "Opravit všechny automaticky opravitelné problémy IE Lua"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "Parameter",
"hover.kind.forVariable": "for-Variable",
"hover.kind.global": "global",
"hover.engineReplaced": "Die Spiel-Engine ersetzt {0} durch eine eigene Funktion, daher gilt die Beschreibung im Lua 5.2-Handbuch nicht. Siehe {1}."
"hover.engineReplaced": "Die Spiel-Engine ersetzt {0} durch eine eigene Funktion, daher gilt die Beschreibung im Lua 5.2-Handbuch nicht. Siehe {1}.",
"codeAction.quote": "In Anführungszeichen setzen",
"codeAction.insertSpace": "Leerzeichen vor dem schließenden Backtick einfügen",
"codeAction.fixAllOfCode": "Alle {0}-Probleme beheben",
"codeAction.fixAll": "Alle automatisch behebbaren IE Lua-Probleme beheben"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parámetro",
"hover.kind.forVariable": "variable for",
"hover.kind.global": "global",
"hover.engineReplaced": "El motor del juego reemplaza {0} por una función propia, por lo que la descripción del manual de Lua 5.2 no se aplica. Consulte {1}."
"hover.engineReplaced": "El motor del juego reemplaza {0} por una función propia, por lo que la descripción del manual de Lua 5.2 no se aplica. Consulte {1}.",
"codeAction.quote": "Encerrar entre comillas",
"codeAction.insertSpace": "Insertar un espacio antes de la comilla invertida de cierre",
"codeAction.fixAllOfCode": "Corregir todos los problemas {0}",
"codeAction.fixAll": "Corregir todos los problemas de IE Lua que se pueden corregir automáticamente"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "paramètre",
"hover.kind.forVariable": "variable for",
"hover.kind.global": "globale",
"hover.engineReplaced": "Le moteur du jeu remplace {0} par sa propre fonction : la description du manuel Lua 5.2 ne s'applique donc pas. Voir {1}."
"hover.engineReplaced": "Le moteur du jeu remplace {0} par sa propre fonction : la description du manuel Lua 5.2 ne s'applique donc pas. Voir {1}.",
"codeAction.quote": "Mettre entre guillemets",
"codeAction.insertSpace": "Insérer un espace avant l'accent grave fermant",
"codeAction.fixAllOfCode": "Corriger tous les problèmes {0}",
"codeAction.fixAll": "Corriger tous les problèmes IE Lua corrigibles automatiquement"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "paraméter",
"hover.kind.forVariable": "for-változó",
"hover.kind.global": "globális",
"hover.engineReplaced": "A játékmotor saját függvényre cseréli a(z) {0} függvényt, ezért a Lua 5.2 kézikönyv leírása nem érvényes. Lásd: {1}."
"hover.engineReplaced": "A játékmotor saját függvényre cseréli a(z) {0} függvényt, ezért a Lua 5.2 kézikönyv leírása nem érvényes. Lásd: {1}.",
"codeAction.quote": "Idézőjelek közé tétel",
"codeAction.insertSpace": "Szóköz beszúrása a záró fordított aposztróf elé",
"codeAction.fixAllOfCode": "Az összes {0} probléma javítása",
"codeAction.fixAll": "Az összes automatikusan javítható IE Lua-probléma javítása"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parametro",
"hover.kind.forVariable": "variabile for",
"hover.kind.global": "globale",
"hover.engineReplaced": "Il motore di gioco sostituisce {0} con una propria funzione, quindi la descrizione del manuale di Lua 5.2 non si applica. Vedere {1}."
"hover.engineReplaced": "Il motore di gioco sostituisce {0} con una propria funzione, quindi la descrizione del manuale di Lua 5.2 non si applica. Vedere {1}.",
"codeAction.quote": "Racchiudi tra virgolette",
"codeAction.insertSpace": "Inserisci uno spazio prima dell'apice inverso di chiusura",
"codeAction.fixAllOfCode": "Correggi tutti i problemi {0}",
"codeAction.fixAll": "Correggi tutti i problemi di IE Lua correggibili automaticamente"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "パラメーター",
"hover.kind.forVariable": "for 変数",
"hover.kind.global": "グローバル",
"hover.engineReplaced": "ゲーム エンジンは {0} を独自の関数に置き換えるため、Lua 5.2 マニュアルの説明は当てはまりません。{1} を参照してください。"
"hover.engineReplaced": "ゲーム エンジンは {0} を独自の関数に置き換えるため、Lua 5.2 マニュアルの説明は当てはまりません。{1} を参照してください。",
"codeAction.quote": "引用符で囲む",
"codeAction.insertSpace": "閉じるバッククォートの前にスペースを挿入する",
"codeAction.fixAllOfCode": "すべての {0} の問題を修正する",
"codeAction.fixAll": "自動修正可能な IE Lua の問題をすべて修正する"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parameter",
"hover.kind.forVariable": "for variable",
"hover.kind.global": "global",
"hover.engineReplaced": "The game engine replaces {0} with its own function, so the description in the Lua 5.2 manual does not apply. See {1}."
"hover.engineReplaced": "The game engine replaces {0} with its own function, so the description in the Lua 5.2 manual does not apply. See {1}.",
"codeAction.quote": "Enclose in quotes",
"codeAction.insertSpace": "Insert a space before the closing backtick",
"codeAction.fixAllOfCode": "Fix all {0} problems",
"codeAction.fixAll": "Fix all IE Lua auto-fixable problems"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "매개 변수",
"hover.kind.forVariable": "for 변수",
"hover.kind.global": "전역",
"hover.engineReplaced": "게임 엔진이 {0}을(를) 자체 함수로 대체하므로 Lua 5.2 설명서의 설명은 적용되지 않습니다. {1}을(를) 참조하세요."
"hover.engineReplaced": "게임 엔진이 {0}을(를) 자체 함수로 대체하므로 Lua 5.2 설명서의 설명은 적용되지 않습니다. {1}을(를) 참조하세요.",
"codeAction.quote": "따옴표로 묶기",
"codeAction.insertSpace": "닫는 백틱 앞에 공백 삽입",
"codeAction.fixAllOfCode": "모든 {0} 문제 해결",
"codeAction.fixAll": "자동 수정 가능한 모든 IE Lua 문제 해결"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parametr",
"hover.kind.forVariable": "zmienna for",
"hover.kind.global": "globalna",
"hover.engineReplaced": "Silnik gry zastępuje {0} własną funkcją, więc opis z podręcznika Lua 5.2 nie ma zastosowania. Zobacz {1}."
"hover.engineReplaced": "Silnik gry zastępuje {0} własną funkcją, więc opis z podręcznika Lua 5.2 nie ma zastosowania. Zobacz {1}.",
"codeAction.quote": "Ujmij w cudzysłów",
"codeAction.insertSpace": "Wstaw spację przed zamykającym grawisem",
"codeAction.fixAllOfCode": "Napraw wszystkie problemy {0}",
"codeAction.fixAll": "Napraw wszystkie automatycznie naprawialne problemy IE Lua"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "parâmetro",
"hover.kind.forVariable": "variável for",
"hover.kind.global": "global",
"hover.engineReplaced": "O mecanismo do jogo substitui {0} por uma função própria, portanto a descrição do manual do Lua 5.2 não se aplica. Consulte {1}."
"hover.engineReplaced": "O mecanismo do jogo substitui {0} por uma função própria, portanto a descrição do manual do Lua 5.2 não se aplica. Consulte {1}.",
"codeAction.quote": "Colocar entre aspas",
"codeAction.insertSpace": "Inserir um espaço antes do acento grave de fechamento",
"codeAction.fixAllOfCode": "Corrigir todos os problemas {0}",
"codeAction.fixAll": "Corrigir todos os problemas do IE Lua que podem ser corrigidos automaticamente"
}
6 changes: 5 additions & 1 deletion l10n/server/messages.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"hover.kind.parameter": "параметр",
"hover.kind.forVariable": "переменная for",
"hover.kind.global": "глобальная",
"hover.engineReplaced": "Игровой движок заменяет {0} собственной функцией, поэтому описание из руководства по Lua 5.2 не применимо. См. {1}."
"hover.engineReplaced": "Игровой движок заменяет {0} собственной функцией, поэтому описание из руководства по Lua 5.2 не применимо. См. {1}.",
"codeAction.quote": "Заключить в кавычки",
"codeAction.insertSpace": "Вставить пробел перед закрывающим обратным апострофом",
"codeAction.fixAllOfCode": "Исправить все проблемы {0}",
"codeAction.fixAll": "Исправить все автоматически исправляемые проблемы IE Lua"
}
Loading