1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
Before:
Save g:ale_linters
Save g:ale_linter_aliases
let g:testlinter1 = {'name': 'testlinter1', 'executable': 'testlinter1', 'command': 'testlinter1', 'callback': 'testCB1', 'output_stream': 'stdout', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': '', 'add_newline': 0}
let g:testlinter2 = {'name': 'testlinter2', 'executable': 'testlinter2', 'command': 'testlinter2', 'callback': 'testCB2', 'output_stream': 'stdout', 'read_buffer': 0, 'lint_file': 1, 'aliases': [], 'lsp': '', 'add_newline': 0}
call ale#linter#Reset()
After:
Restore
unlet! g:testlinter1
unlet! g:testlinter2
unlet! b:ale_linters
unlet! b:ale_linter_aliases
call ale#linter#Reset()
Execute (You should be able to get a defined linter):
call ale#linter#Define('testft', g:testlinter1)
AssertEqual [g:testlinter1], ale#linter#Get('testft')
Execute (You should be able get select a single linter):
call ale#linter#Define('testft', g:testlinter1)
call ale#linter#Define('testft', g:testlinter2)
let g:ale_linters = {'testft': ['testlinter1']}
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']}
AssertEqual [g:testlinter1], ale#linter#Get('testft')
Execute (You should be able to select linters with a buffer option):
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']}
AssertEqual [g:testlinter1], ale#linter#Get('testft')
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')
Execute (Buffer settings shouldn't completely replace global settings):
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']}
AssertEqual [g:testlinter1], ale#linter#Get('testft')
Execute (You should be able to alias linters from one filetype to another):
call ale#linter#Define('testft1', g:testlinter1)
let g:ale_linter_aliases = {'testft2': 'testft1'}
AssertEqual [g:testlinter1], ale#linter#Get('testft2')
Execute (You should be able to filter aliased linters):
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'}
AssertEqual [g:testlinter1], ale#linter#Get('testft1')
AssertEqual [g:testlinter2], ale#linter#Get('testft2')
Execute (Dot-separated filetypes should be handled correctly):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1.testft2')
Execute (Linters for multiple aliases should be loaded):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let ale_linter_aliases = {'testft3': ['testft1', 'testft2']}
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft3')
Execute (You should be able to alias filetypes to themselves and another):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
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']}
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
Execute (The local alias option shouldn't completely replace the global one):
call ale#linter#Define('testft1', g:testlinter1)
call ale#linter#Define('testft2', g:testlinter2)
let g:ale_linter_aliases = {'testft1': ['testft1', 'testft2']}
" This is a key set for a different filetype.
" We should look for a key in this Dictionary first, and then check the
" global Dictionary.
let b:ale_linter_aliases = {'testft3': ['testft1']}
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')
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']}
AssertEqual [g:testlinter1, g:testlinter2], ale#linter#Get('testft1')
Execute (Linters should be loaded from disk appropriately):
AssertEqual [{'name': 'testlinter', 'output_stream': 'stdout', 'executable': 'testlinter', 'command': 'testlinter', 'callback': 'testCB', 'read_buffer': 1, 'lint_file': 0, 'aliases': [], 'lsp': '', 'add_newline': 0}], ale#linter#Get('testft')
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 [
\ {'output_stream': 'stdout', 'lint_file': 0, 'read_buffer': 1, 'name': 'eslint', 'executable': 'x', 'lsp': '', 'aliases': [], 'command': 'x', 'callback': 'x', 'add_newline': 0}
\], ale#linter#Get('javascript.typescript')
|