black icon indicating copy to clipboard operation
black copied to clipboard

Improve vim plugin error message if vim is too old or python support is missing

Open nirs opened this issue 1 year ago • 1 comments

When trying the black vim plugin in builtin vim in macOS 14, we get this unclear error message:

The black.vim plugin requires vim7.0+ with Python 3.6 support.

The issues is that the builtin vim is not compiled with python3:

% /usr/bin/vim --version | grep python3
+cmdline_info      +libcall           -python3           +virtualedit

No issue with vim from homebrew:

% /opt/homebrew/bin/vim --version | grep python3
+cmdline_info      +libcall           +python3           +virtualedit

The error message is correct about the requirement, but not helpful to users.

This will be a more useful behavior:

  • If vim version is too old, fail with a message about vim version
  • If python3 support is missing, fail with a message about missing python support

Also the name of the helper function __BLACK_MISSING is confusing since black is not missing but cannot be used with this vim executable.

Finally based on README.md, python3.8+ is required not, but the message is about python 3.6.

nirs avatar Aug 15 '24 17:08 nirs

@nirs I will highly appreciate your suggestion. https://github.com/psf/black/pull/4441

Typocalypse avatar Aug 22 '24 17:08 Typocalypse