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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
<!-- Major changes to documentation and policies. Small docs changes
don't need a changelog entry. -->

- Add Neovim integration guide covering conform.nvim, ALE, and simple command approaches
(#5061)
- Use "Version X.Y.Z" headings in changelog for stable permalink anchors on ReadTheDocs
(#5063)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that. Thank you for your caution.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Twisted and CPython:

> _At least the name is good._

**Kenneth Reitz**, creator of [requests](http://python-requests.org/) and
**Kenneth Reitz**, creator of [requests](https://python-requests.org/) and
[pipenv](https://docs.pipenv.org/):

> _This vastly improves the formatting of our code. Thanks a ton!_
Expand Down
61 changes: 61 additions & 0 deletions docs/integrations/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,67 @@ nnoremap <F9> :Black<CR>
let g:ale_fixers.python = ['black']
```

## Neovim

### Via conform.nvim

[conform.nvim](https://github.com/stevearc/conform.nvim) is a lightweight formatter
plugin for Neovim. It supports _Black_ out of the box as long as `black` is available in
your `PATH`.

1. Install `black` (e.g. `pip install black` or `pipx install black`)

1. Install `conform.nvim` using your plugin manager and add the following to your Neovim
configuration:

```lua
require("conform").setup({
formatters_by_ft = {
python = { "black" },
},
})
```

1. To format on save, add:

```lua
require("conform").setup({
formatters_by_ft = {
python = { "black" },
},
format_on_save = {
timeout_ms = 500,
lsp_format = "fallback",
},
})
```

### With ALE

[ALE](https://github.com/dense-analysis/ale) supports both Vim and Neovim. See the
[Vim section](#with-ale) above for setup instructions — the same configuration works for
Neovim.

### Simple command

You can invoke _Black_ on the current file directly from Neovim without any plugins:

```vim
:!black %
```

To create a convenient `:Black` command, add this to your `init.lua`:

```lua
vim.api.nvim_create_user_command(
"Black",
function()
vim.cmd("!black " .. vim.fn.expand("%"))
end,
{ nargs = 0 }
)
```

## Gedit

gedit is the default text editor of the GNOME, Unix like Operating Systems. Open gedit
Expand Down
Loading