Seamlessly format Vue Single File Components with Stylus support - combining the power of Prettier and Stylus Supremacy in one extension.
If you're working with Vue SFCs that use Stylus for styling, you've likely encountered the challenge of consistent formatting. Standard Prettier doesn't handle <style lang="stylus"> blocks, and manually switching between formatters is tedious.
Prettylus solves this by intelligently applying:
- Prettier for your
<template>and<script>blocks - Stylus Supremacy specifically for
<style lang="stylus">blocks - Full support for Pug templates via
@prettier/plugin-pug
The result? Perfectly formatted Vue components with a single keystroke.
Automatically detects and formats different sections of your Vue SFCs with the appropriate formatter:
<template lang="pug">
// Formatted with Prettier + Pug plugin
.container
h1.title Hello Prettylus
p.description Your Vue files never looked better
</template>
<script setup lang="ts">
// Formatted with Prettier
import { ref, computed } from 'vue'
const count = ref(0)
const doubled = computed(() => count.value * 2)
</script>
<style lang="stylus" scoped>
// Formatted with Stylus Supremacy
.container
display flex
flex-direction column
padding 2rem
.title
font-size 2rem
color #333
.description
margin-top 1rem
color #666
</style>- Vue 3 & Vue 2 Support - Works with all Vue SFC formats
- TypeScript Ready - Full support for
<script setup lang="ts"> - Multiple Style Blocks - Handles multiple
<style>tags in a single component - Scoped Styles - Preserves
scopedand other style attributes - Flexible Configuration - Customize both Prettier and Stylus Supremacy settings
- Monorepo Friendly - Configure base directories for complex project structures
- Open VS Code
- Press
Cmd+P(Mac) orCtrl+P(Windows/Linux) - Type
ext install ekqnp.prettylus - Press Enter and click Install
code --install-extension ekqnp.prettylusCreate a .prettierrc file in your project root:
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"plugins": ["@prettier/plugin-pug"],
"pugSingleQuote": false,
"pugAttributeSeparator": "none",
"pugWrapAttributesThreshold": 1
}Create a .stylusrc file in your project root:
{
"insertColons": false,
"insertSemicolons": false,
"insertBraces": false,
"insertNewLineAroundImports": true,
"insertNewLineAroundBlocks": true,
"insertSpaceBeforeComment": true,
"insertSpaceAfterComment": true,
"indentChar": " ",
"newLineChar": "\n",
"sortProperties": "alphabetical",
"alwaysUseExtends": true,
"alwaysUseNoneOverZero": true,
"alwaysUseAtBlock": true,
"alwaysUseZeroWithoutUnit": true,
"reduceMarginAndPaddingValues": true
}Configure VS Code to use Prettylus as the default formatter for Vue files. Add to your .vscode/settings.json:
{
"[vue]": {
"editor.defaultFormatter": "ekqnp.prettylus",
"editor.formatOnSave": true
},
"prettylus.stylusSupremacyConfigFileName": ".stylusrc",
"prettylus.prettierBaseDirectory": "./",
"prettylus.prettierConfigFile": ".prettierrc"
}| Setting | Description | Default |
|---|---|---|
prettylus.stylusSupremacyConfigFileName |
Name of the Stylus Supremacy config file | .stylusrc |
prettylus.prettierBaseDirectory |
Base directory for Prettier resolution (useful for monorepos) | null |
prettylus.prettierConfigFile |
Path to a specific Prettier config file | null |
For monorepo projects, you can specify where Prettier should resolve its configuration and plugins:
{
"prettylus.prettierBaseDirectory": "./packages/frontend",
"prettylus.prettierConfigFile": "./packages/frontend/.prettierrc"
}Solution: Ensure the plugin is installed in the same directory as Prettier:
npm install --save-dev prettier @prettier/plugin-pug
# or
yarn add -D prettier @prettier/plugin-pugSolution: Check that your style blocks have the correct language attribute:
<!-- β
Correct -->
<style lang="stylus">
<!-- β Incorrect -->
<style type="text/stylus">Solution: Ensure Prettylus is set as the default formatter:
- Open a
.vuefile - Right-click and select "Format Document With..."
- Choose "Configure Default Formatter..."
- Select "Prettylus"
To troubleshoot formatting issues:
- Open VS Code Output panel (
ViewβOutput) - Select "Prettylus" from the dropdown
- Check the logs for detailed formatting information
We welcome contributions! Here's how you can help:
-
Clone the repository:
git clone https://github.com/qnp/prettylus.git cd prettylus -
Install dependencies:
npm install
-
Start development:
npm run watch
-
Test the extension:
- Press
F5in VS Code to open a new Extension Development Host window - Open a Vue project and test the formatting
- Press
# Lint the code
npm run lint
# Build for production
npm run build
# Package the extension
npm run package
# Install locally for testing
npm run install- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGELOG.md for a list of changes in each version.
This project is licensed under the MIT License - see the LICENSE.txt file for details.
- Prettier - The opinionated code formatter
- Stylus Supremacy - The ultimate Stylus formatter
- @prettier/plugin-pug - Pug template formatting
Please open an issue with:
- Your VS Code version
- Your Prettylus version
- A minimal reproduction example
- The expected vs actual behavior
If Prettylus makes your Vue development experience better, please consider:
- β Starring the GitHub repository
- π Writing a review on the VS Code Marketplace
- π¦ Sharing it with your colleagues
Made with β€οΈ for the Vue + Stylus community