black
black copied to clipboard
Improve vim plugin error message if vim is too old or python support is missing
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 I will highly appreciate your suggestion. https://github.com/psf/black/pull/4441