Giter VIP home page Giter VIP logo

volar's Introduction

Volar

⚡ Fast Vue Language Support Extension

https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar

Volar is a Language Support plugin built specifically for Vue 3. It's based on @vue/reactivity to calculate everything on-demand, to implement native TypeScript language service level performance.

🛠️ This project is still in refactoring to make contributing easier.

[Tips] [Discord]

Sponsors

This company is sponsoring this project to improve your DX. 💪

Leniolabs_

Scale your Front-end development with our unique approach

https://www.leniolabs.com/@Leniolabs_[email protected]

Quick Start

Community's Language Client Implements

By-product

Using

Setup for Vue 2
  1. Add @vue/runtime-dom

This extension required Vue 3 types from the @vue/runtime-dom.

Vue 3 in itself includes the package @vue/runtime-dom. For Vue 2 you will have to install this package yourself:

// package.json
{
  "devDependencies": {
    "@vue/runtime-dom": "latest"
  }
}
  1. Remove Vue.extend

Template type-checking do not support with Vue.extend, you can use composition-api, vue-class-component, or export default { ... } instead of export default Vue.extend.

  1. Add tsconfig.json / jsconfig.json if you don't have

  2. Support Vue 2 template

Volar preferentially supports Vue 3. Vue 3 and Vue 2 template has some different. You need to set the experimentalCompatMode option to support Vue 2 template.

// tsconfig.json
{
  "compilerOptions": {
    ...
  },
  "vueCompilerOptions": {
    "experimentalCompatMode": 2
  },
}
Setup for Vue 3
  1. Add tsconfig.json / jsconfig.json if you don't have
Define Global Components

PR: vuejs/core#3399

Local components, Built-in components, native HTML elements Type-Checking is available with no configuration.

For Global components, you need to define GlobalComponents interface, for example:

// components.d.ts

// declare module '@vue/runtime-core' works for vue 3
// declare module 'vue' works for vue2 + vue 3
declare module 'vue' {
  export interface GlobalComponents {
    RouterLink: typeof import('vue-router')['RouterLink']
    RouterView: typeof import('vue-router')['RouterView']
  }
}

export {}

Note

You need to disable Vetur to avoid conflicts.

Recommended use css / less / scss as <style> language, because these base on vscode-css-languageservice to provide reliable language support.

If use postcss / stylus / sass, you need to install additional extension for syntax highlighting. I tried these and it works, you can also choose others.

tsconfig.json / jsconfig.json is required for now.

Also required "strict": true and "moduleResolution": "node".

Volar does not include ESLint and Prettier, but the official ESLint and Prettier extensions support Vue, so you could install these yourself if needed.

If using Vetur's Customizable Scaffold Snippets, recommend use Snippet Generator convert to VSCode Snippets.

volar's People

Contributors

alexrohleder avatar amour1688 avatar cereschen avatar cs09g avatar dependabot[bot] avatar fnlctrl avatar g-plane avatar gekkedev avatar iwanabethatguy avatar johnsoncodehk avatar klwfwdk avatar kunoacc avatar perfumere avatar posva avatar wenfangdu avatar yaegassy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.