Registry: cleaner handling of checker redirections.
Redirected checkers no longer need to add "syntax_checkers/<filetype>/*.vim" to &runtimepath. Parameters "exec" and "enable" to CreateAndRegisterChecker() are now inherited from the source checker, but can be overridden in the target if needed.
This commit is contained in:
parent
4725c8616c
commit
e60555de70
@ -19,7 +19,7 @@ if has('reltime')
|
||||
lockvar! g:_SYNTASTIC_START
|
||||
endif
|
||||
|
||||
let g:_SYNTASTIC_VERSION = '3.7.0-53'
|
||||
let g:_SYNTASTIC_VERSION = '3.7.0-54'
|
||||
lockvar g:_SYNTASTIC_VERSION
|
||||
|
||||
" Sanity checks {{{1
|
||||
|
@ -7,26 +7,36 @@ let g:SyntasticChecker = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticChecker.New(args) abort " {{{2
|
||||
function! g:SyntasticChecker.New(args, ...) abort " {{{2
|
||||
let newObj = copy(self)
|
||||
|
||||
let newObj._filetype = a:args['filetype']
|
||||
let newObj._name = a:args['name']
|
||||
let newObj._exec = get(a:args, 'exec', newObj._name)
|
||||
|
||||
if has_key(a:args, 'redirect')
|
||||
let [filetype, name] = split(a:args['redirect'], '/')
|
||||
if a:0
|
||||
" redirected checker
|
||||
let newObj._exec = get(a:args, 'exec', a:1['_exec'])
|
||||
|
||||
let filetype = a:1['_filetype']
|
||||
let name = a:1['_name']
|
||||
let prefix = 'SyntaxCheckers_' . filetype . '_' . name . '_'
|
||||
|
||||
if exists('g:syntastic_' . filetype . '_' . name . '_sort') && !exists('g:syntastic_' . newObj._filetype . '_' . newObj._name . '_sort')
|
||||
let g:syntastic_{newObj._filetype}_{newObj._name}_sort = g:syntastic_{filetype}_{name}_sort
|
||||
endif
|
||||
else
|
||||
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
||||
endif
|
||||
|
||||
if has_key(a:args, 'enable')
|
||||
let newObj._enable = a:args['enable']
|
||||
elseif has_key(a:1, '_enable')
|
||||
let newObj._enable = a:1['_enable']
|
||||
endif
|
||||
else
|
||||
let newObj._exec = get(a:args, 'exec', newObj._name)
|
||||
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
||||
|
||||
if has_key(a:args, 'enable')
|
||||
let newObj._enable = a:args['enable']
|
||||
endif
|
||||
endif
|
||||
|
||||
let newObj._locListFunc = function(prefix . 'GetLocList')
|
||||
|
@ -159,8 +159,21 @@ function! g:SyntasticRegistry.Instance() abort " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticRegistry.CreateAndRegisterChecker(args) abort " {{{2
|
||||
let checker = g:SyntasticChecker.New(a:args)
|
||||
let registry = g:SyntasticRegistry.Instance()
|
||||
|
||||
if has_key(a:args, 'redirect')
|
||||
let [ft, name] = split(a:args['redirect'], '/')
|
||||
call registry._loadCheckersFor(ft)
|
||||
|
||||
let clone = get(registry._checkerMap[ft], name, {})
|
||||
if empty(clone)
|
||||
throw 'Syntastic: Checker ' . a:args['redirect'] . ' redirects to unregistered checker ' . ft . '/' . name
|
||||
endif
|
||||
|
||||
let checker = g:SyntasticChecker.New(a:args, clone)
|
||||
else
|
||||
let checker = g:SyntasticChecker.New(a:args)
|
||||
endif
|
||||
call registry._registerChecker(checker)
|
||||
endfunction " }}}2
|
||||
|
||||
@ -195,7 +208,7 @@ function! g:SyntasticRegistry.getCheckersAvailable(ftalias, hints_list) abort "
|
||||
return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isAvailable()')
|
||||
endfunction " }}}2
|
||||
|
||||
" Same as getCheckers(), but keep only the checkers tyhat are available and
|
||||
" Same as getCheckers(), but keep only the checkers that are available and
|
||||
" disabled. This runs the corresponding IsAvailable() functions for all checkers.
|
||||
function! g:SyntasticRegistry.getCheckersDisabled(ftalias, hints_list) abort " {{{2
|
||||
return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isDisabled() && v:val.isAvailable()')
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_cpp_clang_check_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_clang_check_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'clang_check',
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_cpp_clang_tidy_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_clang_tidy_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'clang_tidy',
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_cpp_cppcheck_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_cppcheck_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'cppcheck',
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_cpp_oclint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_oclint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'oclint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_cpp_pc_lint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_pc_lint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'pc_lint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_css_phpcs_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_css_phpcs_checker = 1
|
||||
|
||||
runtime! syntax_checkers/php/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'css',
|
||||
\ 'name': 'phpcs',
|
||||
|
@ -16,8 +16,6 @@ if exists('g:loaded_syntastic_css_recess_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_css_recess_checker = 1
|
||||
|
||||
runtime! syntax_checkers/less/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'css',
|
||||
\ 'name': 'recess',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_docbk_xmllint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_docbk_xmllint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/xml/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'docbk',
|
||||
\ 'name': 'xmllint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_nroff_igor_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_nroff_igor_checker = 1
|
||||
|
||||
runtime! syntax_checkers/docbk/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'nroff',
|
||||
\ 'name': 'igor',
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_objc_oclint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_objc_oclint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'objc',
|
||||
\ 'name': 'oclint',
|
||||
|
@ -14,8 +14,6 @@ if exists('g:loaded_syntastic_objcpp_oclint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_objcpp_oclint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'objcpp',
|
||||
\ 'name': 'oclint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_perl_podchecker_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_perl_podchecker_checker = 1
|
||||
|
||||
runtime! syntax_checkers/pod/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'perl',
|
||||
\ 'name': 'podchecker',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_rmd_lintr_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_rmd_lintr_checker = 1
|
||||
|
||||
runtime! syntax_checkers/r/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'rmd',
|
||||
\ 'name': 'lintr',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_scss_sass_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_scss_sass_checker = 1
|
||||
|
||||
runtime! syntax_checkers/sass/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'scss',
|
||||
\ 'name': 'sass',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_scss_sassc_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_scss_sassc_checker = 1
|
||||
|
||||
runtime! syntax_checkers/sass/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'scss',
|
||||
\ 'name': 'sassc',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_text_igor_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_text_igor_checker = 1
|
||||
|
||||
runtime! syntax_checkers/docbk/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'text',
|
||||
\ 'name': 'igor',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_typescript_eslint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_typescript_eslint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/javascript/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'typescript',
|
||||
\ 'name': 'eslint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_xhtml_jshint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_xhtml_jshint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/html/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'xhtml',
|
||||
\ 'name': 'jshint',
|
||||
|
@ -15,8 +15,6 @@ if exists('g:loaded_syntastic_xslt_xmllint_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_xslt_xmllint_checker = 1
|
||||
|
||||
runtime! syntax_checkers/xml/*.vim
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'xslt',
|
||||
\ 'name': 'xmllint',
|
||||
|
Loading…
Reference in New Issue
Block a user