Skip to content

Commit

Permalink
fix(language-core): template language of .md files should be markdown
Browse files Browse the repository at this point in the history
close #4299
  • Loading branch information
johnsoncodehk committed May 14, 2024
1 parent 0f80d2d commit eae45d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/language-core/lib/plugins/file-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const plugin: VueLanguagePlugin = () => {
const sfc = parse(toString(codes));

if (sfc.descriptor.template) {
sfc.descriptor.template.lang = 'md';
transformRange(sfc.descriptor.template);
}
if (sfc.descriptor.script) {
Expand Down
2 changes: 1 addition & 1 deletion packages/language-core/lib/plugins/vue-template-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const plugin: VueLanguagePlugin = ({ modules }) => {

compileSFCTemplate(lang, template, options) {

if (lang === 'html') {
if (lang === 'html' || lang === 'md') {

const compiler = modules['@vue/compiler-dom'];

Expand Down
30 changes: 20 additions & 10 deletions packages/language-service/lib/plugins/vue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,26 @@ export function create(
},
};
};
const baseServicePlugin = mode === 'pug' ? createPugService : createHtmlService;
const baseService = baseServicePlugin({
getCustomData() {
return [
...customData,
...extraCustomData,
];
},
onDidChangeCustomData,
});
const baseService = mode === 'pug'
? createPugService({
getCustomData() {
return [
...customData,
...extraCustomData,
];
},
onDidChangeCustomData,
})
: createHtmlService({
documentSelector: ['html', 'markdown'],
getCustomData() {
return [
...customData,
...extraCustomData,
];
},
onDidChangeCustomData,
});

return {
name: `vue-template (${mode})`,
Expand Down

0 comments on commit eae45d0

Please sign in to comment.