How to setup formatter for Python ???

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

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. 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.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. 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).

  4. lvim

    My Lunarvim config (by dapc11)

  5. 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

  6. 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.

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