fix(tools): formatter bracket rules, LSP compiler diagnostics, vocabulary sync

- ludic-fmt: `rows[i]`, `new []int`, `s[a..b]`, `emit(`, `~x`, list-literal
  and query-tag braces stay tight; member calls hug their paren
  (`Date.new(`, `Prefab.spawn(`); `<< >> & | ^ ~` are operators and
  `&& ||` are not — mirrored in ludic_syntax.h, LudicLexer.kt and the
  TextMate grammar. 149 of 274 tracked sources failed --check before.
- ludic-lsp: `initializationOptions.compilerDiagnostics` / `compilerPath`
  are honoured — on save the document's compilation unit is compiled and
  `file:line: error: msg` is published as a "ludicc" diagnostic (the
  option had been documented but never implemented); the workspace scan
  file is per process; bracket codes spelled as char literals
- Overlay added to LUDIC_PHASES, LudicTokens.kt, ludic-mode.el and the
  grammar (the game uses it; check-vocabulary flagged the drift)
- editors: VS Code snippets/package.json/extension.js (`${workspaceFolder}`
  and `~` expansion, PATH lookup, Apache-2.0, real repo URL), Neovim root
  markers, Helix/Zed/Sublime bin/ paths, Emacs vocabulary, JetBrains
  comments; tools/editors/README.md no longer describes C tooling
- .forgejo workflows clone `${{ github.server_url }}/${{ github.repository }}`
  so a fork or mirror tests itself; the docs publish pushes the same way

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-05 01:12:26 +03:00
parent 8fed9add66
commit e3e1bc7784
26 changed files with 746 additions and 586 deletions

View file

@ -37,9 +37,9 @@ Format on save:
## Settings
- `ludic.server.path` — where `ludic-lsp` lives. Empty = search `bin/`, then `PATH`.
- `ludic.server.path` — where `ludic-lsp` lives (`~` and `${workspaceFolder}` expand). Empty = search `bin/`, then `PATH`.
- `ludic.server.enabled` — turn the server off and keep only static highlighting.
- `ludic.compilerPath` — where `ludicc` lives, for on-save diagnostics.
- `ludic.compilerPath` — where `ludicc` lives, for on-save diagnostics (`~` and `${workspaceFolder}` expand).
- `ludic.compilerDiagnostics` — whether to run the compiler at all.
- `ludic.indentSize` — spaces per level for the formatter.
- `ludic.trace.server` — log LSP traffic (`Ludic: Show Language Server Log`).

View file

