zed icon indicating copy to clipboard operation
zed copied to clipboard

Formatting with Ruff Doesnt Work

Open Notenlish opened this issue 7 months ago • 2 comments

Summary

Ruff formatter doesn't work. I've already installed the extension and configured it but it still doesn't work.

Description

Steps to reproduce:

  1. add settings.json
  2. Open a python file and tell zed to format it

Expected Behavior: Formatting works Actual Behavior: nothing happens

  1. Check your Zed.log for relevant errors? (please include!)
  2. Click Preview to ensure everything looks right?
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
  "icon_theme": "Catppuccin Mocha",
  "terminal": {
    "dock": "bottom"
  },
  "ui_font_size": 16,
  "buffer_font_size": 16,
  "theme": {
    "mode": "system",
    "light": "One Light",
    "dark": "One Dark Pro"
  },
  "buffer_font_features": {
    "calt": false,
    "liga": false,
    "diga": false
  },
  "autosave": { "after_delay": { "milliseconds": 400 } },
  "format_on_save": "on",
  "languages": {
    "Python": {
      "format_on_save": "on",
      "language_servers": ["ruff", "pyright"],
      "formatter": [
        {
          "code_actions": {
            "source.organizeImports.ruff": true,
            "source.fixAll.ruff": true
          }
        }
      ],
      "tab_size": 4
    }
  },
  "soft_wrap": "editor_width",
  "lsp": {
    "ruff": {
      "initialization_options": {
        "settings": {
          // Ruff server settings goes here
          "lineLength": 80,
          "lint": {
            "extendSelect": ["I"]
          }
        }
      }
    }
  }
}

Zed.log

Zed Version and System Specs

Zed: v0.185.14 (Zed) OS: Linux X11 linuxmint 22.1 Memory: 15.4 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 3050 Ti Laptop GPU || NVIDIA || 570.133.07

Notenlish avatar May 09 '25 18:05 Notenlish

Are you saying that to me? I don't think I can assign it to you, i dont have permissions for that

Notenlish avatar May 09 '25 21:05 Notenlish

You're missing the formatter declaration telling us to use ruff for LSP formatting, instead of just code action formatting. Please add the following above in the "formatter" array for Python and @-mention me if that doesn't fix the issue for you so we can figure out what else may be going wrong

        {
          "language_server": {
            "name": "ruff"
          }
        }

probably-neb avatar May 16 '25 09:05 probably-neb

It seems to be definitely working, thanks a lot!

Notenlish avatar May 16 '25 18:05 Notenlish