Repository navigation
Releases
Releases · 4Luke4/IE-Lua-Language-Server
v1.2.0
Added
- Formatting of
.menufiles (textDocument/formatting,/rangeFormattingand
/onTypeFormatting;src/server/formatting/menuFormat.ts), layout-preserving like Lua
formatting. The formatting selector (FORMAT_SELECTOR, formerlyLUA_SELECTOR) adds the
ie-menulanguage and**/*.[mM][eE][nN][uU].- Only white space the engine's lexer skips changes (IESDP, MENU file format, Lexical
structure). Each line is indented by the{ … }blocks open at its start; a line that starts
with}is indented like the line that opened the block. Trailing white space is removed and
blank lines are emptied. The spacing within a line is kept, and the lines of a string that is
not Lua (text "…") are never touched. - Each Lua chunk is formatted by the Lua rules (
formatEmbedded, new in
src/server/formatting/format.ts), its lines one level deeper than the line where it starts
(action ", or a"on its own line).`blocks outside any{ … }block hold a file's
top-level Lua and stay at level 0. A line that starts with the closing backtick or quote is
indented like the line where the chunk starts. The white space before the first Lua item on
the opening line, and after the last one on the closing line, is kept. - The character before a closing backtick, which the engine drops, stays white space or is
not touched. A chunk with a Lua syntax error (including Lua the engine sees cut short by
that dropped character) is left as written, the rest of the file is formatted, and the count
is logged. - A file with an unterminated string or
`block is not formatted (logged). The result is
lexed and extracted again and must give the same menu tokens, Lua chunks, Lua tokens and
comments, problems and lines, or nothing is changed. - Range formatting keeps the edits of the touched lines. On-type formatting uses the Lua
triggers: a line break formats the line it ended; the last character of a Lua closer, or a
}of the menu, that starts its line re-indents that line.insertFinalNewlineand
trimFinalNewlinesare honored for document formatting.
- Only white space the engine's lexer skips changes (IESDP, MENU file format, Lexical
data/luajit/manual.jsonand its generatorscripts/luajit-manual/(npm run luajit-manual,
-- --checkin the new CI jobluajit, run when the generator, the shared converter or either
data file changes; pinned sources cached by key). The data describes the LuaJIT that EEex's
"Use LuaJIT" component installs:LuaJIT/VERSION.TXTof Bubb13/InfinityLoader (pinned commit)
names the LuaJIT commit, and the text comes from that commit's documentation (extensions.html,
ext_buffer.html,ext_jit.html,ext_ffi_api.html) and from Lua BitOp 1.0.4doc/api.html
forbit.*, word for word. What exists comes from the build's own sources:lib_init.c
(libraries opened as globals and preloaded forrequire) and thelib_*.cregistrations,
with the feature flags ofmsvcbuild.bat(LUAJIT_ENABLE_LUA52COMPAT) aslj_arch.hderives
them. Every documented name must be registered, and every Lua 5.2 manual entry that the build
lacks is listed (onlybit32and its functions). Every file is verified by SHA-256; anything
the generator does not model stops it with the file and line.- Setting
ieLua.runtime.lua(lua52(default) |luajit,resourcescope, localized in every
manifest locale), read per document through the server's oneSettingsStore, now shared by
diagnostics, hover, completion and semantic tokens. Withluajit, the libraries described
(Libraryinsrc/server/hover/knowledge.ts) are the Lua 5.2 manual's minus the entries
data/luajit/manual.jsonlists as unavailable (bit32), plus the LuaJIT globalsbitandjit;
ffi,string.buffer,table.newandtable.clearare known asrequiretargets. Hover and
completion handlers read the setting before answering (then re-check the document and the
cancellation); completion items carry the runtime indata, socompletionItem/resolveuses
the same library (items without it resolve with Lua 5.2); semantic tokens are cached per
document and runtime, and a settings change sendsworkspace/semanticTokens/refreshwhen the
client supports it. Syntax validation follows the setting too (next entry). The LuaJIT and Lua
BitOp licenses, recorded verbatim in the data, are added toTHIRD_PARTY_NOTICES.md. - Syntax diagnostics by LuaJIT's own lexer and parser when
ieLua.runtime.luaisluajit
(src/server/validation/luajit.ts), in.luafiles and in every compiled form of.menu
Lua, so1LL,0x10ULL,3i,0b101and"\u{20AC}"are no longer errors there. The
checker is chosen per document; LuaJIT is loaded on first use. When the setting changes, open
documents whose diagnostics came from the other compiler are checked again, in every validate
mode. Messages are LuaJIT's own (near '<eof>'maps to the end of the chunk:
parseLuaError(raw, dialect)inluaError.ts). Productiondist/server/server.jsgrows from
810,957 to 1,058,231 bytes.third_party/luajit/(npm run build:wasm:luajit,-- --checkin the new CI job
luajit-wasm): theLuaJIT/directory of Bubb13/InfinityLoader at the commit the LuaJIT
manual data uses, fetched with git and verified by its tree hash (source.mts), is built to
WebAssembly following LuaJIT'ssrc/Makefileandmsvcbuild.bat(host tools compiled by
emcc and run by Node). Everylj_*.candlib_*.cis compiled unchanged, with
msvcbuild.bat'sLUAJIT_ENABLE_LUA52COMPATand the target optionsLUAJIT_TARGET=x86,
LUAJIT_DISABLE_JITandLUAJIT_SECURITY_PRNG=0; byte-for-byte reproducible.validate.creplaces the interpreter that buildvm generates as machine code (no WebAssembly
target):lj_vm_cpcallandlj_vm_unwind_cwithsetjmp/longjmp, throughlj_frame.h's
cframe_*macros;lj_vm_floorwithfloor(); the entry points that would run Lua code or
FFI calls stop the module with a message. It loads with mode"tX", which lays out frames in
two slots as EEex's x64 GC64 build does, and opens the FFI library once so that no finalizer
ever needs the interpreter.third_party/luajit/differential.mts(npm run luajit-differential, CI): builds a native
x64 LuaJIT from the same tree and fails if any chunk oftest/fixtures/luajit-syntax/or of
the generated limit cases (call arguments, nesting, locals, upvalues) gets a different answer.
- LuaJIT's lexical extensions in the server's own lexer (
src/server/syntax/lexer.ts) when
ieLua.runtime.luaisluajit, so hover, completion, semantic tokens, folding, document and
workspace symbols, definition, references, rename and formatting work on files that use them
(formatting refused such files as having syntax errors). Ported from the pinned LuaJIT tree:
numerals are read aslj_lex.clex_numberreads them and checked aslj_strscan_scandoes
withSTRSCAN_OPT_LL | STRSCAN_OPT_IMAG(isLuaJitNumber:LL/ULL/LLUon integers that
fit in 64 bits,ion any number,0bwith at most 64 binary digits, exponent and fraction
limits of 2^20);\u{X…}escapes followlex_string(below U+110000, no surrogates). Lua 5.2
lexing is unchanged. Names stay ASCII in both modes (LuaJIT also accepts bytes from 0x80 in
names).lex(source, from, to, runtime),ParseOptions.runtime,Chunk.runtime,
ParsedDocument.runtimeandparseDocument(text, kind, runtime); the formatter, rename and
completion lex again with the tree's runtime.ParsedDocumentCache.get(document, runtime)reuses a parse only for the same version and
runtime; features read the runtime per document first (src/server/features/openDocument.ts).
The workspace index parses files that are not open with their folder's runtime
(WorkspaceIndexDeps.analysisOptions) and re-indexes when it changes.test/unit/server/syntax/luajitDifferential.test.tscompares the parser with the LuaJIT
WebAssembly module ontest/fixtures/luajit-syntax/(except goto/label semantics), every
numeral of up to four characters, 64-bit and exponent limits,\u{…}boundaries and token
mutations of LuaJIT seeds. The mutation helper moved totest/unit/server/syntax/mutations.ts.
- Method syntax in hover, completion and semantic tokens (
src/server/hover/receiver.ts, through
memberTargetinsrc/server/hover/resolve.ts). A receiver is typed only when the code or a
LuaCATS annotation proves it; anything else gets nothing:- strings: a string literal (parenthesized or not), a local declared from one and never
assigned again (aliases followed), or a local or parameter annotated---@type string/
---@param x string.s:m()ands.marestring.m(manual §6.4; LuaJIT's lib_string.c
sets the same__index). Astring.mthe document defines is described by that definition. - tables: global paths (also through locals that alias them:
local w = worldScreen,
local str = string,local g = _G), locals declared from a table constructor and never
assigned again, fields of them, the implicitselfoffunction T:m()(asT), and values
annotated---@type Name/---@param x Namefor a---@class Nameattached to
local Name = …orName = …. Members are the library and EEex-Docs names as before, then the
functions the document stores in the table:function T:m(),function T.f(),
T.f = function, and{ f = function }in the constructor of a local. They are a new hover
target,member, rendered as(method) function T:m(a)/(field) function T.f(a)(labels
localized inl10n/server/) with the doc comment above the definition
(functionDocinsrc/server/docComments/attach.ts); hovering the name in the definition
shows the same. Semantic tokens type themmethodorfunction. - LuaJIT: `require...
- strings: a string literal (parenthesized or not), a local declared from one and never
v1.0.0
Added
- Language server (separate Node process; IPC in VS Code,
--stdiofor other editors) with
syntax diagnostics from the official Lua 5.2.4 compiler, built to WebAssembly from the
checksum-verified lua.org tarball (third_party/lua52/, reproducible build checked in CI). .menusupport: newie-menulanguage (case-insensitive.menuextension), TextMate grammar
that highlights the engine's keywords and embeds Lua where validation finds it, and validation of the Lua the engine compiles, found with a lexer
that follows the engine's (per IESDP):
`…`blocks;onOpen,onCloseandaction*scripts; and the expressions ofenabled,
actionDrag,table,seperator,useOverlayTint,bitmap resand everyluavalue. A value
can be"…",'…'or an unquoted word that is not a keyword, anywhere on a line. Each is
compiled in the shape the engine compiles it: property code as the body of
function f () … end(so...and a trailing--comment are errors), expressions as its
returnvalue, and`…`blocks without their last character, which the engine drops.
slotinfo,spellInfoandmemorizedSpellInfostrings are checked in every expression and
statement the engine generates from them (T.item.icon,Infinity_SwapSlot(T.id), …)..menudiagnostics for text the engine misreads (codes are stable):menu-unterminated-string
for"and'strings,menu-unterminated-block, and the newmenu-word-too-long(error: an
unquoted word of 64 or more characters aborts the game),menu-inline-lua-last-character
(warning: the character before a closing backtick is dropped) andmenu-unquoted-underscore
(warning: unquotedMy_Menuis read asMyandMenu).- Settings
ieLua.validate.mode(manual,save(default),type,saveAndType) and
ieLua.validate.debounce(default 300 ms). - Command IE Lua: Validate Current File (
ieLua.validateDocument). - Document symbols (
textDocument/documentSymbol; outline, breadcrumbs, Go to Symbol in
Editor): functions and methods at any depth, top-level locals, the first assignment to each
global, and named table fields; in.menufiles, eachmenublock by itsname, holding the
Lua symbols inside it. FlatSymbolInformationfor clients without hierarchical support. - Folding ranges (
textDocument/foldingRange): function bodies,do/while/for/repeat,
eachif/elseif/elseclause, multi-line tables, call arguments and long strings, long
comments and runs of--lines; in.menufiles every{ … }block,`…`blocks and
"…"scripts, plus the Lua inside them. The closing line stays visible. Honors the client's
rangeLimitand supported kinds. - Go to definition (
textDocument/definition): from any use of a local to its declaration, and
from a global to every assignment to it (x = …,function x()), in the document and in
every other.luaand.menufile of the workspace. The engine runs "in one global Lua state
that is shared by the MENU file, the game's own Lua files and the engine"
(IESDP), so a
global is matched by name in every file; locals stay in their own chunk. No result for the
implicitself, for globals no file assigns (game, EEex and library functions), or for table
fields. - Find references (
textDocument/references), with the same matching as go to definition: the
uses of a local, including the implicitselfof a method, or every use of a global in the
document and in the other files.includeDeclarationdecides whether the local's
declaration, or the assignments to the global, are included. - Across files, for go to definition and find references: the other files are the open
documents, whose unsaved text wins over the saved file, and the files of the workspace index
(the files of workspace symbols,files.excludehonored). The document's own results come
first, then the other files in URI order. A request waits for files still queued for
indexing, and answersContentModified(LSP 3.17) if the document changed meanwhile._ENV,
and names resolved through a local_ENV(fields of that table, Lua 5.2 manual §2.2), are not
globals: they have no definition or references, in the document or elsewhere. - Rename (
textDocument/prepareRename,textDocument/rename) within the document, for locals
and for globals the document assigns. Refused, with a reason localized in VS Code: anything
that is not a variable (including_ENVand names resolved through a local_ENV), the
implicitself, globals the document never assigns (defined in another file, the game or
EEex), code with syntax errors where the variable can occur, new names that are not Lua names
or are reserved words, and any rename that would change what a name
refers to, including moving a name into or out of a local_ENV(checked by re-analyzing the
renamed text). Edits are versioned when the client
supportsdocumentChanges. - Workspace symbols (
workspace/symbol; Go to Symbol in Workspace): the outline symbols of every
.luaand.menufile (any letter case) in thefile:workspace folders, and of every open
document, whose unsaved text wins over the file. The query matches loosely (its characters in
order, case-insensitively), as LSP recommends. Files are indexed in the background, one per
event-loop turn, and kept current through watched-file events (**/*.[lL][uU][aA],
**/*.[mM][eE][nN][uU], and creates and deletes of folders), workspace folder changes and
document closes.files.excludeis 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 verbatim and a link to the entry:
the basic functions and thestring,table,math,bit32anddebuglibraries, the ones
the engine opens (IESDP), also as_G.string.formatand("x"):rep(). The text is generated
fromdoc/manual.htmlof 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
coroutineare 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 asC.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.menufile. - 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.
- Lua 5.2 library functions, values and module tables, with the text of the
- 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
selfincluded), then the globals the document assigns (in any Lua chunk of a.menufile),
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_ENVis visible, only
locals and keywords. Keywords are the 22 reserved words (manual §3.1); in.menuexpressions
(enabled "…", …) onlynil,false,true,function,not,andandor(§3.4). - Members of globals (
_G.prefixes removed): after_G.the globals; aftert.andt:the
fields the document assigns ont; the manual's members ofstring,table,math,
bit32anddebug, 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
.menufile, or where a name
is declared (afterlocal,function,for,goto,::, in their name lists and in
parameter lists).io,os,package(require) andcoroutineare 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 supportsitemDefaults.editRange, as an insert/replace edit
when it supportsinsertReplaceSupport.
- Variables: the locals visible at the cursor (the innermost of each name, the implicit
- Semantic tokens (
textDocument/semanticTokens/full,/full/deltaand/range) for the names
in the Lua of.luaand.menufiles, classified by the rules of hover so that a name is
colored as it hovers. Keywords, literals, comments and.menusyntax are left to the TextMate
grammars.- Types (all standard):
namespace,function,method,variable,parameter,property,
label. Modifiers:declaration,modification,defaultLibrary, andglobal, declared
in the manifest (`contributes.s...
- Types (all standard):