@ -12,7 +12,7 @@
],
"surroundingPairs": [["{", "}"], ["[", "]"], ["(", ")"], ["\"", "\""]],
"indentationRules": {
"increaseIndentPattern": "^((?!//).)*(\\{[^}\"']*|\\([^)\"']*|\\[[^\\]\"']*)$",
"increaseIndentPattern": "^((?!#).)*(\\{[^}\"']*|\\([^)\"']*|\\[[^\\]\"']*)$",
"decreaseIndentPattern": "^\\s*[}\\])].*$"
},
"onEnterRules": [

View file

@ -4,7 +4,7 @@
"description": "Ludic language support: syntax highlighting, formatting, and the ludic-lsp language server. Also highlights ```ludic fences in Markdown.",
"version": "1.0.0",
"publisher": "ludic",
"license": "MIT",
"license": "Apache-2.0",
"engines": {
"vscode": "^1.75.0"
},
@ -90,7 +90,7 @@
"ludic.server.path": {
"type": "string",
"default": "",
"markdownDescription": "Path to the `ludic-lsp` binary. Empty means: look in `build/ludic-lsp` under each workspace folder, then on `PATH`."
"markdownDescription": "Path to the `ludic-lsp` binary; `~` and `${workspaceFolder}` are expanded. Empty means: look in `bin/ludic-lsp` under each workspace folder, then on `PATH`."
},
"ludic.server.enabled": {
"type": "boolean",
@ -100,7 +100,7 @@
"ludic.compilerPath": {
"type": "string",
"default": "",
"markdownDescription": "Path to `ludicc`. The server shells out to it for authoritative diagnostics on save. Empty means `build/ludicc` under the workspace."
"markdownDescription": "Path to `ludicc`; `~` and `${workspaceFolder}` are expanded. The server runs it on save for the compiler's own diagnostics. Empty means `bin/ludicc` under the workspace, then `PATH`."
},
"ludic.compilerDiagnostics": {
"type": "boolean",
@ -153,6 +153,6 @@
},
"repository": {
"type": "git",
"url": "https://example.invalid/ludic"
"url": "https://git.workshopsoft.io/workshopsoft/ludic"
}
}

View file

@ -1,53 +1,52 @@
{
"game": {
"prefix": "game",
"body": ["game ${1:Name} {", "\t$0", "}"],
"description": "A game unit — compiles to an executable."
"program": {
"prefix": "program",
"body": ["program ${1:Name} {", "\t$0", "}"],
"description": "A program: one block of declarations that compiles to an executable."
},
"module": {
"prefix": "module",
"body": ["module ${1:Name} {", "\t$0", "}"],
"description": "A library unit — compiles to a shared library, no frame loop."
"property": {
"prefix": "property",
"body": ["property ${1:Name} { ${2:x}: ${3:int} = ${4:0} }"],
"description": "A property: typed fields with defaults — a per-entity component, or a record made with `new`."
},
"component": {
"prefix": "component",
"body": ["component ${1:Name} { ${2:x}: ${3:int} = ${4:0} }"],
"description": "A component: typed per-entity fields."
"model": {
"prefix": "model",
"body": ["model ${1:Name} { ${2:Position} }"],
"description": "An entity kind bundling a fixed set of properties."
},
"archetype": {
"prefix": "archetype",
"body": ["archetype ${1:Name} {", "\t${2:Pos}", "}"],
"description": "An entity kind bundling a fixed set of components."
"prefab": {
"prefix": "prefab",
"body": ["prefab ${1:Name}: ${2:Model} { ${3:Stats} { ${4:hp}: ${5:30} } }"],
"description": "A model with preset property fields; `spawn` adds only what differs."
},
"system": {
"prefix": "system",
"handler": {
"prefix": "handler",
"body": [
"system ${1:Name} phase ${2|Start,Input,FixedUpdate,Update,LateUpdate,Render|} {",
"handler ${1:Name} phase ${2|Start,Input,FixedUpdate,Update,LateUpdate,Render,Overlay|} {",
"\t$0",
"}"
],
"description": "A system that runs once per tick in its phase."
"description": "A handler that runs once per tick in its phase."
},
"system with query": {
"prefix": "systemq",
"handler with query": {
"prefix": "handlerq",
"body": [
"system ${1:Name} phase ${2|Update,FixedUpdate,LateUpdate,Render,Input|}",
" query (${3:p}) [${4:Pos}]",
"{",
"@Queries(these: [${1:Position}])",
"handler ${2:Name} phase ${3|Update,FixedUpdate,LateUpdate,Render,Input|} {",
"\t$0",
"}"
],
"description": "A system whose body runs once per matching entity."
"description": "A handler whose body runs once per matching entity, each property bound by name."
},
"for query": {
"prefix": "forq",
"body": ["for (${1:p}) in query [${2:Pos}] {", "\t$0", "}"],
"body": ["for (${1:p}) in query [${2:Position}] {", "\t$0", "}"],
"description": "Iterate every entity matching a query."
},
"spawn": {
"prefix": "spawn",
"body": ["spawn ${1:Kind} {", "\t${2:Pos} = { ${3:x} = ${4:0} }", "}"],
"description": "Create an entity of an archetype."
"body": ["spawn ${1:Kind} { ${2:Position} { ${3:x}: ${4:0} } }"],
"description": "Create an entity of a model or prefab."
},
"scene": {
"prefix": "scene",
@ -59,18 +58,18 @@
"\t}",
"}"
],
"description": "A scene with lifecycle hooks and one layer of systems."
"description": "A scene with lifecycle hooks and one layer of handlers."
},
"ui": {
"prefix": "ui",
"body": [
"ui ${1:Name} {",
"\tpanel id=${2:Root} pad=16 gap=6 align=center {",
"\tpanel id: ${2:Root} pad: 16 gap: 6 align: center {",
"\t\t$0",
"\t}",
"}"
],
"description": "A retained UI tree."
"description": "A retained UI tree, declared as data."
},
"match": {
"prefix": "match",
@ -80,17 +79,32 @@
"machine": {
"prefix": "machine",
"body": [
"machine reg(${1:R_PHASE}) {",
"\tstate ${2:Idle} = 0 {",
"machine ${1:state} {",
"\tstate ${2:Idle} {",
"\t\t$0",
"\t}",
"}"
],
"description": "A state machine over a register."
"description": "A state machine over an enum-typed variable; `become` transitions."
},
"extern fn": {
"event": {
"prefix": "event",
"body": ["event ${1:Name} { ${2:amount}: int = 0 }"],
"description": "An event payload; fire it with `emit`, listen with `@On`."
},
"listener": {
"prefix": "on",
"body": ["@On(${1:Event}) handler ${2:Name} { $0 }"],
"description": "A listener on an event, its payload fields bound by name."
},
"namespace": {
"prefix": "namespace",
"body": ["namespace ${1:Name} {", "\texport function ${2:method}() -> ${3:void} { $0 }", "}"],
"description": "A block of functions callable as Name.method(); `internal` keeps a helper private."
},
"extern function": {
"prefix": "extern",
"body": ["extern fn ${1:name}(${2:a}: ${3:int}) -> ${4:int} = \"${5:c_symbol}\""],
"body": ["extern function ${1:name}(${2:a}: ${3:int}) -> ${4:int} = \"${5:c_symbol}\""],
"description": "Bind a C symbol through the FFI."
}
}

View file

@ -19,7 +19,7 @@ let output = null;
/** Where the language server might be, in the order we should look. */
function resolveServer(folders) {
const configured = vscode.workspace.getConfiguration('ludic').get('server.path');
if (configured) return expand(configured);
if (configured) return expand(configured, folders);
const names = ['ludic-lsp', 'ludic-lsp.exe'];
for (const folder of folders) {
@ -43,18 +43,26 @@ function resolveServer(folders) {
function resolveCompiler(folders) {
const configured = vscode.workspace.getConfiguration('ludic').get('compilerPath');
if (configured) return expand(configured);
if (configured) return expand(configured, folders);
for (const folder of folders) {
for (const rel of ['bin', 'build']) {
const p = path.join(folder.uri.fsPath, rel, 'ludicc');
if (isExecutable(p)) return p;
}
}
for (const dir of (process.env.PATH || '').split(path.delimiter)) {
const p = path.join(dir, 'ludicc');
if (isExecutable(p)) return p;
}
return '';
}
function expand(p) {
return p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p;
/** A configured path may use `~` and `${workspaceFolder}`, so a project can point
* at a sibling checkout without hard-coding one machine's home directory. */
function expand(p, folders) {
const root = folders && folders.length ? folders[0].uri.fsPath : '';
const withRoot = p.replace(/\$\{workspaceFolder\}/g, root);
return withRoot.startsWith('~') ? path.join(os.homedir(), withRoot.slice(1)) : withRoot;
}
function isExecutable(p) {

View file

@ -133,12 +133,20 @@
}
},
{
"match": "\\b(enter)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"match": "\\b(become)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "keyword.control.enter.ludic" },
"1": { "name": "keyword.control.become.ludic" },
"2": { "name": "entity.name.type.scene.ludic" }
}
},
{
"match": "\\b(scene|prefab|event)\\s+(cancellable\\s+)?([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "storage.type.ludic" },
"2": { "name": "keyword.other.clause.ludic" },
"3": { "name": "entity.name.type.ludic" }
}
},
{
"match": "\\b(spawn)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
@ -172,29 +180,29 @@
},
"keyword": {
"patterns": [
{ "name": "keyword.control.ludic", "match": "\\b(if|else|while|for|in|match|machine|prefab|become|return|spawn|despawn|enable|disable|where|break|continue|new|try)\\b" },
{ "name": "keyword.control.ludic", "match": "\\b(if|else|while|for|in|match|machine|become|return|spawn|despawn|enable|disable|attach|detach|emit|cancel|where|break|continue|new|try)\\b" },
{ "name": "keyword.operator.logical.ludic", "match": "\\b(and|or|not)\\b" },
{ "name": "keyword.other.clause.ludic", "match": "\\b(phase|query|on)\\b" },
{ "name": "keyword.other.clause.ludic", "match": "\\b(phase|query|on|cancellable|public|layer|start|shows|lasts|loads|then|export|internal)\\b" },
{ "name": "keyword.other.ludic", "match": "\\b(import|extern)\\b" },
{ "name": "storage.type.ludic", "match": "\\b(program|property|model|namespace|enum|ui|const|var|let|function|handler|entry|state|test)\\b" },
{ "name": "storage.type.ludic", "match": "\\b(program|property|model|prefab|namespace|enum|ui|const|var|let|function|handler|entry|event|scene|state|test)\\b" },
{ "name": "support.type.primitive.ludic", "match": "\\b(int|long|fixed|countdown|bool|entity|string|pointer|byte|words|fixeds|pointers|Vector|IVec2|Rect|void)\\b" },
{ "name": "constant.language.boolean.ludic", "match": "\\b(true|false|null)\\b" },
{ "name": "constant.language.phase.ludic", "match": "\\b(Start|Input|FixedUpdate|Update|LateUpdate|Render)\\b" }
{ "name": "constant.language.phase.ludic", "match": "\\b(Start|Input|FixedUpdate|Update|LateUpdate|Render|Overlay)\\b" }
]
},
"widget": {
"patterns": [
{
"comment": "widget types, recognised by the props or the child block that follow them",
"comment": "widget types, recognised by the `key: value` props or the child block that follow them",
"name": "support.class.widget.ludic",
"match": "\\b(panel|col|row|label|button|image|spacer)\\b(?=\\s*(\\{|[a-z][A-Za-z0-9_]*\\s*=|$))"
"match": "\\b(panel|col|row|label|button|image|spacer)\\b(?=\\s*(\\{|[a-z][A-Za-z0-9_]*\\s*:|$))"
},
{
"comment": "widget props are written tight (id=Root); an assignment is written x = 1",
"match": "\\b([a-z][A-Za-z0-9_]*)(=)(?!=)",
"comment": "a widget prop or a named argument: `id: Root`, `x: 10`",
"match": "\\b([a-z][A-Za-z0-9_]*)(:)(?=\\s)",
"captures": {
"1": { "name": "variable.parameter.widget.ludic" },
"2": { "name": "keyword.operator.assignment.ludic" }
"1": { "name": "variable.parameter.ludic" },
"2": { "name": "punctuation.separator.ludic" }
}
}
]