sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.

Home Page:https://packagecontrol.io/packages/LSP-ruff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add "--ignore F401" to LSP-ruff?

vgoklani opened this issue · comments

Hey there,

Based on this post:

https://github.com/astral-sh/ruff/issues/8408#issuecomment-1789254340

and this in particular:

You should disable [F401](https://docs.astral.sh/ruff/rules/unused-import/) when using your IDE i.e. by adding --ignore F401 to the additional lint command arguments.

Where exactly should I put this statement in the sublime config file?

This is my current LSP-config:

{
  "log_debug": true,
  "lsp_format_on_save": true,
  "lsp_code_actions_on_save": {
    "lsp_format_on_save": true,
    "source.lsp_format_on_save": true,
    "source.fixAll": true,
    "source.organizeImports": true,
    "source.applyFormat": true
  },
  "clients": {
    "ruff-lsp": {
      "command": [
        "ruff-lsp"
      ],
      "enabled": false,
      "selector": "source.python",
      "initializationOptions": {
        "settings": {
          "args": [],
        },
      },
    },
  },
}

Apologies in advance if this is obvious (it most likely is...)

Start with reading the README in this project

(and don't add anything to clients since this package already creates proper configuration for it)

Ive also read the README but still don't get how to disable a rule globally.

Global configuration: Preferences > Package Settings > LSP > Servers > LSP-ruff

What should be added here to disable a list of rules Globally?

I think something like this should work.

{
    "initializationOptions": {
        "globalSettings": {
            "lint.args": [
                "--ignore", "F401",
            ],
        },
    }
}