summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorvaltermro <valtermro@outlook.com>2017-04-11 17:10:08 -0300
committervaltermro <valtermro@outlook.com>2017-04-12 19:47:34 -0300
commit475dd2e76a0fe84d6c804ee00ea5b04a1fbdcdd2 (patch)
tree6fcde692b499218fa7d50f084c3f2c192921cf25 /autoload
parent8b890caa31411cd022156dca8e4c7f4c5fb65fc9 (diff)
downloadale-475dd2e76a0fe84d6c804ee00ea5b04a1fbdcdd2.zip
Add support for multiple filetypes in filetype aliasing
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/linter.vim35
1 files changed, 19 insertions, 16 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim
index 9a838ffa..eec9cf15 100644
--- a/autoload/ale/linter.vim
+++ b/autoload/ale/linter.vim
@@ -174,26 +174,25 @@ function! ale#linter#Define(filetype, linter) abort
call add(s:linters[a:filetype], l:new_linter)
endfunction
-function! ale#linter#GetAll(filetype) abort
- if a:filetype ==# ''
- " Empty filetype? Nothing to be done about that.
- return []
- endif
+function! ale#linter#GetAll(filetypes) abort
+ let l:combined_linters = []
- if has_key(s:linters, a:filetype)
- " We already loaded the linter files for this filetype, so stop here.
- return s:linters[a:filetype]
- endif
+ for l:filetype in a:filetypes
+ " Haven't we loaded the linter files for this filetype yet?
+ if !has_key(s:linters, l:filetype)
+ " So load it
+ execute 'silent! runtime! ale_linters/' . l:filetype . '/*.vim'
- " Load all linters for a given filetype.
- execute 'silent! runtime! ale_linters/' . a:filetype . '/*.vim'
+ " Still don't have the linter files? There must be occured an error
+ if !has_key(s:linters, l:filetype)
+ let s:linters[l:filetype] = []
+ endif
+ endif
- if !has_key(s:linters, a:filetype)
- " If we couldn't load any linters, let everyone know.
- let s:linters[a:filetype] = []
- endif
+ call extend(l:combined_linters, get(s:linters, l:filetype, []))
+ endfor
- return s:linters[a:filetype]
+ return l:combined_linters
endfunction
function! ale#linter#ResolveFiletype(original_filetype) abort
@@ -209,6 +208,10 @@ function! ale#linter#ResolveFiletype(original_filetype) abort
\ )
\)
+ if type(l:filetype) != type([])
+ return [l:filetype]
+ endif
+
return l:filetype
endfunction