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

Impl monorepo and vetur config file support #2495

Merged
merged 33 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e30b23d
Add basic project service
yoyo930021 Nov 24, 2020
85eecb3
Support global components
yoyo930021 Nov 25, 2020
18fa390
Inject getChildComponents in template service
yoyo930021 Nov 25, 2020
365b3eb
Rename normalizeResolve to normalizeFileNameResolve
yoyo930021 Nov 25, 2020
0ea03bf
Support snippetFolder
yoyo930021 Nov 26, 2020
3363b99
Refactor to autoImportSfcPlugin
yoyo930021 Nov 26, 2020
4a90ad5
Add basic mulit-root workspaces support
yoyo930021 Nov 29, 2020
5f686f2
Remove unused code
yoyo930021 Nov 30, 2020
60b579b
Fix client register capabilities error
yoyo930021 Nov 30, 2020
5325e87
Watch ts and vetur config changed
yoyo930021 Nov 30, 2020
e2e882f
Fix passing wrong config
yoyo930021 Nov 30, 2020
ef331ac
Fix wrong tsconfig or jsconfig path
yoyo930021 Dec 1, 2020
590e22e
Fix error when vue3 project startup
yoyo930021 Dec 1, 2020
0e951fc
Add monorepo tests
yoyo930021 Dec 1, 2020
d6707ca
Add vue3 test in monorepo
yoyo930021 Dec 1, 2020
c676367
Add more refresh log
yoyo930021 Dec 3, 2020
cff8892
Add friendly warning when open project
yoyo930021 Dec 3, 2020
0570cde
Remove unused client noti
yoyo930021 Dec 3, 2020
d466ba9
Add show output panel and doctor commands
yoyo930021 Dec 4, 2020
e6ef152
Refactor to EnvironmentService and watch package json
yoyo930021 Dec 6, 2020
00baf2a
Add vetur.config.js docs and refactor docs
yoyo930021 Dec 6, 2020
8d6845a
CHANGELOG
yoyo930021 Dec 6, 2020
dfbabe6
Add vueVersion in doctor info
yoyo930021 Dec 7, 2020
51ee1d0
Add can't access config file error
yoyo930021 Dec 7, 2020
6a7536f
Add warning and link in docs
yoyo930021 Dec 7, 2020
b20d5e5
CHANGELOG
yoyo930021 Dec 7, 2020
6f7fc70
Add shime type in setup doc
yoyo930021 Dec 8, 2020
2d76859
CHANGELOG
yoyo930021 Dec 8, 2020
a0132c0
Remove unused import
yoyo930021 Dec 8, 2020
1507e9f
Support yarn pnp in monorepo
yoyo930021 Dec 8, 2020
8866f41
Add yarn pnp docs
yoyo930021 Dec 8, 2020
e6e498c
Refactor DependencyService
yoyo930021 Dec 8, 2020
b72b404
Loading plugins for prettier
yoyo930021 Dec 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@
"smartStep": true,
"skipFiles": ["<node_internals>/**"]
},
{
"name": "E2E Test (Monorepo)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist-test/test/monorepo",
"--user-data-dir=${workspaceFolder}/test/monorepo/data-dir",
"--disable-extensions",
"${workspaceFolder}/test/monorepo/fixture"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist-test/test/**/*.js"],
"smartStep": true,
"skipFiles": ["<node_internals>/**"]
},
{
"type": "node",
"request": "launch",
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# Changelog

### 0.31.0

----

#### 🎉 RFC release 🎉

We support monorepo and multi-root workspace in this version.
We have also added a new config file called `vetur.config.js`.

See more: https://vetur.github.io/vetur/guide/setup.html#advanced
Reference: https://vetur.github.io/vetur/reference/

----

- Fix pug format. #2460
- Fix scss autocompletion. #2522
- Fix templates in custom blocks are parsed as root elements. #1336
- Support multi-root workspace
- Support monorepo
- Register global components
- Support `vetur.config.js` for monorepo, global components.
- Watch config file changed, Like: `package.json`, `tsconfig.json`
- Warn some probably problem when open project.
- Add `Vetur: doctor` command for debug.
- Improve docs.
- Support yarn PnP support. Thanks to contribution from [@merceyz](https://github.com/merceyz). #2478.


### 0.30.3 | 2020-11-26 | [VSIX](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/octref/vsextensions/vetur/0.30.3/vspackage)

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ Thanks to the following companies for supporting Vetur's development:

## Features

- Syntax-highlighting
- Snippet
- Emmet
- Linting / Error Checking
- Formatting
- Auto Completion
- [Component Data](https://vuejs.github.io/vetur/component-data.html): auto-completion and hover-information for popular Vue frameworks and your own custom components
- [Experimental Interpolation Features](https://vuejs.github.io/vetur/interpolation.html): auto-completion, hover information and type-checking in Vue template
- [VTI](https://vuejs.github.io/vetur/vti.html): Surface template type-checking errors on CLI
- [Syntax-highlighting](/guide/highlighting.md)
- [Snippet](/guide/snippet.md)
- [Emmet](/guide/emmet.md)
- [Linting / Error Checking](/guide/linting-error.md)
- [Formatting](/guide/formatting.md)
- [IntelliSense](/guide/intellisense.md)
- [Debugging](/guide/debugging.md)
- [Component Data](/guide/framework.md): auto-completion and hover-information for popular Vue frameworks and your own custom components
- [Experimental Interpolation Features](/guide/interpolation.md): auto-completion, hover information and type-checking in Vue template
- [VTI](/guide/vti.md): Surface template type-checking errors on CLI
- [Global components](/guide/global-components.md): support define global components.

## Quick Start

Expand All @@ -75,9 +77,8 @@ Thanks to the following companies for supporting Vetur's development:

## Limitations

- No multi root suppport yet ([#424](https://github.com/vuejs/vetur/issues/424))
- Cannot handle tsconfig from non-top-level folder ([#815](https://github.com/vuejs/vetur/issues/815))
- You can restart Vue language service when Vetur slow ([#2192](https://github.com/vuejs/vetur/issues/2192))
- yarn pnp (https://vuejs.github.io/vetur/guide/setup.html#yarn-pnp)

## Roadmap

Expand Down
21 changes: 21 additions & 0 deletions client/commands/doctorCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient';

export function generateDoctorCommand (client: LanguageClient) {
return async () => {
if (!vscode.window.activeTextEditor || !vscode.window.activeTextEditor.document.fileName.endsWith('.vue')) {
return vscode.window.showInformationMessage(
'Failed to doctor. Make sure the current file is a .vue file.'
);
}

const fileName = vscode.window.activeTextEditor.document.fileName;

const result = await client.sendRequest('$/doctor', { fileName }) as string;
const showText = result.slice(0, 1000) + '....';
const action = await vscode.window.showInformationMessage(showText, { modal: true }, 'Ok', 'Copy');
if (action === 'Copy') {
await vscode.env.clipboard.writeText(result);
}
};
}
15 changes: 6 additions & 9 deletions client/vueMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from './commands/virtualFileCommand';
import { getGlobalSnippetDir } from './userSnippetDir';
import { generateOpenUserScaffoldSnippetFolderCommand } from './commands/openUserScaffoldSnippetFolderCommand';
import { generateDoctorCommand } from './commands/doctorCommand';

export async function activate(context: vscode.ExtensionContext) {
const isInsiders = vscode.env.appName.includes('Insiders');
Expand Down Expand Up @@ -86,14 +87,8 @@ function registerRestartVLSCommand(context: vscode.ExtensionContext, client: Lan
}

function registerCustomClientNotificationHandlers(client: LanguageClient) {
client.onNotification('$/displayInfo', (msg: string) => {
vscode.window.showInformationMessage(msg);
});
client.onNotification('$/displayWarning', (msg: string) => {
vscode.window.showWarningMessage(msg);
});
client.onNotification('$/displayError', (msg: string) => {
vscode.window.showErrorMessage(msg);
client.onNotification('$/openWebsite', (url: string) => {
vscode.env.openExternal(vscode.Uri.parse(url));
});
client.onNotification('$/showVirtualFile', (virtualFileSource: string, prettySourceMap: string) => {
setVirtualContents(virtualFileSource, prettySourceMap);
Expand All @@ -102,6 +97,8 @@ function registerCustomClientNotificationHandlers(client: LanguageClient) {

function registerCustomLSPCommands(context: vscode.ExtensionContext, client: LanguageClient) {
context.subscriptions.push(
vscode.commands.registerCommand('vetur.showCorrespondingVirtualFile', generateShowVirtualFileCommand(client))
vscode.commands.registerCommand('vetur.showCorrespondingVirtualFile', generateShowVirtualFileCommand(client)),
vscode.commands.registerCommand('vetur.showOutputChannel', () => client.outputChannel.show()),
vscode.commands.registerCommand('vetur.showDoctorInfo', generateDoctorCommand(client))
);
}
52 changes: 33 additions & 19 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,38 @@ module.exports = {
repo: 'vuejs/vetur',
editLinks: true,
docsDir: 'docs',
sidebar: [
'/setup',
{
title: 'Features',
collapsable: false,
children: [
'/highlighting',
'/snippet',
'/emmet',
'/linting-error',
'/formatting',
'/intellisense',
'/debugging',
'/component-data',
'/interpolation',
'/vti'
]
}
]
nav: [
{ text: 'Guide', link: '/guide/' },
{ text: 'Reference', link: '/reference/' },
{ text: 'FAQ', link: '/guide/FAQ' },
{ text: 'Roadmap', link: 'https://github.com/vuejs/vetur/issues/873' },
{ text: 'Credits', link: '/credits' },
{ text: 'Contribution Guide', link: 'https://github.com/vuejs/vetur/wiki#contribution-guide' }
],
sidebar: {
'/guide/': [
'',
'setup',
{
title: 'Features',
collapsable: false,
children: [
'highlighting',
'snippet',
'emmet',
'linting-error',
'formatting',
'intellisense',
'debugging',
'component-data',
'interpolation',
'vti',
'global-components'
]
},
'FAQ'
],
'/reference/': ['', 'tsconfig']
}
}
};
21 changes: 11 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ You can [open an issue](https://github.com/vuejs/vetur/issues/new) for bugs or f

## Features

- [Syntax-highlighting](highlighting.md)
- [Snippet](snippet.md)
- [Emmet](emmet.md)
- [Linting / Error Checking](linting-error.md)
- [Formatting](formatting.md)
- [IntelliSense](intellisense.md)
- [Debugging](debugging.md)
- [Component Data](framework.md): auto-completion and hover-information for popular Vue frameworks and your own custom components
- [Experimental Interpolation Features](interpolation.md): auto-completion, hover information and type-checking in Vue template
- [VTI](vti.md): Surface template type-checking errors on CLI
- [Syntax-highlighting](/guide/highlighting.md)
- [Snippet](/guide/snippet.md)
- [Emmet](/guide/emmet.md)
- [Linting / Error Checking](/guide/linting-error.md)
- [Formatting](/guide/formatting.md)
- [IntelliSense](/guide/intellisense.md)
- [Debugging](/guide/debugging.md)
- [Component Data](/guide/framework.md): auto-completion and hover-information for popular Vue frameworks and your own custom components
- [Experimental Interpolation Features](/guide/interpolation.md): auto-completion, hover information and type-checking in Vue template
- [VTI](/guide/vti.md): Surface template type-checking errors on CLI
- [Global components](/guide/global-components.md): support define global components.

## Quick Start

Expand Down
8 changes: 8 additions & 0 deletions docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Main Developer: [@octref](https://github.com/octref)
Contributors:
- [@HerringtonDarkholme](https://github.com/HerringtonDarkholme)
- [@sandersn](https://github.com/sandersn)
- [@yoyo930021](https://github.com/yoyo930021)
- [@ktsn](https://github.com/ktsn)
- [@rchl](https://github.com/rchl)
- [@Uninen](https://github.com/Uninen)

Others: https://github.com/vuejs/vetur/graphs/contributors

### Attributions

Expand All @@ -15,3 +21,5 @@ Others:
- Grammar based on [vuejs/vue-syntax-highlight](https://github.com/vuejs/vue-syntax-highlight)
- Sass grammar based on [TheRealSyler/vscode-sass-indented](https://github.com/TheRealSyler/vscode-sass-indented)
- PostCSS grammar based on [hudochenkov/Syntax-highlighting-for-PostCSS](https://github.com/hudochenkov/Syntax-highlighting-for-PostCSS)
- TypeScript/JavaScript based on [TypeScript](https://github.com/microsoft/TypeScript/#readme)
- CSS/SCSS/LESS feature based on [vscode-css-languageservice](https://github.com/microsoft/vscode-css-languageservice)
3 changes: 0 additions & 3 deletions docs/framework.md

This file was deleted.

56 changes: 43 additions & 13 deletions docs/FAQ.md → docs/guide/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# FAQ

- [Install an old version of Vetur](#install-an-old-version-of-vetur)
- [No Syntax Highlighting & No Language Features working](#no-syntax-highlighting--no-language-features-working)
- [Vetur Crash](#vetur-crash)
- [Vetur can't recognize components imported using webpack's alias](#vetur-cant-recognize-components-imported-using-webpacks-alias)
- [Property 'xxx' does not exist on type 'CombinedVueInstance'](#property-xxx-does-not-exist-on-type-combinedvueinstance)
- [Vetur cannot recognize my Vue component import, such as `import Comp from './comp'`](#vetur-cannot-recognize-my-vue-component-import-such-as-import-comp-from-comp)
- [Template Interpolation auto completion does not work](#template-interpolation-auto-completion-does-not-work)
- [.vue file cannot be imported in TS file](#vue-file-cannot-be-imported-in-ts-file)
- [How to build and install from source](#how-to-build-and-install-from-source)
- [Vetur uses different version of TypeScript in .vue files to what I installed in `node_modules`.](#vetur-uses-different-version-of-typescript-in-vue-files-to-what-i-installed-in-node_modules)
- [Vetur is slow](#vetur-is-slow)

## Install an old version of Vetur

Sometimes new releases have bugs that you want to avoid. Here's an easy way to downgrade Vetur to a working version:
Expand Down Expand Up @@ -131,4 +119,46 @@ NB: It will use `typescript.tsdk` setting as the path to look for if defined, de

You can run the command `Vetur: Restart VLS (Vue Language Server)` to restart VLS.

However, we'd appreciate it if you can file a [performance issue report with a profile](https://github.com/vuejs/vetur/blob/master/.github/PERF_ISSUE.md) to help us find the cause of the issue.
However, we'd appreciate it if you can file a [performance issue report with a profile](https://github.com/vuejs/vetur/blob/master/.github/PERF_ISSUE.md) to help us find the cause of the issue.

## Vetur can't find `tsconfig.json`, `jsconfig.json` in /xxxx/xxxxxx.

If you don't have any `tsconfig.json`, `jsconfig.json` in project,
Vetur will use fallback settings. Some feature isn't work.
Like: path alias, decorator, import json.

You can add this config in correct position in project.
Or use `vetur.config.js` to set file path in project.

- [Read more project setup](/guide/setup.html#project-setup)
- [Read more `vetur.config.js`](/guide/setup.html#advanced)

If you want debug info, you can use `Vetur: show doctor info` command.
You can use `vetur.ignoreProjectWarning: false` in vscode setting to close this warning.

## Vetur can't find `package.json` in /xxxx/xxxxxx.

If you don't have any `package.json` in project, Vetur can't know vue version and component data from other libs.
Vetur assume that vue version is less than 2.5 in your project.
If the version is wrong, you will get wrong diagnostic from typescript and eslint template validation.

You can add this config in correct position in project.
Or use `vetur.config.js` to set file path in project.

- [Read more `vetur.config.js`](/guide/setup.html#advanced)

If you want debug info, you can use `Vetur: show doctor info` command.
You can use `vetur.ignoreProjectWarning: false` in vscode setting to close this warning.

## Vetur find xxx, but they aren\'t in the project root.
Vetur find the file, but it may not actually be what you want.
If it is wrong, it will cause same result as the previous two. [ref1](/guide/FAQ.html#vetur-can-t-find-tsconfig-json-jsconfig-json-in-xxxx-xxxxxx), [ref2](/guide/FAQ.html#vetur-can-t-find-package-json-in-xxxx-xxxxxx)

You can add this config in correct position in project.
Or use `vetur.config.js` to set file path in project.

- [Read more `vetur.config.js`](/guide/setup.html#advanced)

If you want debug info, you can use `Vetur: show doctor info` command.
You can use `vetur.ignoreProjectWarning: false` in vscode setting to close this warning.

50 changes: 50 additions & 0 deletions docs/guide/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Quick start

Here are five common case.

- [Vue CLI](#vue-cli)
- [Veturpack]($veturpack)
- [Laravel](#laravel-custom-project)
- [Custom project](#laravel-custom-project)
- [Monorepo](#monorepo)

## Vue CLI
[Offical Website](https://cli.vuejs.org/)
When you create project with Vue CLI,
If no use typescript, please add `jsconfig.json` at opened project root.
```json
{
"compilerOptions": {
"target": "es2015",
"module": "esnext",
"baseUrl": "./",
"paths": {
"@/*": ["components/*"]
}
},
"include": [
"src/**/*.vue",
"src/**/*.js"
]
}
```
[Add shim-types file for import Vue SFC in typescript file.](/guide/setup.html#typescript)

If use typescript, you don't need to do any thing in your project.

## Veturpack
[Github](https://github.com/octref/veturpack)
It is out of box.

## Laravel / Custom project
Please keep `package.json` and `tsconfig.json`/`jsconfig.json` at opened project root.
If you can't do it, please add `vetur.config.js` for set config file path.
[Add shim-types file for import Vue SFC in typescript file.](/guide/setup.html#typescript)

- [Read more `tsconfig.json`/`jsconfig.json`](/guide/setup.html#project-setup).
- [Read more `vetur.config.js` doc](/guide/setup.html#advanced).

## Monorepo
please add `vetur.config.js` for define projects.

- [Read more `vetur.config.js` doc](/guide/setup.html#advanced).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading