-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[ENHANCE]: Error message for plugin. #4441
base: main
Are you sure you want to change the base?
Changes from 1 commit
94f6334
ac2c9c8
9b41eff
1a777ca
9d48c4d
97c7f23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,16 +19,28 @@ if exists("g:load_black") | |
finish | ||
endif | ||
|
||
if v:version < 700 || !has('python3') | ||
func! __BLACK_MISSING() | ||
echo "The black.vim plugin requires vim7.0+ with Python 3.6 support." | ||
endfunc | ||
command! Black :call __BLACK_MISSING() | ||
command! BlackUpgrade :call __BLACK_MISSING() | ||
command! BlackVersion :call __BLACK_MISSING() | ||
" check if vim version is too old | ||
if v:version < 700 | ||
echo "The black.vim plugin requires Vim 7.0+." | ||
finish | ||
endif | ||
|
||
" check if Vim has Python 3 support | ||
if !has('python3') | ||
echo "The black.vim plugin requires Vim compiled with Python 3.8+ support." | ||
finish | ||
endif | ||
|
||
" define commands inly if all checks are passed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inly -> only? |
||
func! BlackNotSupported() | ||
echo "The black.vim plugin cannot be used with this Vim executable." | ||
endfunc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this function is defined when both check pass, but it should be define only if any of the checks did not pass. Also How about something like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for you suggestion. |
||
|
||
command! Black :call BlackNotSupported() | ||
command! BlackUpgrade :call BlackNotSupported() | ||
command! BlackVersion :call BlackNotSupported() | ||
|
||
|
||
let g:load_black = "py1.0" | ||
if !exists("g:black_virtualenv") | ||
if has("nvim") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will hide the version requirements if python3 support is not available. I think it will be more useful to use:
Of course with this if you had very old vim and you get vim 7+ without python3 support you will find about the python3 support on the second try. The current error message avoid this issue by displaying both requirements, but fail to explain what is the actual issue.
We can do something like this:
Vim is too old:
Python3 is missing: