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

Closed reagle closed 11 months ago

reagle commented 11 months ago

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?

LDAP commented 11 months ago

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.

reagle commented 11 months ago

Thank you @LDAP.