feat: redesign additional extensions, VitePress, PetiteVue support #4321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
close #4251, close #3472
Motivation
In the past, the behavior of configuring additional extensions, VitePress and PetiteVue was inconsistent between IDEs and
vue-tscis inconsistent.For example, when
"vue.server.additionalExtensions": ["nvue"]is configured, butvueCompilerOptionsis set to default:.nvuefiles become project files for the Vue language server..nvuefiles do not become project files forvue-tsc..nvuefiles.When
vueCompilerOptions: { "extensions": [".vue", ".nvue"] }is configured, butvue.server.additionalExtensionsis set to default:.nvuefiles become project files for the Vue language server..nvuefiles become project files forvue-tsc..nvuefiles.This PR is to address this inconsistency.
vue.server.additionalExtensionsis actually not needed, and we can achieve the above 3 points by only configuringvueCompilerOptions: { "extensions": [".vue", ".nvue"] }.Changes
vue.server.additionalExtensionsvue.server.petiteVue.supportHtmlFilevue.server.vitePress.supportMdFilevue.server.includeLanguagesvueCompilerOptions:vitePressExtensionspetiteVueExtensionsUsage
Custom Vue Extensions Support
Using
.nvueextension in uni-app as an example..nvueto the tsconfig/jsconfigincludeandvueCompilerOptions.extensionsoptions:// tsconfig.json/jsconfig.json { "include": [ "src/**/*.ts", "src/**/*.vue", + "src/**/*.nvue", ], "vueCompilerOptions": { + "extensions": [".vue", ".nvue"], }, }.nvueto the VSCodefiles.associationssetting:// .vscode/settings.json { "files.associations": { + "*.nvue": "vue" }, }VitePress Support
.mdto the tsconfig/jsconfigincludeandvueCompilerOptions.vitePressExtensionsoptions:// tsconfig.json/jsconfig.json { "include": [ "src/**/*.ts", "src/**/*.vue", + "src/**/*.md", ], "vueCompilerOptions": { + "vitePressExtensions": [".md"], }, }markdownto the VSCodevue.server.includeLanguagessetting:// .vscode/settings.json { "vue.server.includeLanguages": [ "vue", + "markdown", ], }PetiteVue Support
.htmlto the tsconfig/jsconfigincludeandvueCompilerOptions.petiteVueExtensionsoptions:// tsconfig.json/jsconfig.json { "include": [ "src/**/*.ts", "src/**/*.vue", + "src/**/*.html", ], "vueCompilerOptions": { + "petiteVueExtensions": [".html"], }, }htmlto the VSCodevue.server.includeLanguagessetting:// .vscode/settings.json { "vue.server.includeLanguages": [ "vue", + "html", ], }Notes
Vue language server is currently unable to watch additional extensions, we need to wait for the next release of(Fixed by 31c9148)@volar/language-serverto expose the API for dynamically registering file watchers.