mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-10 05:22:31 +08:00
Fix #500 - Support defining aliases for linter names
This commit is contained in:
@@ -105,6 +105,22 @@ function! s:EchoCommandHistory() abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:EchoLinterAliases(all_linters) abort
|
||||
let l:first = 1
|
||||
|
||||
for l:linter in a:all_linters
|
||||
if !empty(l:linter.aliaes)
|
||||
if !l:first
|
||||
echom ' Linter Aliases:'
|
||||
endif
|
||||
|
||||
let l:first = 0
|
||||
|
||||
echom string(l:linter.name) . ' -> ' . string(l:linter.aliaes)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! ale#debugging#Info() abort
|
||||
let l:filetype = &filetype
|
||||
|
||||
@@ -120,8 +136,13 @@ function! ale#debugging#Info() abort
|
||||
call extend(l:all_linters, ale#linter#GetAll(l:aliased_filetype))
|
||||
endfor
|
||||
|
||||
let l:all_names = map(l:all_linters, 'v:val[''name'']')
|
||||
let l:enabled_names = map(l:enabled_linters, 'v:val[''name'']')
|
||||
let l:all_names = map(copy(l:all_linters), 'v:val[''name'']')
|
||||
let l:enabled_names = map(copy(l:enabled_linters), 'v:val[''name'']')
|
||||
let l:linter_aliases = []
|
||||
|
||||
for l:linter in l:all_linters
|
||||
call add(l:linter_aliases, [l:linter.name, l:linter.aliaes])
|
||||
endfor
|
||||
|
||||
" Load linter variables to display
|
||||
" This must be done after linters are loaded.
|
||||
@@ -129,6 +150,7 @@ function! ale#debugging#Info() abort
|
||||
|
||||
echom ' Current Filetype: ' . l:filetype
|
||||
echom 'Available Linters: ' . string(l:all_names)
|
||||
call s:EchoLinterAliases(l:all_linters)
|
||||
echom ' Enabled Linters: ' . string(l:enabled_names)
|
||||
echom ' Linter Variables:'
|
||||
echom ''
|
||||
|
||||
@@ -164,6 +164,13 @@ function! ale#linter#PreProcess(linter) abort
|
||||
throw 'Only one of `lint_file` or `read_buffer` can be `1`'
|
||||
endif
|
||||
|
||||
let l:obj.aliases = get(a:linter, 'aliases', [])
|
||||
|
||||
if type(l:obj.aliases) != type([])
|
||||
\|| len(filter(copy(l:obj.aliases), 'type(v:val) != type('''')')) > 0
|
||||
throw '`aliases` must be a List of String values'
|
||||
endif
|
||||
|
||||
return l:obj
|
||||
endfunction
|
||||
|
||||
@@ -256,9 +263,14 @@ function! ale#linter#Get(original_filetypes) abort
|
||||
elseif type(l:linter_names) == type([])
|
||||
" Select only the linters we or the user has specified.
|
||||
for l:linter in l:all_linters
|
||||
if index(l:linter_names, l:linter.name) >= 0
|
||||
call add(l:filetype_linters, l:linter)
|
||||
endif
|
||||
let l:name_list = [l:linter.name] + l:linter.aliases
|
||||
|
||||
for l:name in l:name_list
|
||||
if index(l:linter_names, l:name) >= 0
|
||||
call add(l:filetype_linters, l:linter)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user