Skip to content

Commit 61361b7

Browse files
sedat4raspre-commit-ci[bot]claudecobaltt7
authored
docs: add Neovim integration guide and fix http link (#5124)
* docs: add Neovim integration guide and fix http link - Add a dedicated Neovim section to the editor integrations docs, covering three approaches: - conform.nvim (recommended, with format-on-save example) - ALE (cross-reference to existing Vim section) - Simple :!black % command with a Lua user command example - Fix http://python-requests.org/ link to use https:// Fixes #3960 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * docs: add changelog entry for Neovim integration guide Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: correct PR number in CHANGES.md (#5061#5124) * move changelog entry to the correct version --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
1 parent ebe6018 commit 61361b7

3 files changed

Lines changed: 65 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
<!-- Major changes to documentation and policies. Small docs changes
5151
don't need a changelog entry. -->
5252

53+
- Add Neovim integration guide covering conform.nvim, ALE, and simple command approaches
54+
(#5124)
55+
5356
## Version 26.5.0
5457

5558
### Highlights

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Twisted and CPython:
5656

5757
> _At least the name is good._
5858
59-
**Kenneth Reitz**, creator of [requests](http://python-requests.org/) and
59+
**Kenneth Reitz**, creator of [requests](https://python-requests.org/) and
6060
[pipenv](https://docs.pipenv.org/):
6161

6262
> _This vastly improves the formatting of our code. Thanks a ton!_

docs/integrations/editors.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,67 @@ nnoremap <F9> :Black<CR>
353353
let g:ale_fixers.python = ['black']
354354
```
355355

356+
## Neovim
357+
358+
### Via conform.nvim
359+
360+
[conform.nvim](https://github.com/stevearc/conform.nvim) is a lightweight formatter
361+
plugin for Neovim. It supports _Black_ out of the box as long as `black` is available in
362+
your `PATH`.
363+
364+
1. Install `black` (e.g. `pip install black` or `pipx install black`)
365+
366+
1. Install `conform.nvim` using your plugin manager and add the following to your Neovim
367+
configuration:
368+
369+
```lua
370+
require("conform").setup({
371+
formatters_by_ft = {
372+
python = { "black" },
373+
},
374+
})
375+
```
376+
377+
1. To format on save, add:
378+
379+
```lua
380+
require("conform").setup({
381+
formatters_by_ft = {
382+
python = { "black" },
383+
},
384+
format_on_save = {
385+
timeout_ms = 500,
386+
lsp_format = "fallback",
387+
},
388+
})
389+
```
390+
391+
### With ALE
392+
393+
[ALE](https://github.com/dense-analysis/ale) supports both Vim and Neovim. See the
394+
[Vim section](#with-ale) above for setup instructions — the same configuration works for
395+
Neovim.
396+
397+
### Simple command
398+
399+
You can invoke _Black_ on the current file directly from Neovim without any plugins:
400+
401+
```vim
402+
:!black %
403+
```
404+
405+
To create a convenient `:Black` command, add this to your `init.lua`:
406+
407+
```lua
408+
vim.api.nvim_create_user_command(
409+
"Black",
410+
function()
411+
vim.cmd("!black " .. vim.fn.expand("%"))
412+
end,
413+
{ nargs = 0 }
414+
)
415+
```
416+
356417
## Gedit
357418

358419
gedit is the default text editor of the GNOME, Unix like Operating Systems. Open gedit

0 commit comments

Comments
 (0)