Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add preview flag in vim plugin #3246

Merged
merged 3 commits into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -61,6 +61,7 @@
- Vim plugin: prefix messages with `Black: ` so it's clear they come from Black (#3194)
- Docker: changed to a /opt/venv installation + added to PATH to be available to
non-root users (#3202)
- Vim plugin: add flag (`g:black_preview`) to enable/disable the preview style (#3246)

### Output

Expand Down
2 changes: 2 additions & 0 deletions autoload/black.vim
Expand Up @@ -30,6 +30,7 @@ FLAGS = [
Flag(name="skip_string_normalization", cast=strtobool),
Flag(name="quiet", cast=strtobool),
Flag(name="skip_magic_trailing_comma", cast=strtobool),
Flag(name="preview", cast=strtobool),
]


Expand Down Expand Up @@ -145,6 +146,7 @@ def Black(**kwargs):
string_normalization=not configs["skip_string_normalization"],
is_pyi=vim.current.buffer.name.endswith('.pyi'),
magic_trailing_comma=not configs["skip_magic_trailing_comma"],
preview=configs["preview"],
**black_kwargs,
)
quiet = configs["quiet"]
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/editors.md
Expand Up @@ -113,6 +113,7 @@ Configuration:
- `g:black_skip_string_normalization` (defaults to `0`)
- `g:black_virtualenv` (defaults to `~/.vim/black` or `~/.local/share/nvim/black`)
- `g:black_quiet` (defaults to `0`)
- `g:black_preview` (defaults to `0`)

To install with [vim-plug](https://github.com/junegunn/vim-plug):

Expand Down
3 changes: 3 additions & 0 deletions plugin/black.vim
Expand Up @@ -63,6 +63,9 @@ endif
if !exists("g:black_target_version")
let g:black_target_version = ""
endif
if !exists("g:black_preview")
let g:black_preview = 0
endif

function BlackComplete(ArgLead, CmdLine, CursorPos)
return [
Expand Down