Something that I really wanted when working with (Zed)[https://zed.dev] and Ruby on Rails was format on save ability for my .rb and .erb files. The setup is simple so I thought I'd give it a share:
First open your settings.json
file with cmnd + ,
or going to Zed -> Settings -> Open Settings.
Then add a key for languages with the following:
{
...other_settings_here,
"languages": {
"Ruby": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "./bin/bundle",
"arguments": [
"exec",
"rubocop",
"--auto-correct",
"--stdin",
"corrected.rb",
"--stderr"
]
}
}
},
"ERB": {
"formatter": [
{
"external": {
"command": "sh",
"arguments": [
"-c",
"f=erblinttemp_$RANDOM$RANDOM.html.erb; cat > $f; erblint -a $f &>/dev/null; cat $f; rm $f;"
]
}
},
{
"external": {
"command": "htmlbeautifier",
"arguments": []
}
}
],
"format_on_save": "on"
}
}
}
There you have it format on save for your template files and ruby files ready to go.
Top comments (0)