ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Support and Integration for VSCode

Open harshalchaudhari35 opened this issue 3 years ago • 4 comments

Is there a way to add ruff as a python linter in VScode?

harshalchaudhari35 avatar Sep 07 '22 09:09 harshalchaudhari35

If the maintainers decide that editor integration is in scope for this project rather than separate dedicated projects, I would like to suggest using Language Server Protocol for this to allow usage with many editors at once (editors that support it include: Visual Studio, Visual Studio Code, Neovim, Sublime Text, JetBrains Fleet, and more): https://microsoft.github.io/language-server-protocol/

Jackenmen avatar Sep 13 '22 23:09 Jackenmen

I think @jack1142 made a good suggestion here. I just researched a little, and integrating ruff as a linter in VSCode is not trivial. The best way is to create a PR for the official Python extension. It doesn't look too complicated, but I am also not sure if they are willing to support a new, not fully stable linter.

As a Neovim user, I am happier with a LSP, which is easily integrable. I might take a look at it.

HallerPatrick avatar Sep 15 '22 18:09 HallerPatrick

VS Code Python team is actually pushing for this as well (LSP-based integrations, not necessarily the linter themselves implementing language server protocol themselves), they're working on extension templates and stuff like that to make it easy to create new integrations for linters with hopefully no TypeScript knowledge required (unlike the current solution which does require that). Considering that a lot of this is still being worked on, it might not make sense to work on VS Code specific extension just yet. LSP is generic enough that it's likely that not much will be needed to make a VS Code specific extension for it in the future.

Here are a bunch of related issues:

  • https://github.com/psf/black/issues/2883
  • https://github.com/PyCQA/isort/issues/1904
  • https://github.com/PyCQA/pylint/issues/5796
  • https://github.com/PyCQA/flake8/issues/1467

Jackenmen avatar Sep 15 '22 19:09 Jackenmen

Worth mentioning, for anyone that comes across this issue in the future, that we now have a dedicated Ruff VS Code Extension.

charliermarsh avatar Dec 18 '22 22:12 charliermarsh

Worth mentioning, for anyone that comes across this issue in the future, that we now have a dedicated Ruff VS Code Extension.

Hello. The vscode extension is not yet updated. I really want the fix for "f-string without any placeholders"

CodeFanaticX avatar Jan 01 '23 17:01 CodeFanaticX

I cut a new pre-release extension with the latest Ruff version.

charliermarsh avatar Jan 02 '23 00:01 charliermarsh

Is there a way to specify the version of ruff that is run in the vscode extension? specifically, it would be super helpful to be able to run version 0.1.6 or 0.1.7. Is this the only way to run one of these later versions https://github.com/astral-sh/ruff-vscode#using-a-custom-version-of-ruff ? thanks so much! :pray:

jaxwagner avatar Dec 12 '23 01:12 jaxwagner

@jaxwagner The extension will use your Python project's Ruff version if available. It will only fall back to the bundled version if it cannot find a compatible one in your environment.

zanieb avatar Dec 12 '23 04:12 zanieb

thanks so much @zanieb ! super helpful really appreciate it :pray:

jaxwagner avatar Dec 12 '23 05:12 jaxwagner