├── .gitignore ├── .github └── FUNDING.yml ├── test.dprint.json ├── src ├── lib.rs ├── plugin.rs ├── configuration.rs └── format.rs ├── dprint.json ├── Cargo.toml ├── test └── file.vue ├── LICENSE ├── README.md └── CHANGELOG.md /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: malobre 2 | -------------------------------------------------------------------------------- /test.dprint.json: -------------------------------------------------------------------------------- 1 | { 2 | "incremental": true, 3 | "includes": ["test/*.vue"], 4 | "excludes": [], 5 | "plugins": [ 6 | "https://plugins.dprint.dev/typescript-0.62.2.wasm", 7 | "./target/wasm32-unknown-unknown/release/dprint_plugin_vue.wasm" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | mod configuration; 2 | mod format; 3 | mod plugin; 4 | 5 | #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] 6 | mod wasm { 7 | use crate::{configuration::Configuration, plugin::VuePluginHandler}; 8 | use dprint_core::plugins::SyncPluginHandler; 9 | dprint_core::generate_plugin_code!(VuePluginHandler, VuePluginHandler::new()); 10 | } 11 | -------------------------------------------------------------------------------- /dprint.json: -------------------------------------------------------------------------------- 1 | { 2 | "incremental": true, 3 | "includes": ["**/*.{json,md,toml}"], 4 | "excludes": [ 5 | "target" 6 | ], 7 | "markdown": { 8 | "textWrap": "always" 9 | }, 10 | "plugins": [ 11 | "https://plugins.dprint.dev/json-0.14.1.wasm", 12 | "https://plugins.dprint.dev/markdown-0.12.2.wasm", 13 | "https://plugins.dprint.dev/toml-0.5.4.wasm" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dprint-plugin-vue" 3 | version = "0.5.0" 4 | edition = "2021" 5 | license = "MIT" 6 | 7 | [lib] 8 | crate-type = ["lib", "cdylib"] 9 | 10 | [profile.release] 11 | opt-level = 3 12 | debug = false 13 | lto = true 14 | debug-assertions = false 15 | overflow-checks = false 16 | panic = "abort" 17 | 18 | [dependencies] 19 | anyhow = "1.0.52" 20 | dprint-core = { version = "0.59", features = ["wasm"] } 21 | serde = { version = "1.0.136", features = ["derive"] } 22 | serde_json = "1" 23 | vue-sfc = "0.3.2" 24 | -------------------------------------------------------------------------------- /test/file.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Maël Obréjan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dprint-plugin-vue 2 | 3 | Format Vue SFC. 4 | 5 | This plugin format root-level blocks through `dprint`, meaning you will need to 6 | install plugins for the languages contained in your Vue SFCs. 7 | 8 | ## Block default language 9 | 10 | Unless a `lang` attribute is present: 11 | 12 | | Block | Default | 13 | | ---------- | ------- | 14 | | `script` | `js` | 15 | | `template` | `html` | 16 | | `style` | `css` | 17 | 18 | ## Usage 19 | 20 | [Install](https://dprint.dev/install) and [setup](https://dprint.dev/setup) 21 | dprint, then: 22 | 23 | 1. Run 24 | ```shell 25 | dprint config add malobre/vue 26 | ``` 27 | 2. Install plugins for the languages contained in your vue files. 28 | 3. Ensure `.vue` file extensions are matched in an `includes` pattern: 29 | ```jsonc 30 | { 31 | // -- snip -- 32 | "includes": [ 33 | "**/*.vue" 34 | ] 35 | } 36 | ``` 37 | 4. Add a `vue` configuration property if desired: 38 | ```jsonc 39 | { 40 | // -- snip -- 41 | "vue": { 42 | // vue config goes here 43 | } 44 | } 45 | ``` 46 | 47 | ## Configuration 48 | 49 | | Key | Default | Description | 50 | | ---------------- | ------- | ------------------------------------------ | 51 | | `indentTemplate` | `true` | Indent the content of the `