@staticbolt/lsp 1.0.0-beta.29 → 1.0.0-beta.31
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 +31 -0
- package/lib/index.mjs +1404 -751
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -4
- package/src/helpers/document-context.ts +36 -0
- package/src/helpers/document-elements.ts +119 -0
- package/src/helpers/document-info.ts +29 -0
- package/src/{modes → helpers}/markdown-regions.ts +25 -35
- package/src/helpers/merge-html-data.ts +79 -33
- package/src/helpers/regions.ts +101 -0
- package/src/helpers/syntax-tokens.ts +327 -0
- package/src/helpers/validation.ts +94 -0
- package/src/helpers/virtual-document.ts +109 -0
- package/src/index.ts +151 -25
- package/src/language-plugin.ts +67 -0
- package/src/projects.ts +305 -0
- package/src/services/staticbolt-service.ts +257 -0
- package/src/services/syntax-tokens-service.ts +127 -0
- package/src/services/typescript-service.ts +20 -0
- package/src/virtual-code.ts +196 -0
- package/src/helpers/config-loader.ts +0 -244
- package/src/helpers/find-projects.ts +0 -23
- package/src/html-server.ts +0 -191
- package/src/language-model-cache.ts +0 -91
- package/src/modes/embedded-support.ts +0 -150
- package/src/modes/html-mode.ts +0 -83
- package/src/modes/language-modes.ts +0 -156
- package/src/requests.ts +0 -72
- package/src/utils/arrays.ts +0 -73
- package/src/utils/document-context.ts +0 -44
- package/src/utils/find-project-root.ts +0 -24
- package/src/utils/node-fs.ts +0 -77
- package/src/utils/runner.ts +0 -56
- package/src/utils/strings.ts +0 -76
package/README.md
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
1
|
# Staticbolt lsp
|
|
2
|
+
|
|
3
|
+
The language server for Staticbolt projects, built on [Volar](https://volarjs.dev). It serves HTML and markdown files:
|
|
4
|
+
|
|
5
|
+
- Completion and hover for the tags and attributes the project's plugins declare (`lspHtmlData`), with path completion that knows the project's aliases.
|
|
6
|
+
- Links resolved the way the build resolves them.
|
|
7
|
+
- The problems plugins find (`lspValidate`).
|
|
8
|
+
- The code plugins embed in HTML (`lspEmbeddedLanguages`), such as `<script type="application/x-typescript">` bodies and the layout plugin's `{{ placeholders }}`, through TypeScript: completion, hover, diagnostics, semantic tokens, definitions, references, rename, folding, signature help, inlay hints and code actions.
|
|
9
|
+
|
|
10
|
+
## Plugin API
|
|
11
|
+
|
|
12
|
+
A plugin takes part through three optional hooks, each given the document already parsed (`DocumentInfo`: the text, every element with its attributes and ranges, `select(...tags)`, `textOf(range)` and `resolve(source)` through the project's aliases):
|
|
13
|
+
|
|
14
|
+
- `lspHtmlData()` — the tags and attributes it adds, in the [VS Code custom data](https://github.com/microsoft/vscode-html-languageservice/blob/main/docs/customData.md) format.
|
|
15
|
+
- `lspValidate(document, report)` — the problems it finds, reported at an element, an attribute or a range.
|
|
16
|
+
- `lspEmbeddedLanguages()` — the code it embeds: a `filter` for the files that carry it, `findRegions(document)` for where it sits, an optional `prelude` declaring what the code can see, and `isColouredByEditor` when the editor's grammar already colours the regions. Regions are claimed in config order, so a plugin that knows a script better than the core HTML plugin, last in the config, simply claims it first.
|
|
17
|
+
|
|
18
|
+
## TypeScript
|
|
19
|
+
|
|
20
|
+
The server runs TypeScript's API in process, so it needs a TypeScript that ships one (6.x; the native 7 builds do not). It looks, in order, at:
|
|
21
|
+
|
|
22
|
+
1. `initializationOptions.typescript.tsdk` — the directory holding `typescript.js`, `node_modules/typescript/lib` say. The VS Code extension passes VS Code's own TypeScript here unless `typescript.tsdk` is set.
|
|
23
|
+
2. A `--tsdk=<directory>` argument.
|
|
24
|
+
3. The nearest `node_modules/typescript/lib` above the working directory that has an API.
|
|
25
|
+
|
|
26
|
+
## Running
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
node node_modules/@staticbolt/lsp/lib/index.mjs --stdio
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Editors find the server through the `@staticbolt/lsp` package installed in the project.
|