Complain loudly when other conflicting plugins are installed

This commit is contained in:
w0rp 2017-03-06 23:15:28 +00:00
parent 70fb1606ad
commit 75a2dc5ff5
4 changed files with 113 additions and 0 deletions

28
after/plugin/ale.vim Normal file
View File

@ -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

View File

@ -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|

View File

@ -32,6 +32,9 @@ if !s:has_features
finish
endif
" Add the after directory to the runtimepath
let &runtimepath .= ',' . expand('<sfile>: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 = {}

View File

@ -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