All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 Save g:ale_set_quickfix
6 Save g:ale_set_highlights
11 let g:ale_set_signs = 0
12 let g:ale_set_quickfix = 0
13 let g:ale_set_loclist = 0
14 let g:ale_set_highlights = 0
15 let g:ale_echo_cursor = 0
18 function EmptyString() abort
22 runtime autoload/ale/util.vim
24 function! ale#util#Execute(expr) abort
25 call add(g:expr_list, a:expr)
28 call ale#engine#InitBufferInfo(bufnr(''))
29 " Call this function first, to clear LSP data.
30 call ale#lsp_linter#ClearLSPData()
32 call ale#linter#Define('testft', {
33 \ 'name': 'lsplinter',
35 \ 'executable': function('EmptyString'),
36 \ 'command': function('EmptyString'),
37 \ 'project_root': function('EmptyString'),
38 \ 'language': function('EmptyString'),
40 call ale#linter#Define('testft', {
41 \ 'name': 'lsplinter2',
43 \ 'executable': function('EmptyString'),
44 \ 'command': function('EmptyString'),
45 \ 'project_root': function('EmptyString'),
46 \ 'language': function('EmptyString'),
48 call ale#linter#Define('testft', {
49 \ 'name': 'otherlinter',
50 \ 'callback': 'TestCallback',
51 \ 'executable': has('win32') ? 'cmd': 'true',
59 delfunction EmptyString
61 unlet! b:ale_save_event_fired
63 " Clear LSP data after tests.
64 call ale#lsp_linter#ClearLSPData()
66 runtime autoload/ale/util.vim
68 call ale#linter#Reset()
70 Given testft(Some file with an imaginary filetype):
71 Execute(ALEStopAllLSPs should clear the loclist):
72 " For these tests we only need to set the keys we need.
73 let g:ale_buffer_info[bufnr('')].loclist = [
74 \ {'linter_name': 'lsplinter'},
75 \ {'linter_name': 'otherlinter'},
77 let g:ale_buffer_info[bufnr('')].active_linter_list = [
78 \ {'name': 'lsplinter'},
79 \ {'name': 'otherlinter'},
84 " The loclist should be updated.
87 \ map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.linter_name')
89 " The LSP linter should be removed from the active linter list.
92 \ map(copy(g:ale_buffer_info[bufnr('')].active_linter_list), 'v:val.name')
94 Execute(ALEStopLSP should stop a named LSP):
95 let g:ale_buffer_info[bufnr('')].loclist = [
96 \ {'linter_name': 'lsplinter'},
97 \ {'linter_name': 'lsplinter2'},
98 \ {'linter_name': 'otherlinter'},
100 let g:ale_buffer_info[bufnr('')].active_linter_list = [
101 \ {'name': 'lsplinter'},
102 \ {'name': 'lsplinter2'},
103 \ {'name': 'otherlinter'},
105 call ale#lsp_linter#SetLSPLinterMap({
106 \ 'conn1': {'name': 'lsplinter'},
107 \ 'conn2': {'name': 'lsplinter2'},
108 \ 'conn3': {'name': 'lsplinter'},
113 " We should remove only the items for this linter.
115 \ ['lsplinter2', 'otherlinter'],
116 \ map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.linter_name')
118 " The linter should be removed from the active linter list.
120 \ ['lsplinter2', 'otherlinter'],
121 \ map(copy(g:ale_buffer_info[bufnr('')].active_linter_list), 'v:val.name')
123 " The connections linters with this name should be removed.
125 \ {'conn2': {'name': 'lsplinter2'}},
126 \ ale#lsp_linter#GetLSPLinterMap()
128 Execute(ALEStopLSP should not clear results for linters not running):
129 let g:ale_buffer_info[bufnr('')].loclist = [
130 \ {'linter_name': 'lsplinter'},
131 \ {'linter_name': 'otherlinter'},
133 let g:ale_buffer_info[bufnr('')].active_linter_list = [
134 \ {'name': 'lsplinter'},
135 \ {'name': 'otherlinter'},
140 " We should emit a message saying the server isn't running.
142 \ ['echom ''No running language server with name: lsplinter'''],
145 " We should keep the linter items.
147 \ ['lsplinter', 'otherlinter'],
148 \ map(copy(g:ale_buffer_info[bufnr('')].loclist), 'v:val.linter_name')
150 \ ['lsplinter', 'otherlinter'],
151 \ map(copy(g:ale_buffer_info[bufnr('')].active_linter_list), 'v:val.name')
153 Execute(ALEStopLSP with a bang should not emit warnings):
154 ALEStopLSP! lsplinter
156 AssertEqual [], g:expr_list
158 Execute(ALEStopLSP's completion function should suggest running linter names):
159 call ale#lsp_linter#SetLSPLinterMap({
160 \ 'conn1': {'name': 'pyright'},
161 \ 'conn2': {'name': 'pylsp'},
162 \ 'conn3': {'name': 'imaginaryserver'},
166 \ ['imaginaryserver', 'pylsp', 'pyright'],
167 \ ale#lsp#reset#Complete('', '', 42)
168 AssertEqual ['imaginaryserver'], ale#lsp#reset#Complete('inary', '', 42)
169 AssertEqual ['pylsp'], ale#lsp#reset#Complete('LSP', '', 42)