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

refactor: remove "volar.usePrettier" command and docs adjustment #122

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ In this case, please execute the command to restart the language server.

Delete the `.vim/coc-settings.json` file in the "project root", and start Vim again.

## Formatter

If `coc-prettier` (v9.2.0 later) is installed, `prettier` will be run as the formatter.

If you want to use the volar's built-in formatter, set `prettier.formatterPriority` to `-1` in `.vim/coc-settings.json`.

```jsonc
{
"prettier.formatterPriority": -1,
}
```

Or set `prettier.disableLanguages` to `vue` in `.vim/coc-settings.json`.

```jsonc
{
"prettier.disableLanguages": [
"vue"
]
}
```

It can also be controlled by other `coc-prettier` settings and `.prettierignore` files.

Check the README of `coc-prettier` for details. <https://github.com/neoclide/coc-prettier/blob/master/Readme.md>

## Configuration options

- `volar.enable`: Enable coc-volar extension, default: `true`
Expand Down Expand Up @@ -87,7 +113,6 @@ Delete the `.vim/coc-settings.json` file in the "project root", and start Vim ag
- You can check the versions and settings of various packages
- client, server, vue, @vue/runtime-dom, vue-tsc, typescript related, coc-volar's configuration, and more...
- `volar.initializeTakeOverMode`: Enable Take Over Mode in your project
- `volar.usePrettier`: Disable volar formatter and enable prettier in your project
- `volar.action.restartServer`: Restart Vue server
- `volar.action.verifyAllScripts`: Verify All Scripts
- `volar.action.splitEditors`: Split `<script>`, `<template>`, `<style>` Editors
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@
"title": "Enable TakeOverMode in your project",
"category": "Volar"
},
{
"command": "volar.usePrettier",
"title": "Disable volar formatter and enable prettier in your project",
"category": "Volar"
},
{
"command": "volar.action.restartServer",
"title": "Restart Vue server",
Expand Down
20 changes: 0 additions & 20 deletions src/client/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,6 @@ export function initializeTakeOverModeCommand() {
};
}

export function usePrettierCommand() {
return async () => {
const usePrettier = await window.showPrompt('Disable volar formatter and enable prettier in your project?');

let isCocPretteir = true;
if (!extensions.all.find((e) => e.id === 'coc-prettier')) {
isCocPretteir = false;
window.showWarningMessage(`coc-prettier is not installed`);
}

if (usePrettier && isCocPretteir) {
const config = workspace.getConfiguration('volar');
const prettierConfig = workspace.getConfiguration('prettier');
config.update('formatting.enable', false);
prettierConfig.update('disableLanguages', []);
workspace.nvim.command(`CocRestart`, true);
}
};
}

function getPackageVersionFromJson(packageJsonPath: string): string | undefined {
let version: string | undefined;
try {
Expand Down
4 changes: 1 addition & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as splitEditors from './features/splitEditors';
import * as tsVersion from './features/tsVersion';
import * as verifyAll from './features/verifyAll';

import { doctorCommand, initializeTakeOverModeCommand, usePrettierCommand } from './client/commands';
import { doctorCommand, initializeTakeOverModeCommand } from './client/commands';
import { scaffoldSnippetsCompletionProvider } from './client/completions';

let apiClient: LanguageClient;
Expand Down Expand Up @@ -175,8 +175,6 @@ export async function doActivate(context: ExtensionContext, createLc: CreateLang

/** MEMO: Custom commands for coc-volar */
context.subscriptions.push(commands.registerCommand('volar.doctor', doctorCommand(context)));
/** MEMO: Custom commands for coc-volar */
context.subscriptions.push(commands.registerCommand('volar.usePrettier', usePrettierCommand()));
/** MEMO: Custom snippets completion for coc-volar */
if (getConfigScaffoldSnippetsCompletion()) {
context.subscriptions.push(
Expand Down