volar-service-markdown 0.0.53 → 0.0.55
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.js +62 -22
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const vscode_markdown_languageservice_1 = require("vscode-markdown-languageservi
|
|
|
7
7
|
const vscode_uri_1 = require("vscode-uri");
|
|
8
8
|
const MarkdownIt = require("markdown-it");
|
|
9
9
|
const md = new MarkdownIt();
|
|
10
|
+
const organizeLinkDefKind = 'source.organizeLinkDefinitions';
|
|
10
11
|
function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
11
12
|
'md',
|
|
12
13
|
'mkd',
|
|
@@ -23,7 +24,14 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
23
24
|
return {
|
|
24
25
|
name: 'markdown',
|
|
25
26
|
capabilities: {
|
|
26
|
-
codeActionProvider: {
|
|
27
|
+
codeActionProvider: {
|
|
28
|
+
resolveProvider: true,
|
|
29
|
+
codeActionKinds: [
|
|
30
|
+
organizeLinkDefKind,
|
|
31
|
+
'quickfix',
|
|
32
|
+
'refactor',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
27
35
|
completionProvider: {
|
|
28
36
|
triggerCharacters: ['.', '/', '#'],
|
|
29
37
|
},
|
|
@@ -34,15 +42,16 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
34
42
|
resolveProvider: true,
|
|
35
43
|
},
|
|
36
44
|
documentSymbolProvider: true,
|
|
37
|
-
// fileReferencesProvider: true
|
|
38
45
|
foldingRangeProvider: true,
|
|
39
46
|
hoverProvider: true,
|
|
40
47
|
referencesProvider: true,
|
|
48
|
+
fileReferencesProvider: true,
|
|
41
49
|
renameProvider: {
|
|
42
50
|
prepareProvider: true,
|
|
43
51
|
},
|
|
52
|
+
fileRenameProvider: true,
|
|
44
53
|
selectionRangeProvider: true,
|
|
45
|
-
workspaceSymbolProvider:
|
|
54
|
+
workspaceSymbolProvider: {},
|
|
46
55
|
},
|
|
47
56
|
create(context) {
|
|
48
57
|
const logger = {
|
|
@@ -58,7 +67,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
58
67
|
}
|
|
59
68
|
};
|
|
60
69
|
const workspace = getMarkdownWorkspace();
|
|
61
|
-
const
|
|
70
|
+
const mdLs = (0, vscode_markdown_languageservice_1.createLanguageService)({
|
|
62
71
|
logger,
|
|
63
72
|
parser,
|
|
64
73
|
workspace: workspace.workspace,
|
|
@@ -70,23 +79,50 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
70
79
|
fsSourceScripts.delete(change.uri);
|
|
71
80
|
}
|
|
72
81
|
});
|
|
82
|
+
const codeActionDocuments = new Map();
|
|
73
83
|
return {
|
|
74
84
|
dispose() {
|
|
75
|
-
|
|
85
|
+
mdLs.dispose();
|
|
76
86
|
workspace.dispose();
|
|
77
87
|
fileWatcher?.dispose();
|
|
78
88
|
},
|
|
79
89
|
provide: {
|
|
80
|
-
'markdown/languageService': () =>
|
|
90
|
+
'markdown/languageService': () => mdLs
|
|
81
91
|
},
|
|
82
92
|
provideCodeActions(document, range, context, token) {
|
|
83
93
|
if (prepare(document)) {
|
|
84
|
-
|
|
94
|
+
if (context.only?.some(kind => kind === 'source' || kind.startsWith('source.'))) {
|
|
95
|
+
const action = {
|
|
96
|
+
title: 'Organize link definitions',
|
|
97
|
+
kind: organizeLinkDefKind,
|
|
98
|
+
data: { uri: document.uri },
|
|
99
|
+
};
|
|
100
|
+
codeActionDocuments.set(action.title, new WeakRef(document));
|
|
101
|
+
return [action];
|
|
102
|
+
}
|
|
103
|
+
return mdLs.getCodeActions(document, range, context, token);
|
|
85
104
|
}
|
|
86
105
|
},
|
|
106
|
+
async resolveCodeAction(codeAction, token) {
|
|
107
|
+
if (codeAction.kind === organizeLinkDefKind) {
|
|
108
|
+
const data = codeAction.data;
|
|
109
|
+
const document = codeActionDocuments.get(codeAction.title)?.deref();
|
|
110
|
+
if (!document) {
|
|
111
|
+
return codeAction;
|
|
112
|
+
}
|
|
113
|
+
const edits = await mdLs.organizeLinkDefinitions(document, { removeUnused: true }, token);
|
|
114
|
+
codeAction.edit = {
|
|
115
|
+
changes: {
|
|
116
|
+
[data.uri]: edits,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
return codeAction;
|
|
120
|
+
}
|
|
121
|
+
return codeAction;
|
|
122
|
+
},
|
|
87
123
|
async provideCompletionItems(document, position, _context, token) {
|
|
88
124
|
if (prepare(document)) {
|
|
89
|
-
const items = await
|
|
125
|
+
const items = await mdLs.getCompletionItems(document, position, {}, token);
|
|
90
126
|
return {
|
|
91
127
|
isIncomplete: false,
|
|
92
128
|
items
|
|
@@ -95,7 +131,7 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
95
131
|
},
|
|
96
132
|
async provideDefinition(document, position, token) {
|
|
97
133
|
if (prepare(document)) {
|
|
98
|
-
let locations = await
|
|
134
|
+
let locations = await mdLs.getDefinition(document, position, token);
|
|
99
135
|
if (!locations) {
|
|
100
136
|
return;
|
|
101
137
|
}
|
|
@@ -113,65 +149,69 @@ function create({ documentSelector = ['markdown'], fileExtensions = [
|
|
|
113
149
|
if (prepare(document)) {
|
|
114
150
|
const configuration = await getDiagnosticOptions(document, context);
|
|
115
151
|
if (configuration) {
|
|
116
|
-
return
|
|
152
|
+
return mdLs.computeDiagnostics(document, configuration, token);
|
|
117
153
|
}
|
|
118
154
|
}
|
|
119
155
|
},
|
|
120
156
|
provideDocumentHighlights(document, position, token) {
|
|
121
157
|
if (prepare(document)) {
|
|
122
|
-
return
|
|
158
|
+
return mdLs.getDocumentHighlights(document, position, token);
|
|
123
159
|
}
|
|
124
160
|
},
|
|
125
161
|
async provideDocumentLinks(document, token) {
|
|
126
162
|
if (prepare(document)) {
|
|
127
|
-
return await
|
|
163
|
+
return await mdLs.getDocumentLinks(document, token);
|
|
128
164
|
}
|
|
129
165
|
},
|
|
130
166
|
provideDocumentSymbols(document, token) {
|
|
131
167
|
if (prepare(document)) {
|
|
132
|
-
return
|
|
168
|
+
return mdLs.getDocumentSymbols(document, { includeLinkDefinitions: true }, token);
|
|
133
169
|
}
|
|
134
170
|
},
|
|
135
171
|
provideFileReferences(document, token) {
|
|
136
172
|
if (prepare(document)) {
|
|
137
|
-
return
|
|
173
|
+
return mdLs.getFileReferences(vscode_uri_1.URI.parse(document.uri), token);
|
|
138
174
|
}
|
|
139
175
|
},
|
|
140
176
|
provideFoldingRanges(document, token) {
|
|
141
177
|
if (prepare(document)) {
|
|
142
|
-
return
|
|
178
|
+
return mdLs.getFoldingRanges(document, token);
|
|
143
179
|
}
|
|
144
180
|
},
|
|
145
181
|
provideHover(document, position, token) {
|
|
146
182
|
if (prepare(document)) {
|
|
147
|
-
return
|
|
183
|
+
return mdLs.getHover(document, position, token);
|
|
148
184
|
}
|
|
149
185
|
},
|
|
150
186
|
provideReferences(document, position, referenceContext, token) {
|
|
151
187
|
if (prepare(document)) {
|
|
152
|
-
return
|
|
188
|
+
return mdLs.getReferences(document, position, referenceContext, token);
|
|
153
189
|
}
|
|
154
190
|
},
|
|
155
191
|
provideRenameEdits(document, position, newName, token) {
|
|
156
192
|
if (prepare(document)) {
|
|
157
|
-
return
|
|
193
|
+
return mdLs.getRenameEdit(document, position, newName, token);
|
|
158
194
|
}
|
|
159
195
|
},
|
|
160
196
|
provideRenameRange(document, position, token) {
|
|
161
197
|
if (prepare(document)) {
|
|
162
|
-
return
|
|
198
|
+
return mdLs.prepareRename(document, position, token);
|
|
163
199
|
}
|
|
164
200
|
},
|
|
201
|
+
async provideFileRenameEdits(oldUri, newUri, token) {
|
|
202
|
+
const result = await mdLs.getRenameFilesInWorkspaceEdit([{ oldUri, newUri }], token);
|
|
203
|
+
return result?.edit;
|
|
204
|
+
},
|
|
165
205
|
provideSelectionRanges(document, positions, token) {
|
|
166
206
|
if (prepare(document)) {
|
|
167
|
-
return
|
|
207
|
+
return mdLs.getSelectionRanges(document, positions, token);
|
|
168
208
|
}
|
|
169
209
|
},
|
|
170
210
|
provideWorkspaceSymbols(query, token) {
|
|
171
|
-
return
|
|
211
|
+
return mdLs.getWorkspaceSymbols(query, token);
|
|
172
212
|
},
|
|
173
213
|
async resolveDocumentLink(link, token) {
|
|
174
|
-
return await
|
|
214
|
+
return await mdLs.resolveDocumentLink(link, token) ?? link;
|
|
175
215
|
}
|
|
176
216
|
};
|
|
177
217
|
function prepare(document) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
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",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"url": "https://github.com/remcohaszing"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"markdown-it": "^
|
|
28
|
-
"vscode-jsonrpc": "^8.2.
|
|
29
|
-
"vscode-markdown-languageservice": "~0.5.0-alpha.
|
|
27
|
+
"markdown-it": "^14.1.0",
|
|
28
|
+
"vscode-jsonrpc": "^8.2.1",
|
|
29
|
+
"vscode-markdown-languageservice": "~0.5.0-alpha.6",
|
|
30
30
|
"vscode-uri": "^3.0.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/markdown-it": "^
|
|
33
|
+
"@types/markdown-it": "^14.1.1",
|
|
34
34
|
"vscode-languageserver-textdocument": "^1.0.11"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@volar/language-service": "~2.
|
|
37
|
+
"@volar/language-service": "~2.4.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": "2ab1ef6c5ad543e762522f80048cd73c3aa04bb6"
|
|
45
45
|
}
|