From: Thom Lu Date: Sun, 17 Mar 2019 16:27:50 +0000 (-0500) Subject: fix vim plugin for 19.3b0 (#755) (#766) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/a2f6706a1ea026cbe0e7d83caffa6c13c463bfe1?hp=ba64fc757c12e59fb35f2306eb4fa75fdc566647 fix vim plugin for 19.3b0 (#755) (#766) --- diff --git a/plugin/black.vim b/plugin/black.vim index f0b55b2..36825cf 100644 --- a/plugin/black.vim +++ b/plugin/black.vim @@ -98,15 +98,14 @@ if _initialize_black_env(): def Black(): start = time.time() fast = bool(int(vim.eval("g:black_fast"))) - line_length = int(vim.eval("g:black_linelength")) - mode = black.FileMode.AUTO_DETECT - if bool(int(vim.eval("g:black_skip_string_normalization"))): - mode |= black.FileMode.NO_STRING_NORMALIZATION - if vim.current.buffer.name.endswith('.pyi'): - mode |= black.FileMode.PYI + mode = black.FileMode( + line_length=int(vim.eval("g:black_linelength")), + string_normalization=not bool(int(vim.eval("g:black_skip_string_normalization"))), + is_pyi=vim.current.buffer.name.endswith('.pyi'), + ) buffer_str = '\n'.join(vim.current.buffer) + '\n' try: - new_buffer_str = black.format_file_contents(buffer_str, line_length=line_length, fast=fast, mode=mode) + new_buffer_str = black.format_file_contents(buffer_str, fast=fast, mode=mode) except black.NothingChanged: print(f'Already well formatted, good job. (took {time.time() - start:.4f}s)') except Exception as exc: