1- import { VirtualCode , buildMappings , resolveCommonLanguageId , toString } from '@volar/language-core' ;
1+ import { VirtualCode , buildMappings , toString } from '@volar/language-core' ;
22import { computed } from 'computeds' ;
33import type * as ts from 'typescript' ;
44import type { Code , Sfc , SfcBlock , VueLanguagePlugin } from '../types' ;
@@ -57,7 +57,7 @@ export function computedFiles(
5757 if ( ! file . parentCodeId ) {
5858 embeddedCodes . push ( {
5959 id : file . id ,
60- languageId : resolveCommonLanguageId ( `/dummy. ${ file . lang } ` ) ,
60+ languageId : resolveCommonLanguageId ( file . lang ) ,
6161 linkedCodeMappings : file . linkedCodeMappings ,
6262 snapshot,
6363 mappings,
@@ -71,7 +71,7 @@ export function computedFiles(
7171 parent . embeddedCodes ??= [ ] ;
7272 parent . embeddedCodes . push ( {
7373 id : file . id ,
74- languageId : resolveCommonLanguageId ( `/dummy. ${ file . lang } ` ) ,
74+ languageId : resolveCommonLanguageId ( file . lang ) ,
7575 linkedCodeMappings : file . linkedCodeMappings ,
7676 snapshot,
7777 mappings,
@@ -238,3 +238,19 @@ function fullDiffTextChangeRange(oldText: string, newText: string): ts.TextChang
238238 }
239239 }
240240}
241+
242+ export function resolveCommonLanguageId ( lang : string ) {
243+ switch ( lang ) {
244+ case 'js' : return 'javascript' ;
245+ case 'cjs' : return 'javascript' ;
246+ case 'mjs' : return 'javascript' ;
247+ case 'ts' : return 'typescript' ;
248+ case 'cts' : return 'typescript' ;
249+ case 'mts' : return 'typescript' ;
250+ case 'jsx' : return 'javascriptreact' ;
251+ case 'tsx' : return 'typescriptreact' ;
252+ case 'pug' : return 'jade' ;
253+ case 'md' : return 'markdown' ;
254+ }
255+ return lang ;
256+ }
0 commit comments