diff --git a/CHANGES.md b/CHANGES.md index 98e4f6506ad..05a914c26f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -47,6 +47,8 @@ - Enhance GitHub Action `psf/black` to support the `required-version` major-version-only "stability" format when using pyproject.toml (#4770) +- Improve error message for vim plugin users. It now handles independently vim version +- Vim: Warn on unsupported Vim and Python versions independently (#4772) - Vim: Print the import paths when importing black fails (#4675) - Vim: Fix handling of virtualenvs that have a different Python version (#4675) diff --git a/plugin/black.vim b/plugin/black.vim index 84dfc256f8e..0ecbef4c5ab 100644 --- a/plugin/black.vim +++ b/plugin/black.vim @@ -20,12 +20,21 @@ if exists("g:load_black") endif if v:version < 700 || !has('python3') - func! __BLACK_MISSING() - echo "The black.vim plugin requires vim7.0+ with Python 3.9 support." + func! __ERROR() + let messages = [] + + if v:version < 700 + call add(messages, "vim7.0+") + endif + if !has('python3') + call add(messages, "Python 3.9 support") + endif + + echo "The black.vim plugin requires" join(messages, " and ") endfunc - command! Black :call __BLACK_MISSING() - command! BlackUpgrade :call __BLACK_MISSING() - command! BlackVersion :call __BLACK_MISSING() + command! Black :call __ERROR() + command! BlackUpgrade :call __ERROR() + command! BlackVersion :call __ERROR() finish endif