From 107de76cfeb25074697d33b262a81ec28b34143b Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 31 Aug 2022 09:34:35 +0200 Subject: [PATCH 1/3] add preview flag in vim plugin --- autoload/black.vim | 2 ++ docs/integrations/editors.md | 1 + plugin/black.vim | 3 +++ 3 files changed, 6 insertions(+) diff --git a/autoload/black.vim b/autoload/black.vim index ed657be7bd3..2edd27edc21 100644 --- a/autoload/black.vim +++ b/autoload/black.vim @@ -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), ] @@ -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=not configs["preview"], **black_kwargs, ) quiet = configs["quiet"] diff --git a/docs/integrations/editors.md b/docs/integrations/editors.md index 07bf672f4fd..318e0e295d0 100644 --- a/docs/integrations/editors.md +++ b/docs/integrations/editors.md @@ -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): diff --git a/plugin/black.vim b/plugin/black.vim index 3fc11fe9e8d..fb70424b0ef 100644 --- a/plugin/black.vim +++ b/plugin/black.vim @@ -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 [ From a4d542484c9552e751f4c0cbb0bd0dd398b539d2 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 1 Sep 2022 10:17:06 +0200 Subject: [PATCH 2/3] add to CHANGES.md and remove _not_ in configs mode --- CHANGES.md | 1 + autoload/black.vim | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a5ce3b1fbe2..f183dc31e0c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 preview flag (`g:black_preview`) to use the corresponding mode (#3246) ### Output diff --git a/autoload/black.vim b/autoload/black.vim index 2edd27edc21..e87a1e4edfa 100644 --- a/autoload/black.vim +++ b/autoload/black.vim @@ -146,7 +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=not configs["preview"], + preview=configs["preview"], **black_kwargs, ) quiet = configs["quiet"] From 0a3e9e4919750fd25134c73404003aabe7ae7008 Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Thu, 1 Sep 2022 12:34:18 -0400 Subject: [PATCH 3/3] Reword changelog entry --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f183dc31e0c..949d2377a0d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -61,7 +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 preview flag (`g:black_preview`) to use the corresponding mode (#3246) +- Vim plugin: add flag (`g:black_preview`) to enable/disable the preview style (#3246) ### Output