Prettier plugin for Devalang formatting
npm install @devaloop/prettier-plugin-devalang
pattern, for, automate, param, and keyframes
->) with intelligent line breaking for long chains
.deva files
# like this) and intentional spacing are respected β because context matters π¬
loop, group, and conditional if / else if / else blocks with proper indentation, just like you'd expect π§
->) for better readability and consistency.
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
This is a comment
bank devaloop.808 as myBank
let mySynth = synth saw { attack: 0.01, release: 0.1, decay: 0.2, sustain: 0.8 }
mySynth -> note(C4) -> duration(1/4) -> drive({ amp: 0.5, color: 0.7 }) -> reverb({ mix: 0.3 })
loop 10:
.myBank.kick 1/8
.myBank.snare 1500
.myBank.clap auto
`
After formatting with Prettier, it will look like this:
`deva
This is a comment
bank devaloop.808 as myBank
let mySynth = synth saw {
attack: 0.01,
release: 0.1,
decay: 0.2,
sustain: 0.8,
}
mySynth -> note(C4)
-> duration(1/4)
-> drive({ amp: 0.5, color: 0.7 })
-> reverb({ room_size: 0.3 })
loop 10:
.myBank.kick 1/8
.myBank.snare 1500
.myBank.clap auto
`
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`.