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
|
Before:
unlet! b:ale_completion_info
unlet! b:ale_completion_response
unlet! b:ale_completion_parser
unlet! b:ale_completion_result
let b:lsp_started = 0
runtime autoload/ale/lsp_linter.vim
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
return b:lsp_started
endfunction
function! Identity(x) abort
return a:x
endfunction
function! SetCompletionResult(...) abort
let b:ale_completion_result = ['foo']
endfunction
function! SetCompletionResponse(...) abort
let b:ale_completion_response = ['foo']
let b:ale_completion_parser = 'Identity'
endfunction
After:
unlet! b:ale_completion_info
unlet! b:ale_completion_response
unlet! b:ale_completion_parser
unlet! b:ale_completion_result
unlet! b:lsp_started
delfunction Identity
delfunction SetCompletionResult
delfunction SetCompletionResponse
runtime autoload/ale/lsp_linter.vim
call ale#linter#Reset()
Given typescript():
let abc = y.
let foo = ab
let foo = (ab)
Execute(-3 should be returned when completion results cannot be requested):
AssertEqual -3, ale#completion#OmniFunc(1, '')
Execute(The start position should be returned when results can be requested):
let b:lsp_started = 1
call setpos('.', [bufnr(''), 3, 14, 0])
AssertEqual 11, ale#completion#OmniFunc(1, '')
Execute(The omnifunc function should return async results):
" Neovim 0.2.0 struggles at running these tests.
if !has('nvim') || has('nvim-0.3.0')
call timer_start(0, function('SetCompletionResult'))
AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
endif
Execute(The omnifunc function should parse and return async responses):
if !has('nvim') || has('nvim-0.3.0')
call timer_start(0, function('SetCompletionResponse'))
AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
endif
|