sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.
https://packagecontrol.io/packages/LSP-ruff
MIT License
38 stars 4 forks source link

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

Closed vgoklani closed 1 year ago

vgoklani commented 1 year ago

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...)

rchl commented 1 year ago

Start with reading the README in this project

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

hulleyrob commented 1 year ago

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?

rchl commented 1 year ago

I think something like this should work.

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