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.
2 call ale#test#SetDirectory('/testplugin/test')
3 call ale#test#SetFilename('dummy.txt')
6 let g:message_list = []
8 let g:show_message_arg_list = []
10 let g:ale_floating_preview = 0
11 let g:ale_hover_to_floating_preview = 0
12 let g:ale_detail_to_floating_preview = 0
14 runtime autoload/ale/linter.vim
15 runtime autoload/ale/lsp.vim
16 runtime autoload/ale/lsp_linter.vim
17 runtime autoload/ale/util.vim
18 runtime autoload/ale/floating_preview.vim
19 runtime autoload/ale/hover.vim
21 let g:floated_lines = []
22 let g:floating_preview_show_called = 0
24 " Stub out so we can track the call
25 function! ale#floating_preview#Show(lines, ...) abort
26 let g:floating_preview_show_called = 1
27 let g:floated_lines = a:lines
31 function! ale#lsp_linter#StartLSP(buffer, linter, callback) abort
32 let g:Callback = a:callback
35 \ 'command': 'foobar',
36 \ 'connection_id': 347,
37 \ 'project_root': '/foo/bar',
41 function! ale#lsp#Send(conn_id, message, root) abort
42 call add(g:message_list, a:message)
47 function! ale#util#ShowMessage(string, ...) abort
48 call add(g:show_message_arg_list, [a:string] + a:000)
51 function! HandleValidLSPResult(result) abort
52 " The cursor is beyond the length of the line.
53 " We will clamp the cursor position with the line length.
54 call setpos('.', [bufnr(''), 1, 5, 0])
56 call ale#hover#SetMap({3: {
57 \ 'buffer': bufnr(''),
61 call ale#hover#HandleLSPResponse(
72 call ale#hover#SetMap({})
73 call ale#test#RestoreDirectory()
74 call ale#linter#Reset()
79 unlet! g:show_message_arg_list
81 delfunction HandleValidLSPResult
83 runtime autoload/ale/lsp_linter.vim
84 runtime autoload/ale/lsp.vim
85 runtime autoload/ale/util.vim
86 runtime autoload/ale/floating_preview.vim
88 Given python(Some Python file):
93 Execute(Other messages for the tsserver handler should be ignored):
94 call ale#hover#HandleTSServerResponse(1, {'command': 'foo'})
96 Execute(Failed hover responses should be handled correctly):
97 call ale#hover#SetMap({3: {}})
98 call ale#hover#HandleTSServerResponse(
100 \ {'command': 'quickinfo', 'request_seq': 3}
102 AssertEqual {}, ale#hover#GetMap()
104 Given typescript(Some typescript file):
109 Execute(tsserver quickinfo responses will null missing bodies should be handled):
110 call ale#hover#SetMap({3: {}})
111 call ale#hover#HandleTSServerResponse(
114 \ 'command': 'quickinfo',
120 AssertEqual {}, ale#hover#GetMap()
122 Execute(tsserver quickinfo displayString values should be displayed):
123 call ale#hover#SetMap({3: {'buffer': bufnr('')}})
124 call ale#hover#HandleTSServerResponse(
127 \ 'command': 'quickinfo',
130 \ 'body': {'displayString': 'foo bar'},
134 AssertEqual [['foo bar']], g:show_message_arg_list
135 AssertEqual {}, ale#hover#GetMap()
137 Execute(LSP hover responses with just a string should be handled):
138 call HandleValidLSPResult({'contents': 'foobar'})
140 AssertEqual [['foobar', {'commands': []}]], g:show_message_arg_list
141 AssertEqual {}, ale#hover#GetMap()
143 Execute(LSP hover null responses should be handled):
144 call HandleValidLSPResult(v:null)
146 AssertEqual [], g:show_message_arg_list
147 AssertEqual {}, ale#hover#GetMap()
149 Execute(LSP hover responses with markup content should be handled):
150 call HandleValidLSPResult({'contents': {'kind': 'markdown', 'value': 'markup'}})
152 AssertEqual [['markup', {'commands': []}]], g:show_message_arg_list
153 AssertEqual {}, ale#hover#GetMap()
155 Execute(LSP hover responses with markup content missing values should be handled):
156 call HandleValidLSPResult({'contents': {'kind': 'markdown'}})
158 AssertEqual [], g:show_message_arg_list
159 AssertEqual {}, ale#hover#GetMap()
161 Execute(LSP hover response with lists of strings should be handled):
162 call HandleValidLSPResult({'contents': [
167 AssertEqual [["foo\n\nbar", {'commands': []}]], g:show_message_arg_list
168 AssertEqual {}, ale#hover#GetMap()
170 Execute(LSP hover response with lists of strings and marked strings should be handled):
171 call HandleValidLSPResult({'contents': [
172 \ {'language': 'python', 'value': 'foo'},
181 \ 'unlet! b:current_syntax',
182 \ 'syntax include @ALE_hover_python syntax/python.vim',
183 \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%2l/ contains=@ALE_hover_python',
187 \], g:show_message_arg_list
188 AssertEqual {}, ale#hover#GetMap()
190 Execute(LSP hover with ale_floating_preview should float):
191 let g:ale_floating_preview = 1
193 call HandleValidLSPResult({'contents': "the message\ncontinuing"})
195 AssertEqual 1, g:floating_preview_show_called
196 AssertEqual ["the message", "continuing"], g:floated_lines
198 Execute(LSP hover ale_hover_to_floating_preview should float):
199 let g:ale_hover_to_floating_preview = 1
201 call HandleValidLSPResult({'contents': "the message\ncontinuing"})
203 AssertEqual 1, g:floating_preview_show_called
204 AssertEqual ["the message", "continuing"], g:floated_lines
207 Execute(LSP hover by default should not float):
208 call HandleValidLSPResult({'contents': "the message\ncontinuing"})
210 AssertEqual 0, g:floating_preview_show_called
212 Execute(tsserver responses for documentation requests should be handled):
213 call ale#hover#SetMap({3: {'show_documentation': 1, 'buffer': bufnr('')}})
215 call ale#hover#HandleTSServerResponse(
218 \ 'command': 'quickinfo',
222 \ 'documentation': 'foo is a very good method',
223 \ 'displayString': 'foo bar',
228 " The preview window should show the text.
229 AssertEqual ['foo is a very good method'], ale#test#GetPreviewWindowText()
232 Execute(hover with show_documentation should be in the preview window, not floating):
233 let g:ale_hover_to_floating_preview = 1
234 let g:ale_floating_preview = 1
236 call ale#hover#SetMap({3: {'show_documentation': 1, 'buffer': bufnr('')}})
238 call ale#hover#HandleTSServerResponse(
241 \ 'command': 'quickinfo',
245 \ 'documentation': 'foo is a very good method',
246 \ 'displayString': 'foo bar ',
251 let expected = ["Every statement should end with a semicolon", "second line"]
253 AssertEqual 0, g:floating_preview_show_called
255 Execute(TSServer hover without show_documentation and ale_floating_preview should float):
256 let g:ale_floating_preview = 1
258 call ale#hover#SetMap({3: {'buffer': bufnr('')}})
260 call ale#hover#HandleTSServerResponse(
263 \ 'command': 'quickinfo',
267 \ 'displayString': "the message\ncontinuing",
272 AssertEqual 1, g:floating_preview_show_called
273 AssertEqual ["the message", "continuing"], g:floated_lines