Skip to content

Commit

Permalink
feat: support html, css intellisense for petite-vue
Browse files Browse the repository at this point in the history
close #1471
  • Loading branch information
johnsoncodehk committed Jul 7, 2022
1 parent bb936cc commit 3307bd8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/vue-language-service/src/languageService.ts
Expand Up @@ -355,7 +355,9 @@ export function createLanguageService(
}
},
tsLs,
isSupportedDocument: (document) => document.languageId === languageId,
isSupportedDocument: (document) =>
document.languageId === languageId
&& !vueDocuments.get(document.uri) /* not petite-vue source file */,
getNameCases,
vueLsHost,
vueDocuments,
Expand Down
11 changes: 8 additions & 3 deletions packages/vue-language-service/src/plugins/vue-template.ts
Expand Up @@ -129,6 +129,10 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
},

doHover(document, position) {

if (!options.isSupportedDocument(document))
return;

const vueDocument = options.vueDocuments.fromEmbeddedDocument(document);
if (vueDocument) {
options.templateLanguagePlugin.htmlLs.setDataProviders(
Expand Down Expand Up @@ -584,9 +588,10 @@ export default function useVueTemplateLanguagePlugin<T extends ReturnType<typeof
}

function useDefaultDataProvider(uri: string) {
if (uri.endsWith('.html')) {
return false; // petite-vue
}
// commented for https://github.com/johnsoncodehk/volar/issues/1471#issuecomment-1159691270
// if (uri.endsWith('.html')) {
// return false; // petite-vue
// }
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vue-typescript/src/plugins/vue-sfc-styles.ts
Expand Up @@ -6,7 +6,7 @@ export default function (): VueLanguagePlugin {
return {

getEmbeddedFilesCount(fileName, sfc) {
return fileName.endsWith('.html') ? 0 : sfc.styles.length;
return sfc.styles.length;
},

getEmbeddedFile(fileName, sfc, i) {
Expand Down

0 comments on commit 3307bd8

Please sign in to comment.