diff --git a/after/plugin/ale.vim b/after/plugin/ale.vim new file mode 100644 index 00000000..463b65a5 --- /dev/null +++ b/after/plugin/ale.vim @@ -0,0 +1,28 @@ +if exists('g:loaded_ale_after') + finish +endif + +let g:loaded_ale_after = 1 + +if !g:ale_emit_conflict_warnings + finish +endif + +function! s:GetConflictingPluginWarning(plugin_name) abort + return 'ALE conflicts with ' . a:plugin_name + \ . '. Uninstall it, or disable this warning with ' + \ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, ' + \ . '*before* plugins are loaded.' +endfunction + +if exists('g:loaded_syntastic_plugin') + throw s:GetConflictingPluginWarning('Syntastic') +endif + +if exists('g:loaded_neomake') + throw s:GetConflictingPluginWarning('Neomake') +endif + +if exists('g:loaded_validator_plugin') + throw s:GetConflictingPluginWarning('Validator') +endif diff --git a/doc/ale.txt b/doc/ale.txt index 1660ecd5..2fe3ad8a 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -187,6 +187,15 @@ g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* Note |`g:ale_echo_msg_format`| should contain the `%severity%` handler +g:ale_emit_conflict_warnings *g:ale_emit_conflict_warnings* + + Type: |Number| + Default: `1` + + When set to `0`, ALE will not emit any warnings on startup about conflicting + plugins. ALE will probably not work if other linting plugins are installed. + + g:ale_enabled *g:ale_enabled* Type: |Number| diff --git a/plugin/ale.vim b/plugin/ale.vim index e69aba18..bdbf3ad1 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -32,6 +32,9 @@ if !s:has_features finish endif +" Add the after directory to the runtimepath +let &runtimepath .= ',' . expand(':p:h:h') . '/after' + " Set this flag so that other plugins can use it, like airline. let g:loaded_ale = 1 @@ -41,6 +44,9 @@ if has('unix') && empty($TMPDIR) let $TMPDIR = '/tmp' endif +" This flag can be set to 0 to disable emitting conflict warnings. +let g:ale_emit_conflict_warnings = get(g:, 'ale_emit_conflict_warnings', 1) + " This global variable is used internally by ALE for tracking information for " each buffer which linters are being run against. let g:ale_buffer_info = {} diff --git a/test/test_conflicting_plugin_warnings.vader b/test/test_conflicting_plugin_warnings.vader new file mode 100644 index 00000000..ebf53c8a --- /dev/null +++ b/test/test_conflicting_plugin_warnings.vader @@ -0,0 +1,70 @@ +Execute(The after file should have been loaded for real): + Assert g:loaded_ale_after + +Before: + silent! cd /testplugin/test + cd .. + unlet! g:loaded_ale_after + +After: + cd test + let g:loaded_ale_after = 1 + let g:ale_emit_conflict_warnings = 1 + unlet! g:loaded_syntastic_plugin + unlet! g:loaded_neomake + unlet! g:loaded_validator_plugin + +Execute(ALE should not warn when nothing extra is installed): + " Nothing should be thrown when loading the after file. + source after/plugin/ale.vim + +Execute(ALE should warn users when Syntastic is installed): + let g:loaded_syntastic_plugin = 1 + + AssertThrows source after/plugin/ale.vim + AssertEqual + \ 'ALE conflicts with Syntastic' + \ . '. Uninstall it, or disable this warning with ' + \ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, ' + \ . '*before* plugins are loaded.', + \ g:vader_exception + +Execute(ALE should not warn about Syntastic when the flag is set): + let g:loaded_syntastic_plugin = 1 + let g:ale_emit_conflict_warnings = 0 + + source after/plugin/ale.vim + +Execute(ALE should warn users when Neomake is installed): + let g:loaded_neomake = 1 + + AssertThrows source after/plugin/ale.vim + AssertEqual + \ 'ALE conflicts with Neomake' + \ . '. Uninstall it, or disable this warning with ' + \ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, ' + \ . '*before* plugins are loaded.', + \ g:vader_exception + +Execute(ALE should not warn about Neomake when the flag is set): + let g:loaded_neomake = 1 + let g:ale_emit_conflict_warnings = 0 + + source after/plugin/ale.vim + +Execute(ALE should warn users when Validator is installed): + let g:loaded_validator_plugin = 1 + + AssertThrows source after/plugin/ale.vim + AssertEqual + \ 'ALE conflicts with Validator' + \ . '. Uninstall it, or disable this warning with ' + \ . '`let g:ale_emit_conflict_warnings = 0` in your vimrc file, ' + \ . '*before* plugins are loaded.', + \ g:vader_exception + +Execute(ALE should not warn about Validator when the flag is set): + let g:loaded_validator_plugin = 1 + let g:ale_emit_conflict_warnings = 0 + + source after/plugin/ale.vim