Skip to content

Commit 84071f1

Browse files
committed
refactor(pug): expose all options from HTML plugin
1 parent 7bf7327 commit 84071f1

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

packages/pug/index.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import type {
22
Diagnostic,
33
DiagnosticSeverity,
4-
Disposable,
54
DocumentSelector,
6-
LanguageServiceContext,
75
LanguageServicePlugin,
86
LanguageServicePluginInstance,
9-
ProviderResult,
107
} from '@volar/language-service';
118
import { transformDocumentSymbol } from '@volar/language-service';
129
import { getSourceRange } from '@volar/language-service/lib/utils/featureWorkers';
@@ -24,24 +21,11 @@ export function create({
2421
documentSelector = ['jade'],
2522
configurationSections = {
2623
autoCreateQuotes: 'html.autoCreateQuotes',
24+
autoClosingTags: '',
2725
},
28-
useDefaultDataProvider = true,
29-
getCustomData,
30-
onDidChangeCustomData,
31-
}: {
32-
documentSelector?: DocumentSelector;
33-
configurationSections?: {
34-
autoCreateQuotes: string;
35-
};
36-
useDefaultDataProvider?: boolean;
37-
getCustomData?(context: LanguageServiceContext): ProviderResult<html.IHTMLDataProvider[]>;
38-
onDidChangeCustomData?(listener: () => void, context: LanguageServiceContext): Disposable;
39-
} = {}): LanguageServicePlugin {
40-
const _htmlService = createHtmlService({
41-
useDefaultDataProvider,
42-
getCustomData,
43-
onDidChangeCustomData,
44-
});
26+
...options
27+
}: Parameters<typeof createHtmlService>[0] = {}): LanguageServicePlugin {
28+
const _htmlService = createHtmlService(options);
4529
return {
4630
name: 'pug',
4731
capabilities: {
@@ -68,7 +52,7 @@ export function create({
6852
const pugDocuments = new WeakMap<TextDocument, [number, pug.PugDocument]>();
6953
const htmlLs: html.LanguageService = htmlService.provide['html/languageService']();
7054
const pugLs = pug.getLanguageService(htmlLs);
71-
const disposable = onDidChangeCustomData?.(() => initializing = undefined, context);
55+
const disposable = options.onDidChangeCustomData?.(() => initializing = undefined, context);
7256

7357
let initializing: Promise<void> | undefined;
7458

@@ -199,11 +183,11 @@ export function create({
199183
}
200184

201185
async function initialize() {
202-
if (!getCustomData) {
186+
if (!options.getCustomData) {
203187
return;
204188
}
205-
const customData = await getCustomData(context);
206-
htmlLs.setDataProviders(useDefaultDataProvider, customData);
189+
const customData = await options.getCustomData(context);
190+
htmlLs.setDataProviders(options.useDefaultDataProvider ?? true, customData);
207191
}
208192

209193
function getPugDocument(document: TextDocument) {

0 commit comments

Comments
 (0)