volar-service-markdown 0.0.46 → 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 +44 -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,23 +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
|
-
getContainingDocument() {
|
|
203
|
-
|
|
223
|
+
getContainingDocument(resource) {
|
|
224
|
+
const decoded = context.decodeEmbeddedDocumentUri(resource);
|
|
225
|
+
if (decoded) {
|
|
226
|
+
return {
|
|
227
|
+
uri: decoded[0],
|
|
228
|
+
children: [],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
204
231
|
},
|
|
205
232
|
hasMarkdownDocument(resource) {
|
|
206
|
-
const document = getTextDocument(resource
|
|
233
|
+
const document = getTextDocument(resource);
|
|
207
234
|
return Boolean(document && matchDocument(documentSelector, document));
|
|
208
235
|
},
|
|
209
236
|
onDidChangeMarkdownDocument: onDidChangeMarkdownDocument.event,
|
|
210
237
|
onDidCreateMarkdownDocument: onDidCreateMarkdownDocument.event,
|
|
211
238
|
onDidDeleteMarkdownDocument: onDidDeleteMarkdownDocument.event,
|
|
212
239
|
async openMarkdownDocument(resource) {
|
|
213
|
-
return getTextDocument(resource
|
|
240
|
+
return getTextDocument(resource);
|
|
214
241
|
},
|
|
215
242
|
async readDirectory(resource) {
|
|
216
|
-
const directory = await fs?.readDirectory(resource
|
|
243
|
+
const directory = await fs?.readDirectory(resource) ?? [];
|
|
217
244
|
return directory
|
|
218
245
|
.filter(file => file[1] !== 0)
|
|
219
246
|
.map(([fileName, fileType]) => [
|
|
@@ -222,13 +249,13 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
222
249
|
]);
|
|
223
250
|
},
|
|
224
251
|
async stat(resource) {
|
|
225
|
-
const stat = await fs?.stat(resource
|
|
252
|
+
const stat = await fs?.stat(resource);
|
|
226
253
|
if (stat?.type === 0) {
|
|
227
254
|
return;
|
|
228
255
|
}
|
|
229
256
|
return { isDirectory: stat?.type === 2 };
|
|
230
257
|
},
|
|
231
|
-
workspaceFolders:
|
|
258
|
+
workspaceFolders: context.env.workspaceFolders,
|
|
232
259
|
};
|
|
233
260
|
return {
|
|
234
261
|
workspace,
|
|
@@ -245,7 +272,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
245
272
|
}
|
|
246
273
|
async function findMarkdownFilesInWorkspace(folder) {
|
|
247
274
|
const { fs } = context.env;
|
|
248
|
-
const files = await fs?.readDirectory(folder
|
|
275
|
+
const files = await fs?.readDirectory(folder) ?? [];
|
|
249
276
|
const docs = [];
|
|
250
277
|
await Promise.all(files.map(async ([fileName, fileType]) => {
|
|
251
278
|
if (fileType === 2 && fileName !== 'node_modules') {
|
|
@@ -255,13 +282,13 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
255
282
|
}
|
|
256
283
|
else if (fileExtensions.some(ext => fileName.endsWith('.' + ext))) {
|
|
257
284
|
const fileUri = vscode_uri_1.Utils.joinPath(folder, fileName);
|
|
258
|
-
let sourceScript = context.language.scripts.get(fileUri
|
|
285
|
+
let sourceScript = context.language.scripts.get(fileUri);
|
|
259
286
|
if (!sourceScript) {
|
|
260
287
|
if (!fsSourceScripts.has(fileUri.toString())) {
|
|
261
288
|
fsSourceScripts.set(fileUri.toString(), undefined);
|
|
262
|
-
const fileContent = await fs?.readFile(fileUri
|
|
289
|
+
const fileContent = await fs?.readFile(fileUri);
|
|
263
290
|
if (fileContent !== undefined) {
|
|
264
|
-
fsSourceScripts.set(fileUri.toString(), context.language.scripts.set(fileUri
|
|
291
|
+
fsSourceScripts.set(fileUri.toString(), context.language.scripts.set(fileUri, {
|
|
265
292
|
getText(start, end) {
|
|
266
293
|
return fileContent.substring(start, end);
|
|
267
294
|
},
|
|
@@ -272,7 +299,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
272
299
|
return undefined;
|
|
273
300
|
},
|
|
274
301
|
}));
|
|
275
|
-
context.language.scripts.delete(fileUri
|
|
302
|
+
context.language.scripts.delete(fileUri);
|
|
276
303
|
}
|
|
277
304
|
}
|
|
278
305
|
sourceScript = fsSourceScripts.get(fileUri.toString());
|
|
@@ -287,7 +314,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
287
314
|
}
|
|
288
315
|
}
|
|
289
316
|
else if (sourceScript) {
|
|
290
|
-
const doc = context.documents.get(
|
|
317
|
+
const doc = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
|
291
318
|
if (doc && matchDocument(documentSelector, doc)) {
|
|
292
319
|
docs.push(doc);
|
|
293
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
|
}
|