Skip to content

Commit 50bae8a

Browse files
committed
更新格式化的代码
更新格式化的代码
1 parent f50052c commit 50bae8a

File tree

4 files changed

+145
-17
lines changed

4 files changed

+145
-17
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Vue3 Snippets, Contains code highlighting, code snippets and formatting commonly
1313

1414
You can turn on the statusbar `Auto Format Vue` switch at the bottom of vscode, which allows you to automatically format the `vue` file when you write it.
1515

16-
Or right-click to display the drop-down menu panel, click the `Vue Format` menu item to format.
16+
Or right-click to display the drop-down menu panel, click the `Format Document` menu item to format.
1717

1818
<!-- <img src="./public/2.gif" /> -->
1919
![Demo](public/2.gif)
@@ -258,9 +258,7 @@ If you think it's useful, you can leave us a [message and like it](https://marke
258258

259259
# Requirements
260260

261-
- [Js Beautify](https://github.com/beautify-web/js-beautify)
262-
- [Pug Beautify](https://github.com/vingorius/pug-beautify)
263-
- [Vue Format](https://github.com/win7killer/vue-format)
261+
- [Prettier](https://github.com/prettier/prettier)
264262
- [Vue2 Snippets](https://github.com/sdras/vue-vscode-snippets)
265263
- [Vue Syntax Highlight](https://github.com/vuejs/vue-syntax-highlight)
266264

extension.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function activate(context) {
3232
context.subscriptions.push(compileOn);
3333
context.subscriptions.push(compileOff);
3434
context.subscriptions.push(format);
35-
vscode.workspace.onWillSaveTextDocument(() => {
35+
vscode.workspace.onWillSaveTextDocument((document) => {
3636
let config = vscode.workspace.getConfiguration("vue3snippets");
3737
let isEnableOnDidSaveTextDocument = config.get("enable-compile-vue-file-on-did-save-code");
3838
if (!isEnableOnDidSaveTextDocument) { return };
@@ -41,8 +41,14 @@ function activate(context) {
4141
vscode.commands.executeCommand("vue3snippets.format");
4242
}
4343
});
44+
vscode.languages.registerDocumentFormattingEditProvider('vue', {
45+
provideDocumentFormattingEdits(document) {
46+
vscode.commands.executeCommand("vue3snippets.format");
47+
}
48+
});
4449
statusBarUi.StatusBarUi.init(vscode.workspace.getConfiguration("vue3snippets").get("enable-compile-vue-file-on-did-save-code"));
4550
}
51+
4652
exports.activate = activate;
4753
function deactivate() { };
4854
exports.deactivate = deactivate;

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+135-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"url": "https://github.com/Wscats"
1010
},
1111
"publisher": "Wscats",
12-
"version": "1.0.10",
12+
"version": "1.0.11",
1313
"license": "MIT",
1414
"engines": {
1515
"vscode": "^1.40.0"
@@ -39,7 +39,8 @@
3939
"javascript",
4040
"snippet",
4141
"api",
42-
"cnode"
42+
"cnode",
43+
"format"
4344
],
4445
"homepage": "https://github.com/wscats/vue-snippets#readme",
4546
"repository": {
@@ -70,6 +71,138 @@
7071
"type": "boolean",
7172
"default": false,
7273
"description": "Enable compile vue file on did save code."
74+
},
75+
"vue3snippets.printWidth": {
76+
"type": "integer",
77+
"default": 80,
78+
"markdownDescription": "Fit code within this line limit.",
79+
"scope": "resource"
80+
},
81+
"vue3snippets.tabWidth": {
82+
"type": "integer",
83+
"default": 2,
84+
"markdownDescription": "Number of spaces it should use per tab.",
85+
"scope": "resource"
86+
},
87+
"vue3snippets.singleQuote": {
88+
"type": "boolean",
89+
"default": false,
90+
"markdownDescription": "If true, will use single instead of double quotes.",
91+
"scope": "resource"
92+
},
93+
"vue3snippets.trailingComma": {
94+
"type": "string",
95+
"enum": [
96+
"none",
97+
"es5",
98+
"all"
99+
],
100+
"default": "es5",
101+
"markdownDescription": "Controls the printing of trailing commas wherever possible. Valid options:\n- `none` - No trailing commas\n- `es5` - Trailing commas where valid in ES5 (objects, arrays, etc)\n- `all` - Trailing commas wherever possible (function arguments).",
102+
"scope": "resource"
103+
},
104+
"vue3snippets.bracketSpacing": {
105+
"type": "boolean",
106+
"default": true,
107+
"markdownDescription": "Controls the printing of spaces inside object literals.",
108+
"scope": "resource"
109+
},
110+
"vue3snippets.jsxBracketSameLine": {
111+
"type": "boolean",
112+
"default": false,
113+
"markdownDescription": "If true, puts the `>` of a multi-line jsx element at the end of the last line instead of being alone on the next line.",
114+
"scope": "resource"
115+
},
116+
"vue3snippets.semi": {
117+
"type": "boolean",
118+
"default": true,
119+
"markdownDescription": "Whether to add a semicolon at the end of every line.",
120+
"scope": "resource"
121+
},
122+
"vue3snippets.requirePragma": {
123+
"type": "boolean",
124+
"default": false,
125+
"markdownDescription": "Vue 3 Snippets can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. This is very useful when gradually transitioning large, unformatted codebases to it.",
126+
"scope": "resource"
127+
},
128+
"vue3snippets.insertPragma": {
129+
"type": "boolean",
130+
"default": false,
131+
"markdownDescription": "Vue 3 Snippets can insert a special @format marker at the top of files specifying that the file has been formatted with it. This works well when used in tandem with the `--require-pragma` option. If there is already a docblock at the top of the file then this option will add a newline to it with the @format marker.",
132+
"scope": "resource"
133+
},
134+
"vue3snippets.useTabs": {
135+
"type": "boolean",
136+
"default": false,
137+
"markdownDescription": "Indent lines with tabs.",
138+
"scope": "resource"
139+
},
140+
"vue3snippets.proseWrap": {
141+
"type": "string",
142+
"enum": [
143+
"preserve",
144+
"always",
145+
"never"
146+
],
147+
"default": "preserve",
148+
"markdownDescription": "(Markdown) wrap prose over multiple lines.",
149+
"scope": "resource"
150+
},
151+
"vue3snippets.arrowParens": {
152+
"type": "string",
153+
"enum": [
154+
"avoid",
155+
"always"
156+
],
157+
"default": "always",
158+
"markdownDescription": "Include parentheses around a sole arrow function parameter.",
159+
"scope": "resource"
160+
},
161+
"vue3snippets.jsxSingleQuote": {
162+
"type": "boolean",
163+
"default": false,
164+
"markdownDescription": "Use single quotes instead of double quotes in JSX.",
165+
"scope": "resource"
166+
},
167+
"vue3snippets.htmlWhitespaceSensitivity": {
168+
"type": "string",
169+
"enum": [
170+
"css",
171+
"strict",
172+
"ignore"
173+
],
174+
"default": "css",
175+
"markdownDescription": "Specify the global whitespace sensitivity for HTML files.\n Valid options:\n- `css` - Respect the default value of CSS display property.\n- `strict` - Whitespaces are considered sensitive.\n- `ignores` - Whitespaces are considered insensitive.",
176+
"scope": "resource"
177+
},
178+
"vue3snippets.vueIndentScriptAndStyle": {
179+
"type": "boolean",
180+
"default": false,
181+
"markdownDescription": "Whether or not to indent the code inside `<script>` and `<style>` tags in Vue files. Some people (like the creator of Vue) don’t indent to save an indentation level, but this might break code folding in your editor.",
182+
"scope": "resource"
183+
},
184+
"vue3snippets.endOfLine": {
185+
"type": "string",
186+
"enum": [
187+
"auto",
188+
"lf",
189+
"crlf",
190+
"cr"
191+
],
192+
"default": "lf",
193+
"markdownDescription": "Specify the end of line used by Vue 3 Snippets.",
194+
"scope": "resource"
195+
},
196+
"vue3snippets.quoteProps": {
197+
"type": "string",
198+
"enum": [
199+
"as-needed",
200+
"consistent",
201+
"preserve"
202+
],
203+
"default": "as-needed",
204+
"markdownDescription": "Change when properties in objects are quoted.",
205+
"scope": "resource"
73206
}
74207
}
75208
},
@@ -92,15 +225,6 @@
92225
"path": "./syntaxes/vue.tmLanguage"
93226
}
94227
],
95-
"menus": {
96-
"editor/context": [
97-
{
98-
"when": "editorLangId == vue",
99-
"command": "vue3snippets.format",
100-
"group": "navigation"
101-
}
102-
]
103-
},
104228
"keybindings": [
105229
{
106230
"key": "ctrl+shift+f",

0 commit comments

Comments
 (0)