volar-service-markdown 0.0.47 → 0.0.48
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/index.d.ts +2 -2
- package/index.js +38 -17
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DocumentSelector, type LanguageServicePlugin, type ProviderResult, type
|
|
1
|
+
import { type DocumentSelector, type LanguageServicePlugin, type ProviderResult, type LanguageServiceContext } from '@volar/language-service';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import type { DiagnosticOptions, IMdLanguageService } from 'vscode-markdown-languageservice';
|
|
4
4
|
export interface Provide {
|
|
@@ -7,6 +7,6 @@ export interface Provide {
|
|
|
7
7
|
export declare function create({ documentSelector, fileExtensions, getDiagnosticOptions, }?: {
|
|
8
8
|
documentSelector?: DocumentSelector;
|
|
9
9
|
fileExtensions?: string[];
|
|
10
|
-
getDiagnosticOptions?(document: TextDocument, context:
|
|
10
|
+
getDiagnosticOptions?(document: TextDocument, context: LanguageServiceContext): ProviderResult<DiagnosticOptions | undefined>;
|
|
11
11
|
}): LanguageServicePlugin;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -22,7 +22,28 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
22
22
|
}, } = {}) {
|
|
23
23
|
return {
|
|
24
24
|
name: 'markdown',
|
|
25
|
-
|
|
25
|
+
capabilities: {
|
|
26
|
+
codeActionProvider: {},
|
|
27
|
+
completionProvider: {
|
|
28
|
+
triggerCharacters: ['.', '/', '#'],
|
|
29
|
+
},
|
|
30
|
+
definitionProvider: true,
|
|
31
|
+
diagnosticProvider: true,
|
|
32
|
+
documentHighlightProvider: true,
|
|
33
|
+
documentLinkProvider: {
|
|
34
|
+
resolveProvider: true,
|
|
35
|
+
},
|
|
36
|
+
documentSymbolProvider: true,
|
|
37
|
+
// fileReferencesProvider: true
|
|
38
|
+
foldingRangeProvider: true,
|
|
39
|
+
hoverProvider: true,
|
|
40
|
+
referencesProvider: true,
|
|
41
|
+
renameProvider: {
|
|
42
|
+
prepareProvider: true,
|
|
43
|
+
},
|
|
44
|
+
selectionRangeProvider: true,
|
|
45
|
+
workspaceSymbolProvider: true,
|
|
46
|
+
},
|
|
26
47
|
create(context) {
|
|
27
48
|
const logger = {
|
|
28
49
|
level: vscode_markdown_languageservice_1.LogLevel.Off,
|
|
@@ -172,14 +193,14 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
172
193
|
for (const change of event.changes) {
|
|
173
194
|
switch (change.type) {
|
|
174
195
|
case 2: {
|
|
175
|
-
const document = getTextDocument(change.uri);
|
|
196
|
+
const document = getTextDocument(vscode_uri_1.URI.parse(change.uri));
|
|
176
197
|
if (document) {
|
|
177
198
|
onDidChangeMarkdownDocument.fire(document);
|
|
178
199
|
}
|
|
179
200
|
break;
|
|
180
201
|
}
|
|
181
202
|
case 1: {
|
|
182
|
-
const document = getTextDocument(change.uri);
|
|
203
|
+
const document = getTextDocument(vscode_uri_1.URI.parse(change.uri));
|
|
183
204
|
if (document) {
|
|
184
205
|
onDidCreateMarkdownDocument.fire(document);
|
|
185
206
|
}
|
|
@@ -197,29 +218,29 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
197
218
|
// TODO: Add opened files (such as untitled files)
|
|
198
219
|
// const openTextDocumentResults = this.documents.all()
|
|
199
220
|
// .filter(doc => this.isRelevantMarkdownDocument(doc));
|
|
200
|
-
return await
|
|
221
|
+
return (await Promise.all(context.env.workspaceFolders.map(findMarkdownFilesInWorkspace))).flat();
|
|
201
222
|
},
|
|
202
223
|
getContainingDocument(resource) {
|
|
203
|
-
const decoded = context.decodeEmbeddedDocumentUri(resource
|
|
224
|
+
const decoded = context.decodeEmbeddedDocumentUri(resource);
|
|
204
225
|
if (decoded) {
|
|
205
226
|
return {
|
|
206
|
-
uri:
|
|
227
|
+
uri: decoded[0],
|
|
207
228
|
children: [],
|
|
208
229
|
};
|
|
209
230
|
}
|
|
210
231
|
},
|
|
211
232
|
hasMarkdownDocument(resource) {
|
|
212
|
-
const document = getTextDocument(resource
|
|
233
|
+
const document = getTextDocument(resource);
|
|
213
234
|
return Boolean(document && matchDocument(documentSelector, document));
|
|
214
235
|
},
|
|
215
236
|
onDidChangeMarkdownDocument: onDidChangeMarkdownDocument.event,
|
|
216
237
|
onDidCreateMarkdownDocument: onDidCreateMarkdownDocument.event,
|
|
217
238
|
onDidDeleteMarkdownDocument: onDidDeleteMarkdownDocument.event,
|
|
218
239
|
async openMarkdownDocument(resource) {
|
|
219
|
-
return getTextDocument(resource
|
|
240
|
+
return getTextDocument(resource);
|
|
220
241
|
},
|
|
221
242
|
async readDirectory(resource) {
|
|
222
|
-
const directory = await fs?.readDirectory(resource
|
|
243
|
+
const directory = await fs?.readDirectory(resource) ?? [];
|
|
223
244
|
return directory
|
|
224
245
|
.filter(file => file[1] !== 0)
|
|
225
246
|
.map(([fileName, fileType]) => [
|
|
@@ -228,13 +249,13 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
228
249
|
]);
|
|
229
250
|
},
|
|
230
251
|
async stat(resource) {
|
|
231
|
-
const stat = await fs?.stat(resource
|
|
252
|
+
const stat = await fs?.stat(resource);
|
|
232
253
|
if (stat?.type === 0) {
|
|
233
254
|
return;
|
|
234
255
|
}
|
|
235
256
|
return { isDirectory: stat?.type === 2 };
|
|
236
257
|
},
|
|
237
|
-
workspaceFolders:
|
|
258
|
+
workspaceFolders: context.env.workspaceFolders,
|
|
238
259
|
};
|
|
239
260
|
return {
|
|
240
261
|
workspace,
|
|
@@ -251,7 +272,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
251
272
|
}
|
|
252
273
|
async function findMarkdownFilesInWorkspace(folder) {
|
|
253
274
|
const { fs } = context.env;
|
|
254
|
-
const files = await fs?.readDirectory(folder
|
|
275
|
+
const files = await fs?.readDirectory(folder) ?? [];
|
|
255
276
|
const docs = [];
|
|
256
277
|
await Promise.all(files.map(async ([fileName, fileType]) => {
|
|
257
278
|
if (fileType === 2 && fileName !== 'node_modules') {
|
|
@@ -261,13 +282,13 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
261
282
|
}
|
|
262
283
|
else if (fileExtensions.some(ext => fileName.endsWith('.' + ext))) {
|
|
263
284
|
const fileUri = vscode_uri_1.Utils.joinPath(folder, fileName);
|
|
264
|
-
let sourceScript = context.language.scripts.get(fileUri
|
|
285
|
+
let sourceScript = context.language.scripts.get(fileUri);
|
|
265
286
|
if (!sourceScript) {
|
|
266
287
|
if (!fsSourceScripts.has(fileUri.toString())) {
|
|
267
288
|
fsSourceScripts.set(fileUri.toString(), undefined);
|
|
268
|
-
const fileContent = await fs?.readFile(fileUri
|
|
289
|
+
const fileContent = await fs?.readFile(fileUri);
|
|
269
290
|
if (fileContent !== undefined) {
|
|
270
|
-
fsSourceScripts.set(fileUri.toString(), context.language.scripts.set(fileUri
|
|
291
|
+
fsSourceScripts.set(fileUri.toString(), context.language.scripts.set(fileUri, {
|
|
271
292
|
getText(start, end) {
|
|
272
293
|
return fileContent.substring(start, end);
|
|
273
294
|
},
|
|
@@ -278,7 +299,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
278
299
|
return undefined;
|
|
279
300
|
},
|
|
280
301
|
}));
|
|
281
|
-
context.language.scripts.delete(fileUri
|
|
302
|
+
context.language.scripts.delete(fileUri);
|
|
282
303
|
}
|
|
283
304
|
}
|
|
284
305
|
sourceScript = fsSourceScripts.get(fileUri.toString());
|
|
@@ -293,7 +314,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
else if (sourceScript) {
|
|
296
|
-
const doc = context.documents.get(
|
|
317
|
+
const doc = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
|
297
318
|
if (doc && matchDocument(documentSelector, doc)) {
|
|
298
319
|
docs.push(doc);
|
|
299
320
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Integrate vscode-markdown-languageservice into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/markdown",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@volar/language-service": "~2.
|
|
37
|
+
"@volar/language-service": "~2.3.0-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@volar/language-service": {
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "6a80c92133e154907a79eefa05603f63994214c3"
|
|
45
45
|
}
|