diff options
author | w0rp <devw0rp@gmail.com> | 2017-05-27 21:27:42 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-27 21:27:42 +0100 |
commit | aca5a00fb7b00655685a4306f1517d4e0f9126ee (patch) | |
tree | f41fac4c2166abaabeadb188c00c0de813f0e484 /autoload | |
parent | 8e997ac2319efac06f7ca6b0912ca00a47ba26d1 (diff) | |
download | ale-aca5a00fb7b00655685a4306f1517d4e0f9126ee.zip |
Fix #500 - Support defining aliases for linter names
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/debugging.vim | 26 | ||||
-rw-r--r-- | autoload/ale/linter.vim | 18 |
2 files changed, 39 insertions, 5 deletions
diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim index f42c9e82..5e4b7a21 100644 --- a/autoload/ale/debugging.vim +++ b/autoload/ale/debugging.vim @@ -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 '' diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim index 05156214..12c6e841 100644 --- a/autoload/ale/linter.vim +++ b/autoload/ale/linter.vim @@ -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 |