How to setup formatter for Python ???

This page summarizes the projects mentioned and recommended in the original post on /r/neovim

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • null-ls.nvim

    Discontinued Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.

  • However you can see that it would be quite cool to allow simple binaries like black or eslint to hook into the lsp and allow us to run formatting as if they were an lsp server. This is precisely why null-ls exists. Null-ls allows your simple binaries to hook into lsp features allowing you to interact with the binaries as you would normally like vim.lsp.buf.format() for example.

  • formatter.nvim

  • I use null-ls (https://github.com/jose-elias-alvarez/null-ls.nvim), I haven't tried it for python, but haven't had trouble with lua, js, ts or rust. You can also look into formatter.nvim (https://github.com/mhartington/formatter.nvim).

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • lvim

    My Lunarvim config (by dapc11)

  • ruff

    An extremely fast Python linter and code formatter, written in Rust.

  • Do yourself a favor, forget everything else and just use black+ruff https://github.com/charliermarsh/ruff

  • lsp-zero.nvim

    A starting point to setup some lsp related features in neovim.

  • There is a fundamental difference between formatters and lsp. Lsp-zero just set's up lsp. Lsp is the language server protocol, so lsp-zero only setus up things you get from your lsp server, in python's case perhaps pyright. So formatting will only work if your language server supports it, hence why it's working for you in c and c++ files. In c and c++, clangd supports formatting, however in python's case and pyright it doesn't.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts