Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redesign additional extensions, VitePress, PetiteVue support #4321

Merged
merged 4 commits into from Apr 28, 2024

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Apr 28, 2024

close #4251, close #3472

Motivation

In the past, the behavior of configuring additional extensions, VitePress and PetiteVue was inconsistent between IDEs and vue-tsc is inconsistent.

For example, when "vue.server.additionalExtensions": ["nvue"] is configured, but vueCompilerOptions is set to default:

  • .nvue files become project files for the Vue language server.
  • .nvue files do not become project files for vue-tsc.
  • The Vue language server can monitor .nvue files.

When vueCompilerOptions: { "extensions": [".vue", ".nvue"] } is configured, but vue.server.additionalExtensions is set to default:

  • .nvue files become project files for the Vue language server.
  • .nvue files become project files for vue-tsc.
  • The Vue language server cannot monitor .nvue files.

This PR is to address this inconsistency. vue.server.additionalExtensions is actually not needed, and we can achieve the above 3 points by only configuring vueCompilerOptions: { "extensions": [".vue", ".nvue"] }.

Changes

  • Removed editor settings:
    • vue.server.additionalExtensions
    • vue.server.petiteVue.supportHtmlFile
    • vue.server.vitePress.supportMdFile
  • Added editor setting:
    • vue.server.includeLanguages
  • Added vueCompilerOptions:
    • vitePressExtensions
    • petiteVueExtensions

Usage

Custom Vue Extensions Support

Using .nvue extension in uni-app as an example.

  1. Add .nvue to the tsconfig/jsconfig include option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
    +    "src/**/*.nvue",
        ],
    }
  2. Add .nvue to the tsconfig/jsconfig vueCompilerOptions.extensions option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
       	 "src/**/*.nvue",
        ],
        "vueCompilerOptions": {
    +    "extensions": [".vue", ".nvue"],
        },
    }
  3. For VSCode support, add .nvue to the VSCode files.associations setting:
    // .vscode/settings.json
    {
        "files.associations": {
    +    "*.nvue": "vue"
        },
    }

VitePress Support

  1. Add .md to the tsconfig/jsconfig include option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
    +    "src/**/*.md",
        ],
    }
  2. Add .md to the tsconfig/jsconfig vueCompilerOptions.vitePressExtensions option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
       	 "src/**/*.md",
        ],
        "vueCompilerOptions": {
    +    "vitePressExtensions": [".md"],
        },
    }
  3. For VSCode support, add markdown to the VSCode vue.server.includeLanguages setting:
    // .vscode/settings.json
    {
        "vue.server.includeLanguages": [
       	 "vue",
    +    "markdown",
        ],
    }

PetiteVue Support

  1. Add .html to the tsconfig/jsconfig include option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
    +    "src/**/*.html",
        ],
    }
  2. Add .html to the tsconfig/jsconfig vueCompilerOptions.petiteVueExtensions option:
    // tsconfig.json/jsconfig.json
    {
        "include": [
       	 "src/**/*.ts",
       	 "src/**/*.vue",
       	 "src/**/*.html",
        ],
        "vueCompilerOptions": {
    +    "petiteVueExtensions": [".html"],
        },
    }
  3. For VSCode support, add html to the VSCode vue.server.includeLanguages setting:
    // .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 @volar/language-server to expose the API for dynamically registering file watchers. (Fixed by 31c9148)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vue-Official对.nvue文件支持吗 [Feature Request] VitePress markdown support in vue-tsc
1 participant