npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yaegassy/coc-ruff

v0.7.8

Published

ruff-lsp extension for coc.nvim

Downloads

1,063

Readme

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
}

[EXPERIMENTAL] Enabling the Rust-based language server

To use the new Rust-based language server (ruff server), you'll need to enable the ruff.nativeServer setting in the coc-settings.json:

{
  "ruff.nativeServer": true
}

In coc-ruff, the ruff binary is detected from the runtime environment (PATH) by default to start the native server. If you want to specify a custom ruff binary path, please set ruff.nativeBinaryPath.

{
  "ruff.nativeBinaryPath": "/path/to/ruff"
}

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 alongside coc-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.nativeServer: Use the integrated Rust-based language server, available now in Beta, default: false
  • ruff.nativeBinaryPath: Custom path for the ruff binary when using the native server. If no value is set, the ruff command will be detected from the runtime environment, default: ""
  • 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.debugInformation: Print debug information (native server only)
  • ruff.showLogs: Show logs
  • 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