0.6.3 • Published 2 months ago

@yaegassy/coc-ruff v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

coc-ruff

ruff-lsp extension for coc.nvim.

Install

CocInstall:

:CocInstall @yaegassy/coc-ruff

scoped packages

e.g. vim-plug:

Plug 'yaegassy/coc-ruff', {'do': 'yarn install --frozen-lockfile'}

Note

Detecting the "ruff" command from the execution environment

The ruff command used by ruff-lsp uses the ruff command installed with the ruff-lsp dependency.

To use the ruff command installed in the virtual environment of a project created by venv, poetry, etc., ruff.path must be set to an absolute path.

coc-ruff adds the feature to automatically detect ruff commands in the execution environment and use them in ruff-lsp.

If you do not need this feature, set ruff.useDetectRuffCommand to false.

coc-settings.json:

{
  "ruff.useDetectRuffCommand": false
}

Format (DocumentFormatting)

The black equivalent formatting feature has been added to ruff. This feature is enabled by default in ruff-lsp "v0.0.42" and later.

If you want to disable this feature, set the ruff.disableDocumentFormatting setting to true.

coc-settings.json:

{
  "ruff.disableDocumentFormatting": true
}

If you are using ruff-lsp "v0.4.1" or earlier and want to use this feature, please follow these steps.

  1. Please set ruff.enableExperimentalFormatter to true.
  2. If you are using other Python-related coc-extensions alongsidecoc-ruff, please disable the formatting feature of those coc-extensions.
    • e.g. coc-pyright:
      • Please set python.formatting.provider to none.

coc-settings.json:

{
  "ruff.enableExperimentalFormatter": true,
  "python.formatting.provider": "none"
}

Auto-fixing

Auto-fixing can be executed via the ruff.executeAutofix command or CodeAction.

Set ruff.autoFixOnSave setting to true if you also want auto-fixing to be performed when the file is saved.

coc-settings.json:

{
  "ruff.autoFixOnSave": true
}

Order of detection of ruff-lsp used by extensions

coc-ruff detects and starts ruff-lsp in the following priority order.

  1. ruff.serverPath (If there is a setting)
  2. current python3/python environment (e.g. ruff-lsp in global or virtual environment)
  3. built-in ruff-lsp (Installation commands are also provided)

Bult-in install

coc-ruff allows you to create an extension-only "venv" and install ruff-lsp.

When using coc-ruff for the first time, if ruff-lsp is not present in the runtime environment, you will be prompted to do a built-in install.

To use the built-in installation feature, execute the following command.

:CocCommand ruff.builtin.installServer

Configuration options

  • ruff.enable: Enable coc-ruff extension, default: true
  • ruff.disableDocumentFormatting: Disable document formatting only, default: false
  • ruff.disableHover: Disable hover only, default: false
  • ruff.useDetectRuffCommand: Automatically detects the ruff command in the execution environment and sets ruff.path, default: true
  • ruff.autoFixOnSave: Turns auto fix on save on or off, default: false
  • ruff.client.codeAction.showDocumantaion.enable: Whether to display the code action for open the Ruff rule documentation web page included in the diagnostic information, default: false
  • ruff.serverPath: Custom path to the ruff-lsp command. If not set, the ruff-lsp command found in the current Python environment or in the venv environment created for the extension will be used, default: ""
  • ruff.builtin.pythonPath: Python 3.x path (Absolute path) to be used for built-in install, default: ""
  • ruff.trace.server: Traces the communication between coc.nvim and the ruff-lsp, default: "off"

Other settings have the same configuration as ruff-vscode.

Commands

  • ruff.executeAutofix: Fix all auto-fixable problems
  • ruff.executeFormat: Format document
  • ruff.executeOrganizeImports: Format imports
  • ruff.showOutput: Show ruff output channel
  • ruff.restart: Restart Server
  • ruff.builtin.installServer: Install ruff-lsp
    • It will be installed in this path:
      • Mac/Linux:
        • ~/.config/coc/extensions/@yaegassy/coc-ruff-data/ruff-lsp/venv/bin/ruff-lsp
      • Windows:
        • ~\AppData\Local\coc\extensions\@yaegassy\coc-ruff-data\ruff-lsp\venv\Scripts\ruff-lsp.exe

Thanks

License

MIT


This extension is built with create-coc-extension

0.6.3

2 months ago

0.6.2

3 months ago

0.6.1

3 months ago

0.6.0

3 months ago

0.5.8

4 months ago

0.5.7

5 months ago

0.5.6

5 months ago

0.5.5

5 months ago

0.3.13

8 months ago

0.5.4

6 months ago

0.5.3

6 months ago

0.5.0

7 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.5.2

6 months ago

0.5.1

6 months ago

0.4.2

7 months ago

0.3.9

11 months ago

0.3.12

11 months ago

0.3.11

11 months ago

0.3.10

11 months ago

0.3.6

11 months ago

0.3.5

12 months ago

0.3.8

11 months ago

0.3.7

11 months ago

0.3.4

12 months ago

0.3.3

12 months ago

0.3.0

1 year ago

0.3.2

12 months ago

0.3.1

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.2

1 year ago