@devaloop/prettier-plugin-devalang
Version:
Prettier plugin for Devalang formatting
144 lines (93 loc) β’ 5.03 kB
Markdown
<div align="center">
<img src="https://devalang.com/images/devalang-logo-cyan.svg" alt="Devalang Logo" width="300" />
</div>





# πΆ [Devalang](https://github.com/devaloop-labs/devalang) (Prettier Plugin)
πΆ Compose music with code β structured, expressive, and fast.
[Devalang](https://github.com/devaloop-labs/devalang) is a tiny domain-specific language (DSL) for music makers, sound designers, and audio hackers.
Compose loops, control samples, render and play audio β all in clean, readable text.
π¦ Whether you're building a track, shaping textures, or performing live, Devalang helps you think in rhythms. Itβs designed to be simple, expressive, and fast β because your ideas shouldnβt wait.
From studio sketches to live sets, Devalang gives you rhythmic control β with the elegance of code.
## π Quick Access
- [βΆοΈ Playground](https://playground.devalang.com)
- [π Documentation](https://docs.devalang.com)
- [π Devalang CLI Github](https://github.com/devaloop-labs/devalang)
- [π§© VSCode Extension](https://marketplace.visualstudio.com/items?itemName=devaloop.devalang-vscode)
- [π Changelog](https://github.com/devaloop-labs/devalang/blob/main/docs/CHANGELOG.md)
- [π‘ Examples](https://github.com/devaloop-labs/devalang/tree/main/examples)
- [π Project Website](https://devalang.com)
- [π¦ Devalang CLI on npm](https://www.npmjs.com/package/@devaloop/devalang)
## Features
πΉ **Clean formatting for `.deva` files**
Say goodbye to messy indentation and inconsistent spacing. Your Devalang code is auto-magically formatted with precision π§Ή
πΈ **Preserves blank lines & comments**
Comments (`# like this`) and intentional spacing are respected β because context matters π¬
πΉ **Smart indentation for blocks**
Handles `loop`, `group`, and conditional `if / else if / else` blocks with proper indentation, just like you'd expect π§
πΈ **Seamless integration**
Works out of the box in **VS Code**, Prettier, and any compatible editor π»βοΈ
---
π§© Built with love to make your Devalang experience smoother and your files prettier!
## Installation
To install the plugin, run the following command:
```bash
npm install --save-dev @devaloop/prettier-plugin-devalang
```
## Usage
To use the plugin, you need to configure Prettier to recognize it. You can do this by adding the following configuration to your `.prettierrc` file:
```json
{
"plugins": ["@devaloop/prettier-plugin-devalang"]
}
```
You can also specify the plugin directly in the Prettier CLI command:
```bash
npx prettier --plugin=@devaloop/prettier-plugin-devalang --write your-file.deva
```
## Example
Here's an example of how to format a Devalang file using the plugin:
```deva
@import { trigger, params } from "./my-module.deva"
# This is a comment
.trigger 1/4 {
drive:50
}
loop 10:
.trigger 1/8 params
.trigger 1500 { drive: 50 }
.trigger auto args
```
After formatting with Prettier, it will look like this:
```deva
@import { trigger, params } from "./my-module.deva"
# This is a comment
.trigger 1/4 { drive: 50 }
loop 10:
.trigger 1/8 params
.trigger 1500 { drive: 50 }
.trigger auto args
```
The plugin automatically indents the code and ensures consistent formatting across your Devalang files.
## Development
To contribute to the development of this plugin, you can clone the repository and run the following commands:
```bash
> git clone https://github.com/devaloop-labs/prettier-plugin-devalang.git
> cd prettier-plugin-devalang
> npm install
> npm run test
```
This will build the plugin and run the test file located in `test/index.js`.
NOTE: Prettier CLI is not used in this project, so you need to run the test file directly with Node.js.
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/devaloop/prettier-plugin-devalang/blob/main/LICENSE) file for details.
## Contributing
We welcome contributions to this project! If you find a bug or have a feature request, please open an issue on GitHub. You can also submit pull requests for any improvements or fixes.
## Acknowledgements
- [Prettier](https://prettier.io/) for its amazing code formatting capabilities.
- [Devalang](https://github.com/devaloop/devalang) for providing the foundation for this plugin.
## Contact
If you have any questions or need support, feel free to reach out to us: [contact@devaloop.com](mailto:contact@devaloop.com)