diff options
author | w0rp <devw0rp@gmail.com> | 2018-10-26 09:22:33 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-10-26 09:22:52 +0100 |
commit | 77aacf0c91e15449e9b0c332047b666dd21ee9d4 (patch) | |
tree | de7a707e5539583a22a0cb5e029ad2bb98a78f09 | |
parent | 320c74ce1a28bfb4f2e10e1efcd2ca93701fc00e (diff) | |
download | ale-77aacf0c91e15449e9b0c332047b666dd21ee9d4.zip |
#927 Allow b:ale_linter_aliases to be set to a String
-rw-r--r-- | autoload/ale/linter.vim | 3 | ||||
-rw-r--r-- | doc/ale.txt | 6 | ||||
-rw-r--r-- | test/test_linter_retrieval.vader | 11 |
3 files changed, 17 insertions, 3 deletions
diff --git a/autoload/ale/linter.vim b/autoload/ale/linter.vim index 7c1dc53e..dbf9f221 100644 --- a/autoload/ale/linter.vim +++ b/autoload/ale/linter.vim @@ -346,8 +346,9 @@ endfunction function! s:GetAliasedFiletype(original_filetype) abort let l:buffer_aliases = get(b:, 'ale_linter_aliases', {}) - " b:ale_linter_aliases can be set to a List. + " b:ale_linter_aliases can be set to a List or String. if type(l:buffer_aliases) is v:t_list + \|| type(l:buffer_aliases) is v:t_string return l:buffer_aliases endif diff --git a/doc/ale.txt b/doc/ale.txt index 7e37d2dc..66ce8ab1 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -1310,10 +1310,12 @@ g:ale_linter_aliases *g:ale_linter_aliases* ALE will first look for aliases for filetypes in the `b:ale_linter_aliases` variable, then `g:ale_linter_aliases`, and then a default Dictionary. - `b:ale_linter_aliases` can be set to a |List|, to tell ALE to load the - linters for specific filetypes for a given buffer. > + `b:ale_linter_aliases` can be set to a |List| or a |String|, to tell ALE to + load the linters for specific filetypes for a given buffer. > let b:ale_linter_aliases = ['html', 'javascript', 'css'] + " OR, Alias a filetype to only a single filetype with a String. + let b:ale_linter_aliases = 'javascript' < No linters will be loaded when the buffer's filetype is empty. diff --git a/test/test_linter_retrieval.vader b/test/test_linter_retrieval.vader index 6c402d54..a1c34622 100644 --- a/test/test_linter_retrieval.vader +++ b/test/test_linter_retrieval.vader @@ -130,6 +130,8 @@ Execute (The local alias option shouldn't completely replace the global one): " global Dictionary. let b:ale_linter_aliases = {'testft3': ['testft1']} + AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1') + Execute (Lists should be accepted for local aliases): call ale#linter#Define('testft1', g:testlinter1) call ale#linter#Define('testft2', g:testlinter2) @@ -139,6 +141,15 @@ Execute (Lists should be accepted for local aliases): AssertEqual [g:testlinter2], ale#linter#Get('anything.else') +Execute (Strings should be accepted for local aliases): + call ale#linter#Define('testft1', g:testlinter1) + call ale#linter#Define('testft2', g:testlinter2) + let g:ale_linter_aliases = {'testft1': ['testft1', 'testft2']} + " We should load the testft2 linters for this buffer, with no duplicates. + let b:ale_linter_aliases = 'testft2' + + AssertEqual [g:testlinter2], ale#linter#Get('anything.else') + Execute (Buffer-local overrides for aliases should be used): call ale#linter#Define('testft1', g:testlinter1) call ale#linter#Define('testft2', g:testlinter2) |