Skip to content

LSP: Format File -- ruff.toml settings ignored #92

@AndydeCleyre

Description

@AndydeCleyre

Hello!

I have the following ~/.config/ruff/ruff.toml, and I'd like this plugin to use that configuration, at least in the absence of a more local configuration file.

ruff.toml
line-length = 99

[format]
quote-style = "preserve"
skip-magic-trailing-comma = true

[lint]
select = ["ALL"]
ignore = ["BLE", "COM812", "EM", "FIX", "ISC001", "PERF203", "PGH003", "Q000", "T20", "TD002", "TD003", "TRY003", "TRY203"]

[lint.flake8-annotations]
suppress-none-returning = true

[lint.isort]
combine-as-imports = true
split-on-trailing-comma = false

[lint.pydocstyle]
convention = "pep257"

[lint.pylint]
max-args = 6

To that end, I've configured this plugin as:

{
  "initializationOptions": {
    "settings": {
      "configuration": "~/.config/ruff/ruff.toml",
      "configurationPreference": "filesystemFirst"
    }
  }
}

I test with the following main.py:

X_PATTERN = r'https://x\.com/[^/]+/status/\d+'
single = 'single'
double = "double"
(single,double,)

On the command line, I can see what ruff format will do, following my configuration:

$ ruff format --diff main.py
--- main.py
+++ main.py
@@ -1,4 +1,4 @@
 X_PATTERN = r'https://x\.com/[^/]+/status/\d+'
 single = 'single'
 double = "double"
-(single,double,)
+(single, double)

But when I choose LSP: Format File from the command palette, the following changes are made:

--- main.py
+++ main.py
@@ -1,4 +1,7 @@
-X_PATTERN = r'https://x\.com/[^/]+/status/\d+'
-single = 'single'
+X_PATTERN = r"https://x\.com/[^/]+/status/\d+"
+single = "single"
 double = "double"
-(single,double,)
+(
+    single,
+    double,
+)

Here is my troubleshooting output:

LSP: Troubleshoot Server

Troubleshooting: LSP-ruff

Version

  • LSP: 2.3.0
  • Sublime Text: 4180

Server Test Run

  • exit code: 0
  • output

Server Configuration

  • command
[
  "$server_path",
  "server"
]
  • shell command
"/home/andy/.cache/sublime-text/Package Storage/LSP-ruff/bin/ruff" server
  • selector
source.python
  • priority_selector
source.python
  • init_options
{
  "settings": {
    "codeAction": {
      "disableRuleComment": {
        "enable": true
      },
      "fixViolation": {
        "enable": true
      }
    },
    "configuration": "~/.config/ruff/ruff.toml",
    "configurationPreference": "filesystemFirst",
    "exclude": null,
    "fixAll": true,
    "format": {
      "preview": null
    },
    "lineLength": null,
    "lint": {
      "enable": true,
      "extendSelect": null,
      "ignore": null,
      "preview": null,
      "select": null
    },
    "logLevel": "error",
    "organizeImports": true
  }
}
  • settings
{}
  • env
{
  "PATH": "/home/andy/.cache/sublime-text/Package Storage/LSP-ruff/bin:"
}

Active view

  • File name
/home/andy/Code/rufflsptest/main.py
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
  "lsp_active": true,
  "syntax": "Packages/Python/Python.sublime-syntax"
}
  • base scope
source.python

Project / Workspace

  • folders
[
  "/home/andy/Code/rufflsptest"
]
  • is project: False

LSP configuration

{
  "clients": {
    "nimlsp": {
      "command": [
        "nimlsp"
      ],
      "enabled": true,
      "selector": "source.nim"
    }
  }
}

System PATH

  • /home/andy/.local/share/venvs/b85b12618c824167e5af3f14cdf57a1b/venv/bin
  • /home/andy/.local/share/mise/installs/cargo-broot/1.44.2/bin
  • /home/andy/.local/share/mise/installs/cargo-ncspot/1.2.1/bin
  • /home/andy/.local/share/mise/installs/cargo-prqlc/0.13.2/bin
  • /home/andy/.local/share/mise/installs/cargo-skim/0.15.5/bin
  • /home/andy/.local/share/mise/installs/ubi-asciinema-agg/1.5.0/bin
  • /home/andy/.local/share/mise/installs/ubi-bensadeh-tailspin/4.0.0/bin
  • /home/andy/.local/share/mise/installs/ubi-containers-podlet/0.3.0/bin
  • /home/andy/.local/share/mise/installs/ubi-eza-community-eza/0.20.11/bin
  • /home/andy/.local/share/mise/installs/ubi-input-username-rescrobbled/0.7.1/bin
  • /home/andy/.local/share/mise/installs/ubi-jhbabon-scout/2.8.0/bin
  • /home/andy/.local/share/mise/installs/ubi-koki-develop-gat/0.19.1/bin
  • /home/andy/.local/share/mise/installs/ubi-libxmq-xmq/2.18.0/bin
  • /home/andy/.local/share/mise/installs/ubi-rami3l-pacaptr/0.22.0/bin
  • /home/andy/.local/share/mise/installs/ubi-shshemi-tabiew/0.7.1/bin
  • /home/andy/.local/share/mise/installs/ubi-walles-moar/1.30.0/bin
  • /home/andy/.local/share/mise/installs/ubi-walles-riff/3.3.7/bin
  • /home/andy/.local/share/mise/installs/dasel/2.8.1/bin
  • /home/andy/.local/share/mise/installs/difftastic/0.61.0/bin
  • /home/andy/.local/share/mise/installs/fzf/0.56.3/bin
  • /home/andy/.local/share/mise/installs/gh/2.63.2/bin
  • /home/andy/.local/share/mise/installs/hyperfine/1.19.0/bin
  • /home/andy/.local/share/mise/installs/just/1.37.0/bin
  • /home/andy/.local/share/mise/installs/lua/5.4.7/bin
  • /home/andy/.local/share/mise/installs/lua/5.4.7/luarocks/bin
  • /home/andy/.local/share/mise/installs/python/3.13.0/bin
  • /home/andy/.local/share/mise/installs/shellcheck/0.10.0/bin
  • /home/andy/.local/share/mise/installs/usage/1.3.4/bin
  • /home/andy/.local/share/mise/installs/cargo-pacdef/1.6.0/bin
  • /home/andy/.local/share/mise/installs/ubi-glehmann-yage/0.5.0/bin
  • /home/andy/.local/share/mise/installs/ubi-schollz-croc/10.1.1/bin
  • /home/andy/.local/share/mise/installs/ubi-yaml-yamlscript/0.1.86/bin
  • /home/andy/.local/bin
  • /home/andy/.cargo/bin
  • /usr/local/sbin
  • /usr/local/bin
  • /usr/sbin
  • /usr/bin
  • /sbin
  • /bin
  • /usr/games
  • /usr/local/games
  • /snap/bin
  • /usr/lib/execline/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions