luaut-language-server 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,16 +17,24 @@ luaut-language-server --stdio
17
17
  | request | notes |
18
18
  |---|---|
19
19
  | `publishDiagnostics` | syntax, scope (redeclare, assign-to-`const`) and type errors, on open and on every keystroke |
20
- | `hover` | the type as luaut writes it — the **narrowed** type at a reference, so a guarded `v` reads `string`, not `string \| nil` |
21
- | `definition` | the binding's declaration |
20
+ | `hover` | the type as luaut writes it — the **narrowed** type at a reference, so a guarded `v` reads `string`, not `string \| nil`. Also every name in a type or definitions file: `declare` names (with their overload count), alias names, object-type properties, type parameters, `infer` names, and any type annotation, which reads as what it resolves to |
21
+ | `semanticTokens` | colours from the parser, not from patterns — see [Highlighting](#highlighting) |
22
+ | `definition` | the binding's declaration — and from an `import`, the export in the other module |
22
23
  | `references`, `documentHighlight` | every use of the binding |
23
24
  | `rename`, `prepareRename` | refuses names that are not identifiers, and builtins from the definitions files |
24
- | `completion` | members after `.` / `:`, names in scope, type names in a type position |
25
+ | `completion` | members after `.` / `:` (never the globals there), names in scope, type names in a type position; inside an `import`, module paths and the exported names |
25
26
  | `signatureHelp` | every overload, with the active parameter — `:` calls count `self` for you |
26
27
  | `documentSymbol` | functions, type aliases, top-level bindings |
27
28
 
28
- Single file, for now: `import` resolves to `any`, so cross-file navigation is
29
- not there yet. See [Not yet](#not-yet).
29
+ ### Modules
30
+
31
+ An `import` resolves to a file relative to the importer (`./x`, `../x`; the
32
+ extension may be left off, and a folder means its `index.luaut`). That module
33
+ is analyzed too, and its exports become the importer's types — so imported
34
+ values are type-checked, imported types work in annotations, and a missing
35
+ module or export is a diagnostic. Open documents are read before disk, so an
36
+ import sees unsaved edits, and a cached result is dropped as soon as anything
37
+ it imports changes.
30
38
 
31
39
  ## How it is put together
32
40
 
@@ -68,6 +76,21 @@ the `declare` statements in the definitions passed to `Analyzer`. Adding a
68
76
  global to a `.d.luaut` is all it takes for the editor to stop calling it
69
77
  undefined.
70
78
 
79
+ ### Highlighting
80
+
81
+ A word's role in luaut depends on where it stands: `extends` is a keyword in a
82
+ type and a name elsewhere, `type Foo = ...` declares an alias while `type(x)`
83
+ calls a builtin, `typeof x` in a type is a query while `typeof(v)` in code is a
84
+ call. A TextMate grammar only sees characters, so it can only guess — and
85
+ guessed `extends (` into a function call.
86
+
87
+ So `semanticTokens` classifies every token from the same lexer and AST the
88
+ analyzer uses: declarations, parameters, properties, methods, types, type
89
+ parameters, and soft keywords only where the AST did not claim the word as a
90
+ name. The grammar in the editor extension keeps just what characters decide
91
+ alone — comments, strings, numbers, reserved words — so a file looks right
92
+ before the server answers, and never disagrees with it after.
93
+
71
94
  ## Not yet
72
95
 
73
96
  - **One file at a time.** No workspace indexing, so no cross-file
@@ -75,7 +98,7 @@ undefined.
75
98
  opened.
76
99
  - **No formatting** — there is no luaut printer yet (the compiler owns
77
100
  emitting Luau, and it emits *Luau*, not luaut).
78
- - No code actions, inlay hints, semantic tokens, or folding ranges.
101
+ - No code actions, inlay hints, or folding ranges.
79
102
  - Everything `luaut-parser` does not check is invisible here too: unknown
80
103
  properties, writes to `readonly`, generic constraints at call sites,
81
104
  metatables.