feat(language-server): add tag folding and linked editing

This commit is contained in:
2026-08-18 21:10:57 +05:30
parent bd0c1317ff
commit d9e8f5be82
5 changed files with 149 additions and 2 deletions
+20 -1
View File
@@ -19,7 +19,13 @@ import {
htmlToWrn,
type TextDocument,
} from "./index.ts";
import { htmlCompletions, htmlHover, mergeCompletions } from "./html-service.ts";
import {
htmlCompletions,
htmlFoldingRanges,
htmlHover,
htmlLinkedEditingRanges,
mergeCompletions,
} from "./html-service.ts";
import { clearHtmlRegionCache } from "./html-regions.ts";
type JsonRpc = { jsonrpc?: string; id?: number | string; method?: string; params?: any };
@@ -117,6 +123,8 @@ async function handle(message: JsonRpc): Promise<void> {
triggerCharacters: ["<", "@", ":", ".", " ", "=", '"', "/"],
},
hoverProvider: true,
foldingRangeProvider: true,
linkedEditingRangeProvider: true,
definitionProvider: true,
referencesProvider: true,
renameProvider: { prepareProvider: true },
@@ -223,6 +231,17 @@ async function handle(message: JsonRpc): Promise<void> {
result(message.id, html ?? (document ? hover(document, params.position) : null));
break;
}
case "textDocument/foldingRange": {
const document = documents.get(params.textDocument.uri);
result(message.id, document ? htmlFoldingRanges(document) : []);
break;
}
case "textDocument/linkedEditingRange": {
const document = documents.get(params.textDocument.uri);
const ranges = document ? htmlLinkedEditingRanges(document, params.position) : null;
result(message.id, ranges ? { ranges } : null);
break;
}
case "textDocument/definition": {
const document = documents.get(params.textDocument.uri);
result(message.id, document ? definitionLocation(document, params.position) : null);