zed-industries/zed

`remove_trailing_whitespace_on_save: false` still removes whitespace on save when not coding locally

Closed this issue · 1 comments

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

My settings.json looks like this:

{
  // ssh connections omitted
  "base_keymap": "VSCode",
  "theme": "Ayu Dark",
  "ui_font_size": 12,
  "buffer_font_size": 12,
  "languages": {
    "Python": {
      "remove_trailing_whitespace_on_save": false,
      "show_whitespaces": "all"
    }
  },
  "lsp": {
    "pyright": {
      "settings": {
        "python": {
          "pythonPath": ".venv/bin/python"
        }
      }
    },
    "tinymist": {
      "initialization_options": {
        "exportPdf": "onSave",
        "outputPath": "$root/$name",
        "typstExtraArgs": ["--", "main.typ"]
      }
    }
  }
}

When coding locally, saving a .py file does not remove whitespace with this setting off(functions as intended). However, when I ssh into my desktop, saving does remove whitespace even though I have "remove_trailing_whitespace_on_save": false.

Environment

My local device(laptop):

Software:

    System Software Overview:

      System Version: macOS 14.5 (23F79)
      Kernel Version: Darwin 23.5.0
      
Zed Version: Zed 0.163.3

Hardware:

    Hardware Overview:

      Model Name: MacBook Air
      Chip: Apple M1

My remote device(desktop):

Architecture: x86_64
OS: Ubuntu(Noble 24.04)

If applicable, add mockups / screenshots to help explain present your vision of the feature

remote.mov
local.mov

If applicable, attach your Zed.log file to this issue.

No response

Nevermind figured it out, read https://zed.dev/docs/remote-development once more and found:

When opening a remote project there are three relevant settings locations:

  • The local Zed settings (in ~/.zed/settings.json on macOS or ~/.config/zed/settings.json on Linux) on your local machine.
  • The server Zed settings (in the same place) on the remote server.
  • The project settings (in .zed/settings.json or .editorconfig of your project)

Depending on the kind of setting you want to make, which settings file you should use:

  • Project settings should be used for things that affect the project: indentation settings, which formatter / language server to use, etc.
  • Server settings should be used for things that affect the server: paths to language servers, etc.
  • Local settings should be used for things that affect the UI: font size, etc.

Then I assumed that despite the server Zed settings(~/.config/zed/settings.json) not existing on the server, it was resulting in the remote experience using the default settings for whatever relevant terms(which probably includes remove_trailing_whitespace_on_save in hindsight).

So I put this in ~/.config/zed/settings.json on the remote:

{
    "languages": {
        "Python": {
            "remove_trailing_whitespace_on_save": false,
            "show_whitespaces": "all"
        }
    }
}

and now everything is working as I expected.