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_lint_on_text_changed
5 Save g:ale_completion_enabled
6 Save g:ale_completion_autoimport
7 Save g:ale_completion_max_suggestions
13 let g:ale_lint_on_text_changed = 'always'
14 let g:ale_completion_enabled = 0
15 let g:ale_completion_autoimport = 0
16 let g:ale_completion_max_suggestions = 50
17 let g:ale_linters = {'typescript': ['tsserver'], 'python': ['pyre']}
20 let g:server_started_value = 1
22 let g:LastCallback = v:null
23 let g:LastHandleCallback = v:null
24 let g:sent_message_list = []
25 let g:code_action_list = []
26 let g:execute_list = []
27 let g:ale_queue_call_list = []
29 runtime autoload/ale.vim
30 runtime autoload/ale/util.vim
31 runtime autoload/ale/code_action.vim
32 runtime autoload/ale/lsp.vim
33 runtime autoload/ale/lsp_linter.vim
35 function! ale#util#Execute(expr) abort
36 call add(g:execute_list, a:expr)
39 function! ale#Queue(...) abort
40 call add(g:ale_queue_call_list, a:000)
43 function! ale#lsp#RegisterCallback(id, Callback) abort
44 let g:LastHandleCallback = a:Callback
47 function! ale#lsp#NotifyForChanges(id, buffer) abort
50 function! ale#lsp#HasCapability(id, capability) abort
54 function! ale#lsp#Send(id, message) abort
57 call add(g:sent_message_list, a:message)
62 function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
63 let g:LastCallback = a:Callback
65 return g:server_started_value
68 function! ale#code_action#HandleCodeAction(code_action, options) abort
69 Assert !get(a:options, 'should_save')
71 call add(g:code_action_list, a:code_action)
74 function GetLastMessage()
75 return get(g:execute_list, -1, '')
78 function CheckLintStates(conn_id, message)
79 " Check that we request more linter results after adding completions.
80 AssertEqual [[0, '']], g:ale_queue_call_list
84 let g:ale_queue_call_list = []
85 call g:LastHandleCallback(a:conn_id, a:message)
86 AssertEqual [], g:ale_queue_call_list
89 let g:ale_lint_on_text_changed = 1
91 let g:ale_queue_call_list = []
92 call g:LastHandleCallback(a:conn_id, a:message)
93 AssertEqual [[0, '']], g:ale_queue_call_list
95 let g:ale_lint_on_text_changed = v:true
97 let g:ale_queue_call_list = []
98 call g:LastHandleCallback(a:conn_id, a:message)
99 AssertEqual [[0, '']], g:ale_queue_call_list
101 let g:ale_lint_on_text_changed = 'normal'
103 let g:ale_queue_call_list = []
104 call g:LastHandleCallback(a:conn_id, a:message)
105 AssertEqual [[0, '']], g:ale_queue_call_list
107 let g:ale_lint_on_text_changed = 'insert'
109 let g:ale_queue_call_list = []
110 call g:LastHandleCallback(a:conn_id, a:message)
111 AssertEqual [[0, '']], g:ale_queue_call_list
113 let g:ale_queue_call_list = []
114 let g:ale_lint_on_text_changed = 'never'
116 call g:LastHandleCallback(a:conn_id, a:message)
117 AssertEqual [], g:ale_queue_call_list
119 let g:ale_lint_on_text_changed = '0'
121 call g:LastHandleCallback(a:conn_id, a:message)
122 AssertEqual [], g:ale_queue_call_list
124 let g:ale_lint_on_text_changed = 0
126 call g:LastHandleCallback(a:conn_id, a:message)
127 AssertEqual [], g:ale_queue_call_list
129 let g:ale_lint_on_text_changed = 'xxx'
131 call g:LastHandleCallback(a:conn_id, a:message)
132 AssertEqual [], g:ale_queue_call_list
136 call ale#linter#Reset()
140 delfunction GetLastMessage
141 delfunction CheckLintStates
143 unlet! g:LastCallback
144 unlet! g:LastHandleCallback
146 unlet! g:server_started_value
147 unlet! g:sent_message_list
148 unlet! g:code_action_list
149 unlet! g:ale_queue_call_list
150 unlet! g:execute_list
151 unlet! g:received_message
152 unlet! b:ale_old_omnifunc
153 unlet! b:ale_old_completeopt
154 unlet! b:ale_completion_info
155 unlet! b:ale_completion_result
156 unlet! b:ale_complete_done_time
158 runtime autoload/ale.vim
159 runtime autoload/ale/util.vim
160 runtime autoload/ale/code_action.vim
161 runtime autoload/ale/lsp.vim
162 runtime autoload/ale/lsp_linter.vim
164 Given typescript(Some example TypeScript code):
166 let foo = missingword
170 Execute(ALEImport should complain when there's no word at the cursor):
171 call setpos('.', [bufnr(''), 3, 1, 0])
174 AssertEqual 'echom ''Nothing to complete at cursor!''', GetLastMessage()
176 Execute(ALEImport should tell the user if no LSP is available):
177 let g:server_started_value = 0
179 call setpos('.', [bufnr(''), 2, 16, 0])
183 \ 'echom ''No completion providers are available.''',
186 Execute(ALEImport should request imports correctly for tsserver):
187 call setpos('.', [bufnr(''), 2, 16, 0])
195 \ 'source': 'ale-import',
199 \ 'prefix': 'missingword',
200 \ 'additional_edits_only': 1,
202 \ b:ale_completion_info
203 Assert g:LastCallback isnot v:null
205 call g:LastCallback(ale#linter#Get(&filetype)[0], {
206 \ 'connection_id': 347,
207 \ 'buffer': bufnr(''),
214 \ 'source': 'ale-import',
218 \ 'prefix': 'missingword',
219 \ 'additional_edits_only': 1,
221 \ b:ale_completion_info
222 Assert g:LastHandleCallback isnot v:null
224 call g:LastHandleCallback(347, {
226 \ 'command': 'completions',
228 \ {'name': 'missingwordIgnoreMe'},
229 \ {'name': 'missingword'},
235 \ [0, 'ts@completions', {
236 \ 'file': expand('%:p'),
237 \ 'includeExternalModuleExports': v:true,
240 \ 'prefix': 'missingword',
242 \ [0, 'ts@completionEntryDetails', {
243 \ 'file': expand('%:p'),
244 \ 'entryNames': [{'name': 'missingword'}],
249 \ g:sent_message_list
250 AssertEqual 2, b:ale_completion_info.request_id
252 let g:ale_enabled = 1
253 let g:received_message = {
255 \ 'command': 'completionEntryDetails',
258 \ 'name': 'missingword',
259 \ 'kind': 'className',
260 \ 'displayParts': [],
262 \ 'description': 'import { missingword } from "./Something";',
268 call g:LastHandleCallback(347, g:received_message)
273 \ 'description': 'import { missingword } from "./Something";',
279 call CheckLintStates(347, g:received_message)
281 Execute(ALEImport should tell the user when no completions were found from tsserver):
282 call setpos('.', [bufnr(''), 2, 16, 0])
290 \ 'source': 'ale-import',
294 \ 'prefix': 'missingword',
295 \ 'additional_edits_only': 1,
297 \ b:ale_completion_info
298 Assert g:LastCallback isnot v:null
300 call g:LastCallback(ale#linter#Get(&filetype)[0], {
301 \ 'connection_id': 347,
302 \ 'buffer': bufnr(''),
309 \ 'source': 'ale-import',
313 \ 'prefix': 'missingword',
314 \ 'additional_edits_only': 1,
316 \ b:ale_completion_info
317 Assert g:LastHandleCallback isnot v:null
319 call g:LastHandleCallback(347, {
321 \ 'command': 'completions',
323 \ {'name': 'missingwordIgnoreMe'},
327 AssertEqual 'echom ''No possible imports found.''', GetLastMessage()
329 Given python(Some example Python code):
335 Execute(ALEImport should request imports correctly for language servers):
336 call setpos('.', [bufnr(''), 2, 12, 0])
344 \ 'source': 'ale-import',
348 \ 'prefix': 'missingword',
349 \ 'additional_edits_only': 1,
351 \ b:ale_completion_info
352 Assert g:LastCallback isnot v:null
354 call g:LastCallback(ale#linter#Get(&filetype)[0], {
355 \ 'connection_id': 347,
356 \ 'buffer': bufnr(''),
363 \ 'source': 'ale-import',
367 \ 'prefix': 'missingword',
368 \ 'additional_edits_only': 1,
369 \ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
371 \ b:ale_completion_info
372 Assert g:LastHandleCallback isnot v:null
376 \ [0, 'textDocument/completion', {
377 \ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
378 \ 'position': {'character': 16, 'line': 1}
381 \ g:sent_message_list
382 AssertEqual 1, b:ale_completion_info.request_id
384 let g:ale_enabled = 1
385 let g:received_message = {
389 \ 'isIncomplete': v:false,
392 \ 'detail': 'Some other word we should ignore',
393 \ 'filterText': 'missingwordIgnoreMe',
394 \ 'insertText': 'missingwordIgnoreMe',
395 \ 'insertTextFormat': 1,
397 \ 'label': ' missingwordIgnoreMe',
398 \ 'sortText': '3ee19999missingword',
399 \ 'additionalTextEdits': [
402 \ 'start': {'line': 1, 'character': 1},
403 \ 'end': {'line': 2, 'character': 1},
405 \ 'newText': 'from something import missingwordIgnoreMe',
410 \ 'detail': 'Some word without text edits',
411 \ 'filterText': 'missingword',
412 \ 'insertText': 'missingword',
413 \ 'insertTextFormat': 1,
415 \ 'label': ' missingword',
416 \ 'sortText': '3ee19999missingword',
419 \ 'detail': 'The word we should use',
420 \ 'filterText': 'missingword',
421 \ 'insertText': 'missingword',
422 \ 'insertTextFormat': 1,
424 \ 'label': ' missingword',
425 \ 'sortText': '3ee19999missingword',
426 \ 'additionalTextEdits': [
429 \ 'start': {'line': 1, 'character': 1},
430 \ 'end': {'line': 2, 'character': 1},
432 \ 'newText': 'from something import missingword',
437 \ 'detail': 'The other word we should not use',
438 \ 'filterText': 'missingword',
439 \ 'insertText': 'missingword',
440 \ 'insertTextFormat': 1,
442 \ 'label': ' missingword',
443 \ 'sortText': '3ee19999missingword',
444 \ 'additionalTextEdits': [
447 \ 'start': {'line': 1, 'character': 1},
448 \ 'end': {'line': 2, 'character': 1},
450 \ 'newText': 'from something_else import missingword',
457 call g:LastHandleCallback(347, g:received_message)
462 \ 'description': 'completion',
465 \ 'fileName': expand('%:p'),
468 \ 'start': {'line': 2, 'offset': 2},
469 \ 'end': {'line': 3, 'offset': 2},
470 \ 'newText': 'from something import missingword',
479 call CheckLintStates(347, g:received_message)
481 Execute(ALEImport should tell the user when no completions were found from a language server):
482 call setpos('.', [bufnr(''), 2, 12, 0])
490 \ 'source': 'ale-import',
494 \ 'prefix': 'missingword',
495 \ 'additional_edits_only': 1,
497 \ b:ale_completion_info
498 Assert g:LastCallback isnot v:null
500 call g:LastCallback(ale#linter#Get(&filetype)[0], {
501 \ 'connection_id': 347,
502 \ 'buffer': bufnr(''),
509 \ 'source': 'ale-import',
513 \ 'prefix': 'missingword',
514 \ 'additional_edits_only': 1,
515 \ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
517 \ b:ale_completion_info
518 Assert g:LastHandleCallback isnot v:null
522 \ [0, 'textDocument/completion', {
523 \ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
524 \ 'position': {'character': 16, 'line': 1}
527 \ g:sent_message_list
528 AssertEqual 1, b:ale_completion_info.request_id
530 let g:received_message = {
534 \ 'isIncomplete': v:false,
537 \ 'detail': 'Some other word we should ignore',
538 \ 'filterText': 'missingwordIgnoreMe',
539 \ 'insertText': 'missingwordIgnoreMe',
540 \ 'insertTextFormat': 1,
542 \ 'label': ' missingwordIgnoreMe',
543 \ 'sortText': '3ee19999missingword',
544 \ 'additionalTextEdits': [
547 \ 'start': {'line': 1, 'character': 1},
548 \ 'end': {'line': 2, 'character': 1},
550 \ 'newText': 'from something import missingwordIgnoreMe',
555 \ 'detail': 'Some word without text edits',
556 \ 'filterText': 'missingword',
557 \ 'insertText': 'missingword',
558 \ 'insertTextFormat': 1,
560 \ 'label': ' missingword',
561 \ 'sortText': '3ee19999missingword',
566 call g:LastHandleCallback(347, g:received_message)
568 AssertEqual 'echom ''No possible imports found.''', GetLastMessage()