Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<!-- Major changes to documentation and policies. Small docs changes
don't need a changelog entry. -->

- Add Neovim configuration guide to editor integration docs, covering lazy.nvim,
packer.nvim, Lua configuration, and troubleshooting (#5064)

## 26.3.1

### Stable style
Expand Down
83 changes: 83 additions & 0 deletions docs/integrations/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,89 @@ Sublime Text, Visual Studio Code and many more), you can use the

Use the [Spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle) plugin.

## Neovim

_Black_ works with Neovim using the same official plugin as Vim. The plugin
automatically detects Neovim and uses `~/.local/share/nvim/black` as the default
virtualenv location.

### Using lazy.nvim

For Neovim 0.8+ with [lazy.nvim](https://github.com/folke/lazy.nvim):

```lua
{
'psf/black',
branch = 'stable',
ft = 'python',
config = function()
-- Configure Black settings
vim.g.black_fast = 0
vim.g.black_linelength = 88

-- Format on save
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.py',
callback = function()
vim.cmd('Black')
end,
})
end,
}
```

### Using packer.nvim

```lua
use {
'psf/black',
branch = 'stable',
ft = 'python',
config = function()
-- Format on save
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.py',
callback = function()
vim.cmd('Black')
end,
})
end,
}
```

### Lua Configuration

For `init.lua` users:

```lua
-- All g:black_* settings
vim.g.black_fast = 0
vim.g.black_linelength = 88
vim.g.black_use_virtualenv = 1
vim.g.black_virtualenv = '~/.local/share/nvim/black'

-- Commands
vim.keymap.set('n', '<F9>', ':Black<CR>', { silent = true })
```

### Troubleshooting

**Error: Python provider not found**

Ensure Neovim has Python 3 support:

```vim
:checkhealth provider
```

Install if missing:

```console
$ pip install pynvim
```

_See [Vim section](#vim) for more configuration options._

## Kakoune

Add the following hook to your kakrc, then run _Black_ with `:format`.
Expand Down
Loading