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
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,33 @@ the extension live in [`docs/CHANGELOG.vsix.md`](docs/CHANGELOG.vsix.md).
dropped or split text hid.
- Titles are localized like the hover labels. Advertised only to clients that accept
`CodeAction` literals (`codeActionLiteralSupport`).
- LuaCATS doc comments ([annotation reference](https://luals.github.io/wiki/annotations/)) on the
document's own code, in hover, completion and diagnostics. Types are shown as written; nothing checks or infers them.
- A doc block is a run of `---` comments, each alone on its line, on consecutive lines; it
documents the statement that starts on the next line. A blank line detaches it, and `----`
banners and `---` after code are not doc comments. The reference does not state this rule;
its examples follow it. The same applies inside the Lua of `.menu` files.
- Documented: `local function f`, `local x = …` (one name), `function G()` and `G = …` (one
name), a global by the block above its first assignment, as its hover code line already is.
Each parameter shows its own `@param` entry, also for `function M.f(a)`, `function M:m(a)`
and `M.f = function(a) … end`, whose names have no hover.
- Rendered: the description (Markdown, one leading space removed from each line), then
`@param`, `@return`, `@type`, `@deprecated` and `@see` in the order written, laid out as VS
Code's own TypeScript hovers lay out JSDoc tags (``*@param* `name` — text``), with the type in
a code span after the name. The other reference tags (`@class`, `@field`, `@overload`, …) and
`---|` lines are not rendered and never show up as description. Tags are `---@tag`, as the
reference writes them; `--- @tag` stays description text.
- The code line of the hover, and the `detail` of a completion item, do not change.
- Completion items of documented names carry the same text as their hover in `documentation`,
sent with the list rather than on `completionItem/resolve`: the resolve request names no
document, so a later lookup could read a newer version of it.
- Diagnostics (warnings, published with the others under `ieLua.validate.mode`; codes are
stable): `doc-tag-malformed` for `---@param` without a name or type and `---@return` or
`---@type` without a type, in any doc block; `doc-param-unknown` for a `---@param` the
documented function does not have (`...` needs a vararg function, `self` a method), checked
only where the statement writes the function itself, never for a call result; and
`doc-param-duplicate` for a parameter documented twice. Messages are localized like the hover
labels.
- 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, `.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 |
| Purpose | Lua 5.2 language support (diagnostics, hover, completion, semantic tokens, formatting of `.lua` files, `.menu` quick fixes, document and workspace symbols, folding, LuaCATS doc comments in hover, completion and diagnostics, 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 @@ -36,6 +36,7 @@
│ │ ├── 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)
│ │ ├── docComments/ # LuaCATS doc comments: parse, attach, render, check (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/docComments/` | LuaCATS doc comments: parsing, what each block documents, rendering and problems (pure) |
| `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`) |
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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**, **quick fixes** (`.menu` files), and **go to definition**,
> **workspace symbols**, **folding**, **quick fixes** (`.menu` files), **LuaCATS doc comments**
> in hover, completion and diagnostics, and **go to definition**,
> **find references** and **rename** within a file; cross-file navigation, formatting of `.menu`
> files and more are planned.

Expand Down Expand Up @@ -76,6 +77,21 @@ Lua language support for the **Infinity Engine Enhanced Edition** games and the
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.
- **Your own documentation from doc comments.** Write [LuaCATS](https://luals.github.io/wiki/annotations/)
doc comments, the `---` style other Lua tools read, on the lines right above a function or
variable:

```lua
--- Builds a greeting.
---@param name string Who to greet.
---@return string greeting
local function greet(name) return "Hello, " .. name end
```

Hover and completion then show the description and the `@param`, `@return`, `@type`,
`@deprecated` and `@see` tags, and hovering a parameter shows its `@param` line. Types are shown
as you write them; they are not checked. A warning points out a `---@param` that names a
parameter the function doesn't have, documents one twice, or misses its name or type.
- **Available in 14 languages**, following your VS Code display language.
- **Works in other editors** through the Language Server Protocol.

Expand Down
6 changes: 6 additions & 0 deletions docs/CHANGELOG.vsix.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ versions with an **even** middle number (for example 1.**2**.0) are stable relea
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" }`.
- **Your own documentation on hover.** Write doc comments in the LuaCATS style used by other Lua
tools, `---` lines with `---@param`, `---@return`, `---@type`, `---@deprecated` and `---@see`,
right above a function or variable, and hovering it shows the description and tags, as does
its code completion suggestion. Hovering a parameter shows its `---@param` line. A warning
tells you when a `---@param` names a parameter the function doesn't have, documents one twice,
or misses its name or type.
- **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.
16 changes: 14 additions & 2 deletions docs/editors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ node /path/to/server.js --stdio

| Feature | LSP request | Notes |
| --- | --- | --- |
| Syntax errors | `textDocument/publishDiagnostics` | When `validate.mode` says so (see above). In `.menu` files, also warnings for text the game misreads. |
| Syntax errors | `textDocument/publishDiagnostics` | When `validate.mode` says so (see above). In `.menu` files, also warnings for text the game misreads. Warnings for doc comments (see below). |
| 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. |
| Go to definition | `textDocument/definition` | The declaration of a local, or every assignment to a global, in the same file. |
| 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. |
| Completion | `textDocument/completion`, `completionItem/resolve` | Triggered by `.` and `:`. Documentation is sent on resolve (with the item, for names with a doc comment), 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. |
Expand Down Expand Up @@ -129,6 +129,18 @@ The `source.fixAll.ieLua` action applies every fix of the file, whether or not d
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.

Hover and completion also show [LuaCATS](https://luals.github.io/wiki/annotations/) doc comments:
a run of `---` lines, each alone on its line, directly above a `local function`, a `local` with
one name, a `function` with one name or an assignment to one global (a global uses the comment
above its first assignment). The description and the `---@param`, `---@return`, `---@type`,
`---@deprecated` and `---@see` tags are shown in the order written, as VS Code shows JSDoc tags;
a parameter shows its own `---@param` line. Types are shown as written and never checked. With
the other diagnostics, the server publishes three warnings for doc comments:
`doc-tag-malformed` (a `---@param` without a name or type, a `---@return` or `---@type` without a
type), `doc-param-unknown` (a `---@param` the function written below does not have) and
`doc-param-duplicate` (a parameter documented twice). Their messages 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.
7 changes: 6 additions & 1 deletion l10n/server/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Opravit všechny automaticky opravitelné problémy IE Lua",
"doc.paramNameMissing": "{0} vyžaduje název parametru a za ním typ.",
"doc.paramTypeMissing": "{0} vyžaduje typ za názvem parametru.",
"doc.typeMissing": "{0} vyžaduje typ.",
"doc.paramUnknown": "Dokumentovaná funkce nemá parametr {0}.",
"doc.paramDuplicate": "Parametr {0} je v tomto komentáři již zdokumentován."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Alle automatisch behebbaren IE Lua-Probleme beheben",
"doc.paramNameMissing": "{0} benötigt einen Parameternamen, gefolgt von einem Typ.",
"doc.paramTypeMissing": "{0} benötigt einen Typ nach dem Parameternamen.",
"doc.typeMissing": "{0} benötigt einen Typ.",
"doc.paramUnknown": "Die dokumentierte Funktion hat keinen Parameter {0}.",
"doc.paramDuplicate": "Der Parameter {0} ist in diesem Kommentar bereits dokumentiert."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Corregir todos los problemas de IE Lua que se pueden corregir automáticamente",
"doc.paramNameMissing": "{0} necesita un nombre de parámetro seguido de un tipo.",
"doc.paramTypeMissing": "{0} necesita un tipo después del nombre del parámetro.",
"doc.typeMissing": "{0} necesita un tipo.",
"doc.paramUnknown": "La función documentada no tiene ningún parámetro {0}.",
"doc.paramDuplicate": "El parámetro {0} ya está documentado en este comentario."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Corriger tous les problèmes IE Lua corrigibles automatiquement",
"doc.paramNameMissing": "{0} nécessite un nom de paramètre suivi d'un type.",
"doc.paramTypeMissing": "{0} nécessite un type après le nom du paramètre.",
"doc.typeMissing": "{0} nécessite un type.",
"doc.paramUnknown": "La fonction documentée n'a pas de paramètre {0}.",
"doc.paramDuplicate": "Le paramètre {0} est déjà documenté dans ce commentaire."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Az összes automatikusan javítható IE Lua-probléma javítása",
"doc.paramNameMissing": "A(z) {0} címkéhez paraméternév és utána típus szükséges.",
"doc.paramTypeMissing": "A(z) {0} címkéhez típus szükséges a paraméternév után.",
"doc.typeMissing": "A(z) {0} címkéhez típus szükséges.",
"doc.paramUnknown": "A dokumentált függvénynek nincs {0} paramétere.",
"doc.paramDuplicate": "A(z) {0} paraméter már dokumentálva van ebben a megjegyzésben."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Correggi tutti i problemi di IE Lua correggibili automaticamente",
"doc.paramNameMissing": "{0} richiede un nome di parametro seguito da un tipo.",
"doc.paramTypeMissing": "{0} richiede un tipo dopo il nome del parametro.",
"doc.typeMissing": "{0} richiede un tipo.",
"doc.paramUnknown": "La funzione documentata non ha alcun parametro {0}.",
"doc.paramDuplicate": "Il parametro {0} è già documentato in questo commento."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"codeAction.quote": "引用符で囲む",
"codeAction.insertSpace": "閉じるバッククォートの前にスペースを挿入する",
"codeAction.fixAllOfCode": "すべての {0} の問題を修正する",
"codeAction.fixAll": "自動修正可能な IE Lua の問題をすべて修正する"
"codeAction.fixAll": "自動修正可能な IE Lua の問題をすべて修正する",
"doc.paramNameMissing": "{0} には、パラメーター名とそれに続く型が必要です。",
"doc.paramTypeMissing": "{0} には、パラメーター名の後に型が必要です。",
"doc.typeMissing": "{0} には型が必要です。",
"doc.paramUnknown": "ドキュメント化された関数にはパラメーター {0} がありません。",
"doc.paramDuplicate": "パラメーター {0} はこのコメントで既にドキュメント化されています。"
}
7 changes: 6 additions & 1 deletion l10n/server/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"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"
"codeAction.fixAll": "Fix all IE Lua auto-fixable problems",
"doc.paramNameMissing": "{0} needs a parameter name followed by a type.",
"doc.paramTypeMissing": "{0} needs a type after the parameter name.",
"doc.typeMissing": "{0} needs a type.",
"doc.paramUnknown": "The documented function has no parameter {0}.",
"doc.paramDuplicate": "Parameter {0} is already documented in this comment."
}
7 changes: 6 additions & 1 deletion l10n/server/messages.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"codeAction.quote": "따옴표로 묶기",
"codeAction.insertSpace": "닫는 백틱 앞에 공백 삽입",
"codeAction.fixAllOfCode": "모든 {0} 문제 해결",
"codeAction.fixAll": "자동 수정 가능한 모든 IE Lua 문제 해결"
"codeAction.fixAll": "자동 수정 가능한 모든 IE Lua 문제 해결",
"doc.paramNameMissing": "{0}에는 매개 변수 이름과 그 뒤에 형식이 필요합니다.",
"doc.paramTypeMissing": "{0}에는 매개 변수 이름 뒤에 형식이 필요합니다.",
"doc.typeMissing": "{0}에는 형식이 필요합니다.",
"doc.paramUnknown": "문서화된 함수에 {0} 매개 변수가 없습니다.",
"doc.paramDuplicate": "{0} 매개 변수는 이 주석에 이미 문서화되어 있습니다."
}
Loading