@@ -36,21 +36,21 @@ onBeforeUnmount(() => {
3636} ) ;
3737
3838export 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' ) ;
4343
4444 const libEs5Model = getOrCreateModel ( libEs5Url , 'typescript' , libEs5Content ) ;
4545 const libDomModel = getOrCreateModel ( libDomUrl , 'typescript' , libDomContent ) ;
4646 const libDtsModel = getOrCreateModel ( libDtsUrl , 'typescript' , libDtsContent ) ;
4747 const libPromiseModel = getOrCreateModel ( libPromiseUrl , 'typescript' , libPromiseContent ) ;
4848
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' ) ;
5454
5555 const vueModel = getOrCreateModel ( vueUrl , 'typescript' , vueContent ) ;
5656 const vueRuntimeDomModel = getOrCreateModel ( vueRuntimeDomUrl , 'typescript' , vueRuntimeDomContent ) ;
@@ -222,9 +222,6 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
222222 return monacoItem ;
223223 } ,
224224 } ) ,
225- ) ;
226-
227- disposables . value . push (
228225 monaco . languages . registerHoverProvider ( lang , {
229226 provideHover : async ( model , position ) => {
230227 const codeResult = await ls . doHover (
@@ -236,38 +233,18 @@ export async function setupLs(modelsMap: Ref<Map<string, monaco.editor.ITextMode
236233 }
237234 } ,
238235 } ) ,
239- ) ;
240-
241- disposables . value . push (
242236 monaco . languages . registerDefinitionProvider ( lang , {
243237 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 ) ;
250245 }
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- } ) ) ;
266246 } ,
267247 } ) ,
268- ) ;
269-
270- disposables . value . push (
271248 monaco . languages . registerSignatureHelpProvider ( lang , {
272249 signatureHelpTriggerCharacters : [ '(' , ',' ] ,
273250 provideSignatureHelp : async ( model , position ) => {
0 commit comments