format_on_save is ignored when saving a remote YAML file
Check for existing issues
- [x] Completed
Describe the bug / provide steps to reproduce it
When saving a YAML file on a remote server after making edits, Zed will auto indent the file. I've set:
"format_on_save": "off",
but it still indents the file.
This doesn't appear to occur if I'm editing the same file locally.
Example YAML: https://raw.githubusercontent.com/rivosinc/JumpStart/refs/heads/main/src/public/jumpstart_public_source_attributes.yaml
Zed Version and System Specs
Zed: v0.169.3 (Zed) OS: macOS 15.1.1 Memory: 16 GiB Architecture: aarch64
If applicable, add screenshots or screencasts of the incorrect state / behavior
Before Saving:
After Saving:
If applicable, attach your Zed.log file to this issue.
Zed.log
I encountered the problem where it doesn't really respect the "tab_size" value for remote.
Exactly as shown in the screenshot, on remote it uses 4 spaces instead of 2 while locally it respect that.
is there any way to configure a custom command that is getting invoked for formatting? Then I could call dprint for yaml files.
Right now there seems no workaround. :(
I think this is a regression? I'm also experience it on 0.175.6 and I thought I had it properly disabled before. I also can't seem to disable format_on_save for toml files (i.e. Cargo.toml).
Related: I can't turn off the auto formatter for HTML. My indentation and certain line breaks are removed / reformatted. With this setting I exact the file to save exactly as it is without processing.
Zed 0.176.1: 121bd97cb189d272c746e04b8d15d188ffe346c5
Settings
{
"format_on_save": "off",
"languages": {
"HTML": {
"tab_size": 4,
"format_on_save": "off"
}
},
Here's a video of this in action:
https://github.com/user-attachments/assets/67e7b935-a289-4259-b2c7-5de8976275d0
I was experiencing the same problem with YAML files being auto formatted (even with format_on_save: false) with $4$ spaces, even with tab_size: 2 for YAML language specifically.
I've discovered that there is a server settings file, which can be seem bellow:
If I set the proper configs in this file, the formatter respects it. But seems like a bug indeed, if no values are set in this file, the user settings in the host should be used.
Specs: Zed: v0.176.3 (Zed) OS: macOS 14.7.3 Memory: 16 GiB Architecture: aarch64
Thanks @paulora2405 - Unfortunately for me that isn't resolving it.
BTW, this issue isn't present on every remote server I'm using Zed with.
My workaround currently is to use cmd+k s but it's really hard/annoying to break my cmd+s muscle memory. I tried to remap the key binding for cmd+s to be cmd+k s but that didn't work either.
Also altering the behavior of the formatting doesn't work as well.
e.g.
"languages": {
"YAML": {
"tab_size": 2,
}
}
has no effect. Nor does selecting an external formatter such as YQ.
One other data point:
I change the file type to "Plain Text" in the bottom right corner of the editing window, and it still formats the YAML to 4 spaces. This makes the IDE completely unusable for me for YAML files.
This is happening on JSON and YAML for me but only on a remote. As others have mentioned setting the tab_size for the languages doesn't work.
Having the same issue. However the workaround above from paulora2405 worked for me.
Took a while however to figure this out.
Anecdotal evidence but this seems to be a problem on remotes where the zed editor is installed too. If you remove the installed editor and just do remote it seems like the issue goes away.
Tested with Remote Ubuntu machine and MacOS client
- Was having problem when Ubuntu had the editor installed.
- Ran
zed --uninstallon remote - Tried remote again WITH the server settings setting the tab_size
- Seems fixed?
Managed to fix it for myself by creating ~/.config/zed/settings.json on remote, with tab_size: 2. Changing local settings.json file doesn't seem to have any effect.
I suppose this also fixes lots of other similar bugs, such as remote LSP configuration.
I'm getting a similar issue. I have a Mac client and a remote Fedora Linux server. When I save using the remote flow it indents files like .json, .toml, and others incorrectly. When I develop locally on the Mac or locally on the Linux server it indents correctly. It has something to do with the remote flow.
For additional context: I'm on Zed Preview 0.195.1. I deleted settings.json on both machines. Issue still persists.
I'm getting a similar issue. I have a Mac client and a remote Fedora Linux server. When I save using the remote flow it indents files like .json, .toml, and others incorrectly. When I develop locally on the Mac or locally on the Linux server it indents correctly. It has something to do with the remote flow.
For additional context: I'm on Zed Preview 0.195.1. I deleted settings.json on both machines. Issue still persists.
Have you tried making local and remote settings.json files identical?
Have you tried making local and remote settings.json files identical?
Yeah
I deleted settings.json on both machines.
They both bootstrapped to an empty settings.json.
The main thing that tells me this is a bug is that saving locally on my Mac formats correctly, saving locally on my Linux machine formats correctly, but saving while remoted in from the Mac to the Linux machine formats incorrectly.
Managed to fix it for myself by creating
~/.config/zed/settings.jsonon remote, withtab_size: 2. Changing localsettings.jsonfile doesn't seem to have any effect.I suppose this also fixes lots of other similar bugs, such as remote LSP configuration.
I experienced same issue while editing rust files on remote, local settings did not have any effect, drove me nuts for few hours. Finally managed to fix it by creating settings file on remote.
Interestingly format_on_save setting in the project setting file also did not have any effect, which means server settings override it?!
The real problem is that remote sessions have settings differing from the client.
Have you tried making local and remote settings.json files identical?
It's hard to see for me how that's a sensible default. Nobody expects or wants that?