@@ -36,21 +36,21 @@ onBeforeUnmount(() => {
36
36
} ) ;
37
37
38
38
export async function setupLs ( modelsMap : Ref < Map < string , monaco . editor . ITextModel > > ) : Promise < LanguageService > {
39
- const libEs5Url = monaco . Uri . parse ( 'playground :///lib.es5.d.ts' ) ;
40
- const libDomUrl = monaco . Uri . parse ( 'playground :///lib.dom.d.ts' ) ;
41
- const libDtsUrl = monaco . Uri . parse ( 'playground :///lib.d.ts' ) ;
42
- const libPromiseUrl = monaco . Uri . parse ( 'playground :///lib.es2015.promise.d.ts' ) ;
39
+ const libEs5Url = monaco . Uri . parse ( 'file :///lib.es5.d.ts' ) ;
40
+ const libDomUrl = monaco . Uri . parse ( 'file :///lib.dom.d.ts' ) ;
41
+ const libDtsUrl = monaco . Uri . parse ( 'file :///lib.d.ts' ) ;
42
+ const libPromiseUrl = monaco . Uri . parse ( 'file :///lib.es2015.promise.d.ts' ) ;
43
43
44
44
const libEs5Model = getOrCreateModel ( libEs5Url , 'typescript' , libEs5Content ) ;
45
45
const libDomModel = getOrCreateModel ( libDomUrl , 'typescript' , libDomContent ) ;
46
46
const libDtsModel = getOrCreateModel ( libDtsUrl , 'typescript' , libDtsContent ) ;
47
47
const libPromiseModel = getOrCreateModel ( libPromiseUrl , 'typescript' , libPromiseContent ) ;
48
48
49
- const vueUrl = monaco . Uri . parse ( 'playground :///node_modules/vue/index.d.ts' ) ;
50
- const vueRuntimeDomUrl = monaco . Uri . parse ( 'playground :///node_modules/%40vue/runtime-dom/index.d.ts' ) ;
51
- const vueRuntimeCoreUrl = monaco . Uri . parse ( 'playground :///node_modules/%40vue/runtime-core/index.d.ts' ) ;
52
- const vueSharedUrl = monaco . Uri . parse ( 'playground :///node_modules/%40vue/shared/index.d.ts' ) ;
53
- const vueReactivityUrl = monaco . Uri . parse ( 'playground :///node_modules/%40vue/reactivity/index.d.ts' ) ;
49
+ const vueUrl = monaco . Uri . parse ( 'file :///node_modules/vue/index.d.ts' ) ;
50
+ const vueRuntimeDomUrl = monaco . Uri . parse ( 'file :///node_modules/%40vue/runtime-dom/index.d.ts' ) ;
51
+ const vueRuntimeCoreUrl = monaco . Uri . parse ( 'file :///node_modules/%40vue/runtime-core/index.d.ts' ) ;
52
+ const vueSharedUrl = monaco . Uri . parse ( 'file :///node_modules/%40vue/shared/index.d.ts' ) ;
53
+ const vueReactivityUrl = monaco . Uri . parse ( 'file :///node_modules/%40vue/reactivity/index.d.ts' ) ;
54
54
55
55
const vueModel = getOrCreateModel ( vueUrl , 'typescript' , vueContent ) ;
56
56
const vueRuntimeDomModel = getOrCreateModel ( vueRuntimeDomUrl , 'typescript' , vueRuntimeDomContent ) ;
@@ -222,9 +222,6 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
222
222
return monacoItem ;
223
223
} ,
224
224
} ) ,
225
- ) ;
226
-
227
- disposables . value . push (
228
225
monaco . languages . registerHoverProvider ( lang , {
229
226
provideHover : async ( model , position ) => {
230
227
const codeResult = await ls . doHover (
@@ -236,38 +233,18 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
236
233
}
237
234
} ,
238
235
} ) ,
239
- ) ;
240
-
241
- disposables . value . push (
242
236
monaco . languages . registerDefinitionProvider ( lang , {
243
237
provideDefinition : async ( model , position ) => {
244
- const result = await ls . findDefinition ( model . uri . toString ( ) , {
245
- line : position . lineNumber - 1 ,
246
- character : position . column - 1 ,
247
- } ) ;
248
- if ( ! result || ! result . length ) {
249
- return undefined ;
238
+ const codeResult = await ls . findDefinition (
239
+ model . uri . toString ( ) ,
240
+ monaco2code . asPosition ( position ) ,
241
+ ) ;
242
+ // TODO: can't show if only one result from libs
243
+ if ( codeResult ) {
244
+ return codeResult . map ( code2monaco . asLocation ) ;
250
245
}
251
- return result . map ( ( x ) => ( {
252
- uri : monaco . Uri . parse ( x . targetUri ) . with ( { scheme : 'playground' } ) ,
253
- range : {
254
- startLineNumber : x . targetRange . start . line + 1 ,
255
- startColumn : x . targetRange . start . character + 1 ,
256
- endLineNumber : x . targetRange . end . line + 1 ,
257
- endColumn : x . targetRange . end . character + 1 ,
258
- } ,
259
- targetSelectionRange : {
260
- startLineNumber : x . targetSelectionRange . start . line + 1 ,
261
- startColumn : x . targetSelectionRange . start . character + 1 ,
262
- endLineNumber : x . targetSelectionRange . end . line + 1 ,
263
- endColumn : x . targetSelectionRange . end . character + 1 ,
264
- } ,
265
- } ) ) ;
266
246
} ,
267
247
} ) ,
268
- ) ;
269
-
270
- disposables . value . push (
271
248
monaco . languages . registerSignatureHelpProvider ( lang , {
272
249
signatureHelpTriggerCharacters : [ '(' , ',' ] ,
273
250
provideSignatureHelp : async ( model , position ) => {
0 commit comments