2016-10-11 22:48:43 +00:00
|
|
|
Before:
|
2017-11-14 19:55:28 +00:00
|
|
|
Save g:ale_linters
|
|
|
|
Save g:ale_linter_aliases
|
2016-10-11 22:48:43 +00:00
|
|
|
|
2019-01-12 13:08:52 +00:00
|
|
|
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}
|
|
|
|
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': [], 'lsp': ''}
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Reset()
|
2018-04-24 20:48:33 +00:00
|
|
|
call ale#linter#PreventLoading('testft')
|
|
|
|
call ale#linter#PreventLoading('javascript')
|
|
|
|
call ale#linter#PreventLoading('typescript')
|
2017-05-27 20:27:42 +00:00
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
|
|
|
|
unlet! g:testlinter1
|
|
|
|
unlet! g:testlinter2
|
2017-04-25 22:52:13 +00:00
|
|
|
unlet! b:ale_linters
|
|
|
|
unlet! b:ale_linter_aliases
|
2017-05-27 20:27:42 +00:00
|
|
|
call ale#linter#Reset()
|
2016-10-11 22:48:43 +00:00
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able to get a defined linter):
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able get select a single linter):
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
|
|
|
Execute (You should be able to select a linter by an alias):
|
|
|
|
let g:testlinter1.aliases = ['foo', 'linter1alias']
|
|
|
|
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['linter1alias']}
|
|
|
|
|
2016-10-22 02:02:20 +00:00
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able to select linters with a buffer option):
|
2017-04-25 22:52:13 +00:00
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1', 'testlinter2']}
|
|
|
|
let b:ale_linters = {'testft': ['testlinter1']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2017-04-25 22:52:13 +00:00
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
2017-11-11 23:55:04 +00:00
|
|
|
Execute (b:ale_linters should work when set to a List):
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1', 'testlinter2']}
|
|
|
|
let b:ale_linters = ['testlinter1']
|
|
|
|
|
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
|
|
|
Execute (b:ale_linters should disable all linters when set to an empty List):
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1', 'testlinter2']}
|
|
|
|
let b:ale_linters = []
|
|
|
|
|
|
|
|
AssertEqual [], ale#linter#Get('testft')
|
|
|
|
|
|
|
|
Execute (b:ale_linters should enable all available linters when set to 'all'):
|
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1']}
|
|
|
|
let b:ale_linters = 'all'
|
|
|
|
|
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (Buffer settings shouldn't completely replace global settings):
|
2017-04-25 22:52:13 +00:00
|
|
|
call ale#linter#Define('testft', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft': ['testlinter1']}
|
|
|
|
let b:ale_linters = {'testft2': ['testlinter1', 'testlinter2']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2017-04-25 22:52:13 +00:00
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able to alias linters from one filetype to another):
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
let g:ale_linter_aliases = {'testft2': 'testft1'}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2016-10-22 02:02:20 +00:00
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft2')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able to filter aliased linters):
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft1', g:testlinter2)
|
|
|
|
let g:ale_linters = {'testft1': ['testlinter1'], 'testft2': ['testlinter2']}
|
|
|
|
let g:ale_linter_aliases = {'testft2': 'testft1'}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2016-10-22 02:02:20 +00:00
|
|
|
AssertEqual [g:testlinter1], ale#linter#Get('testft1')
|
|
|
|
AssertEqual [g:testlinter2], ale#linter#Get('testft2')
|
2016-10-11 22:48:43 +00:00
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (Dot-separated filetypes should be handled correctly):
|
2016-10-22 02:02:20 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2016-10-22 02:02:20 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1.testft2')
|
2016-10-11 22:52:13 +00:00
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (Linters for multiple aliases should be loaded):
|
2017-04-11 20:10:08 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
let ale_linter_aliases = {'testft3': ['testft1', 'testft2']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2017-04-11 20:10:08 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft3')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (You should be able to alias filetypes to themselves and another):
|
2017-04-11 20:10:08 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
let ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2017-04-11 20:10:08 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (Buffer-local overrides for aliases should be used):
|
2017-04-25 22:52:13 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
let g:ale_linter_aliases = {'testft1': ['testft2']}
|
|
|
|
let b:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2017-04-25 22:52:13 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (The local alias option shouldn't completely replace the global one):
|
2017-04-25 22:52:13 +00:00
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
let g:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
|
2017-10-02 16:11:54 +00:00
|
|
|
" This is a key set for a different filetype.
|
2017-04-25 22:52:13 +00:00
|
|
|
" We should look for a key in this Dictionary first, and then check the
|
|
|
|
" global Dictionary.
|
|
|
|
let b:ale_linter_aliases = {'testft3': ['testft1']}
|
2017-05-27 20:27:42 +00:00
|
|
|
|
2018-10-26 08:22:33 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
|
|
|
|
|
2017-11-12 00:11:50 +00:00
|
|
|
Execute (Lists 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')
|
|
|
|
|
2018-10-26 08:22:33 +00:00
|
|
|
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')
|
|
|
|
|
2017-11-12 00:11:50 +00:00
|
|
|
Execute (Buffer-local overrides for aliases should be used):
|
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft2', g:testlinter2)
|
|
|
|
let g:ale_linter_aliases = {'testft1': ['testft2']}
|
|
|
|
let b:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
|
|
|
|
|
2017-04-25 22:52:13 +00:00
|
|
|
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
|
|
|
|
|
2019-06-10 21:41:20 +00:00
|
|
|
Execute (Linters new linters with the same name should replace old ones):
|
|
|
|
let g:testlinter1.name = g:testlinter2.name
|
|
|
|
|
|
|
|
call ale#linter#Define('testft1', g:testlinter1)
|
|
|
|
call ale#linter#Define('testft1', g:testlinter2)
|
|
|
|
|
|
|
|
AssertEqual [g:testlinter2], ale#linter#GetAll(['testft1'])
|
|
|
|
|
2017-05-27 20:27:42 +00:00
|
|
|
Execute (Linters should be loaded from disk appropriately):
|
2018-04-24 20:48:33 +00:00
|
|
|
call ale#linter#Reset()
|
2019-01-12 13:08:52 +00:00
|
|
|
AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': ''}], ale#linter#Get('testft')
|
2017-06-20 09:50:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
Execute (Linters for later filetypes should replace the former ones):
|
|
|
|
call ale#linter#Define('javascript', {
|
|
|
|
\ 'name': 'eslint',
|
|
|
|
\ 'executable': 'y',
|
|
|
|
\ 'command': 'y',
|
|
|
|
\ 'callback': 'y',
|
|
|
|
\})
|
|
|
|
call ale#linter#Define('typescript', {
|
|
|
|
\ 'name': 'eslint',
|
|
|
|
\ 'executable': 'x',
|
|
|
|
\ 'command': 'x',
|
|
|
|
\ 'callback': 'x',
|
|
|
|
\})
|
|
|
|
|
|
|
|
AssertEqual [
|
2019-01-12 13:08:52 +00:00
|
|
|
\ {'output_stream': 'stdout', 'lint_file': 0, 'read_buffer': 1, 'name': 'eslint', 'executable': 'x', 'lsp': '', 'aliases': [], 'command': 'x', 'callback': 'x'}
|
2017-06-20 09:50:38 +00:00
|
|
|
\], ale#linter#Get('javascript.typescript')
|