From: PeterGrossmann Date: Thu, 1 Sep 2022 16:39:47 +0000 (+0200) Subject: Add preview flag to Vim plugin (#3246) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/92c93a278036870a76740d5b0b8f06504925e7dc?ds=sidebyside Add preview flag to Vim plugin (#3246) This allows the configuration of the --preview flag in the Vim plugin. --- diff --git a/CHANGES.md b/CHANGES.md index 7c7be98..25c3d48 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -101,6 +101,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 diff --git a/autoload/black.vim b/autoload/black.vim index ed657be..e87a1e4 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=configs["preview"], **black_kwargs, ) quiet = configs["quiet"] diff --git a/docs/integrations/editors.md b/docs/integrations/editors.md index 07bf672..318e0e2 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 3fc11fe..fb70424 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 [