psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
39.22k stars 2.48k forks source link

Guide for neovim? I Found one for vim but not sure how to apply it to neovim. #3960

Open leet0rz opened 1 year ago

leet0rz commented 1 year ago

https://black.readthedocs.io/en/stable/integrations/editors.html I found the following link to your docs that tells users how to set it up for vim but how exactly do you set it up for neovim? I am close I think but I am getting the following error even tho I am on the newest version of python and neovim: ejli3Vm 1

Simple, easy to follow documentation for neovim as many of the others have.

Probably none as Black is the best

Add good documentation on how to install Black for neovim.

LyndonArmitage commented 4 days ago

For Neovim and vim in general, you can forgo using a plugin altogether and call black on the current buffer from the environment using :!black %.

I added a custom command to do this with :Black using the following lua:

vim.api.nvim_create_user_command(
  'Black',
  function()
    vim.cmd('!black %')
  end,
  { nargs = 0 }
)