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

Vim plugin fix string normalization option #1869

Merged
merged 5 commits into from Jun 12, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions CHANGES.md
Expand Up @@ -12,6 +12,13 @@
- Fix incorrect custom breakpoint indices when string group contains fake f-strings
(#2311)

### Integrations

- The vim plugin now reads the correct string normalization option in pyproject.toml
(#1869)
- The vim plugin no longer crashes Black when there's boolean values in pyproject.toml
(#1869)

## 21.5b2

### _Black_
Expand Down
6 changes: 3 additions & 3 deletions autoload/black.vim
Expand Up @@ -22,7 +22,7 @@ class Flag(collections.namedtuple("FlagBase", "name, cast")):
FLAGS = [
Flag(name="line_length", cast=int),
Flag(name="fast", cast=strtobool),
Flag(name="string_normalization", cast=strtobool),
Flag(name="skip_string_normalization", cast=strtobool),
Flag(name="quiet", cast=strtobool),
]

Expand Down Expand Up @@ -103,7 +103,7 @@ def Black():
configs = get_configs()
mode = black.FileMode(
line_length=configs["line_length"],
string_normalization=configs["string_normalization"],
string_normalization=not configs["skip_string_normalization"],
is_pyi=vim.current.buffer.name.endswith('.pyi'),
)
quiet = configs["quiet"]
Expand Down Expand Up @@ -146,7 +146,7 @@ def get_configs():
toml_config = {}

return {
flag.var_name: flag.cast(toml_config.get(flag.name, vim.eval(flag.vim_rc_name)))
flag.var_name: toml_config.get(flag.name, flag.cast(vim.eval(flag.vim_rc_name)))
for flag in FLAGS
}

Expand Down
8 changes: 4 additions & 4 deletions plugin/black.vim
Expand Up @@ -43,11 +43,11 @@ endif
if !exists("g:black_linelength")
let g:black_linelength = 88
endif
if !exists("g:black_string_normalization")
if exists("g:black_skip_string_normalization")
let g:black_string_normalization = !g:black_skip_string_normalization
if !exists("g:black_skip_string_normalization")
if exists("g:black_string_normalization")
let g:black_skip_string_normalization = !g:black_string_normalizationlse
ichard26 marked this conversation as resolved.
Show resolved Hide resolved
else
let g:black_string_normalization = 1
let g:black_skip_string_normalization = 0
endif
endif
if !exists("g:black_quiet")
Expand Down