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 use as black formatter?

reagle opened this issue · comments

I currently use plugins LSP-ruff for linting and sublack for formatting. I've read ruff can now format using black conventions; can I use LSP-ruff to replace sublack? If so, how would I format that?

ruff advertises itself as formatter. That means you can just run the lsp_format_document command or add bind the command to a key:

{
        "keys": [
            "<your binding>"
        ],
        "command": "lsp_format_document"
    },

LSP does also have the lsp_format_on_save setting, which would run the command every time you save. You can also enable this behavior only for certain syntaxes by using the "Syntax Specific Settings" for that.

Thank you @LDAP.