About
Thanks for your watching.
I found to fix point in the doc packages/server/src/languagePlugin.ts existing on first-server.mdx and so on aren't applied
latest Volar.js version.
Reproduction
{
"name": "languge-tools-startup",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"languge-tools-startup": "link:",
"typescript": "^5.7.2"
}
}
{
"compilerOptions": {
"module": "nodenext"
}
}
packages/server/package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"bin": {
"html-language-server": "./bin/html1-language-server.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@volar/language-core": "^2.4.11",
"@volar/language-server": "^2.4.11",
"@volar/language-service": "^2.4.11",
"volar-service-css": "^0.0.62",
"volar-service-html": "^0.0.62",
"vscode-html-languageservice": "^5.3.1",
"vscode-uri": "^3.0.8"
}
}
packages/server/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src",
},
"include": ["src"],
}
Proposal to fix
packages/server/src/languagePlugin.ts
+import type { LanguagePlugin, VirtualCode, CodeMapping } from "@volar/language-core";
-import type { LanguagePlugin, VirtualCode } from "@volar/language-core";
import type { URI } from "vscode-uri";
import type * as ts from 'typescript';
export const language = {
getLanguageId(uri) {
if (uri.path.endsWith('.html1')) {
return 'html1';
}
},
+ createVirtualCode(scriptId, languageId, snapshot, ctx) {
- createVirtualCode(uri, languageId, snapshot) {
if (languageId === "html1") {
return new Html1Code(snapshot);
}
},
+ updateVirtualCode(scriptId, virtualCode, newSnapshot, ctx) {
- updateVirtualCode(uri, languageCode, snapshot) {
+ virtualCode.snapshot = newSnapshot;
- languageCode.update(snapshot);
+ return virtualCode;
- return languageCode;
},
} satisfies LanguagePlugin<URI>;
export class Html1Code implements VirtualCode {
id = "root";
languageId = "html1";
embeddedCodes: VirtualCode[] = [];
+ mappings: CodeMapping[] = [];
constructor(public snapshot: ts.IScriptSnapshot) {
this.onSnapshotUpdated();
}
public update(newSnapshot: ts.IScriptSnapshot) {
this.snapshot = newSnapshot;
this.onSnapshotUpdated();
}
public onSnapshotUpdated() {
// Do something with the snapshot
}
}
About
Thanks for your watching.
I found to fix point in the doc
packages/server/src/languagePlugin.tsexisting onfirst-server.mdxand so on aren't appliedlatest Volar.js version.
Reproduction
package.json{ "name": "languge-tools-startup", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "languge-tools-startup": "link:", "typescript": "^5.7.2" } }tsconfig.base.json{ "compilerOptions": { "module": "nodenext" } }packages/server/package.json{ "name": "server", "version": "1.0.0", "description": "", "main": "index.js", "bin": { "html-language-server": "./bin/html1-language-server.js" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@volar/language-core": "^2.4.11", "@volar/language-server": "^2.4.11", "@volar/language-service": "^2.4.11", "volar-service-css": "^0.0.62", "volar-service-html": "^0.0.62", "vscode-html-languageservice": "^5.3.1", "vscode-uri": "^3.0.8" } }packages/server/tsconfig.json{ "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "out", "rootDir": "src", }, "include": ["src"], }Proposal to fix
packages/server/src/languagePlugin.ts