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.
3 let g:lsp_get_vim_completion_item_set_kind = 1
6 call lsp#omni#_clear_managed_user_data_map()
9 Describe lsp#omni#get_vim_completion_items
10 It should return item with proper kind
12 \ 'label': 'my-label',
13 \ 'documentation': 'my documentation.',
14 \ 'detail': 'my-detail',
19 \ 'server': { 'name': 'dummy-server' },
20 \ 'position': lsp#get_position(),
21 \ 'response': { 'result': [item] },
32 \ 'user_data': '{"vim-lsp/key":"0"}',
35 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
38 Assert Equals(lsp#omni#get_vim_completion_items(options), want)
41 It should get user_data by the item
42 if !has('patch-8.0.1493')
43 Skip This test requires 'patch-8.0.1493'
47 \ 'label': 'my-label',
48 \ 'documentation': 'my documentation.',
49 \ 'detail': 'my-detail',
53 \ 'start': {'line': 5, 'character': 0},
54 \ 'end': {'line': 5, 'character': 5}
61 \ 'server': { 'name': 'dummy-server' },
62 \ 'position': { 'line': 1, 'character': 1 },
63 \ 'response': { 'result': [item] },
74 \ 'user_data': '{"vim-lsp/key":"0"}',
77 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', {'line': 1, 'character': 0}),
80 let got = lsp#omni#get_vim_completion_items(options)
81 Assert Equals(got, want)
82 Assert Equals(lsp#omni#get_managed_user_data_from_completed_item(got['items'][0]), {
83 \ 'server_name': 'dummy-server',
84 \ 'completion_item': item,
85 \ 'complete_position': { 'line': 1, 'character': 1 },
86 \ 'start_character': 0,
87 \ 'complete_word': 'yyy',
91 It should not raise errors
93 \ 'label': 'my-label',
98 \ 'server': { 'name': 'dummy-server' },
99 \ 'position': lsp#get_position(),
100 \ 'response': { 'result': [item] },
105 \ 'word': 'my-label',
106 \ 'abbr': 'my-label',
111 \ 'user_data': '{"vim-lsp/key":"0"}',
114 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
117 let got = lsp#omni#get_vim_completion_items(options)
118 Assert Equals(got, want)
121 \ 'label': 'my-label',
122 \ 'textEdit': v:null,
123 \ 'insertText': v:null,
127 \ 'server': { 'name': 'dummy-server' },
128 \ 'position': lsp#get_position(),
129 \ 'response': { 'result': [item] },
134 \ 'word': 'my-label',
135 \ 'abbr': 'my-label',
140 \ 'user_data': '{"vim-lsp/key":"1"}',
143 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
146 let got = lsp#omni#get_vim_completion_items(options)
147 Assert Equals(got, want)
150 It should return correct items for snippets
151 if !has('patch-8.0.1493')
152 Skip This test requires 'patch-8.0.1493'
157 \ "insertText": "System.out.println(${0});",
159 \ "insertTextFormat": 2,
160 \ "documentation": "System.out.println();",
161 \ "detail": "print to standard out"
165 \ 'server': { 'name': 'dummy-server' },
166 \ 'position': { 'line': 1, 'character': 1 },
167 \ 'response': { 'result': [item] },
172 \ 'word': 'System.out.println',
178 \ 'user_data': '{"vim-lsp/key":"0"}',
181 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', { 'line': 1, 'character': 1 }),
184 let got = lsp#omni#get_vim_completion_items(options)
185 Assert Equals(got, want)
186 Assert Equals(lsp#omni#get_managed_user_data_from_completed_item(got['items'][0]), {
187 \ 'server_name': 'dummy-server',
188 \ 'completion_item': item,
189 \ 'complete_position': { 'line': 1, 'character': 1 },
190 \ 'start_character': 0,
191 \ 'complete_word': 'System.out.println(${0});',
195 It should sort by sortText
197 \ 'label': 'my-label1',
202 \ 'label': 'my-label2',
207 \ 'label': 'my-label3',
214 \ 'name': 'dummy-server',
216 \ 'sort': { 'max': 100 },
219 \ 'position': lsp#get_position(),
220 \ 'response': { 'result': items },
225 \ 'word': 'my-label2',
226 \ 'abbr': 'my-label2',
230 \ 'kind': 'function',
231 \ 'user_data': '{"vim-lsp/key":"0"}',
234 \ 'word': 'my-label3',
235 \ 'abbr': 'my-label3',
239 \ 'kind': 'function',
240 \ 'user_data': '{"vim-lsp/key":"1"}',
243 \ 'word': 'my-label1',
244 \ 'abbr': 'my-label1',
248 \ 'kind': 'function',
249 \ 'user_data': '{"vim-lsp/key":"2"}',
252 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
255 Assert Equals(lsp#omni#get_vim_completion_items(options), want)
258 It should not sort over max
260 \ 'label': 'my-label3',
265 \ 'label': 'my-label1',
270 \ 'label': 'my-label2',
277 \ 'name': 'dummy-server',
279 \ 'sort': { 'max': 2 },
282 \ 'position': lsp#get_position(),
283 \ 'response': { 'result': items },
288 \ 'word': 'my-label3',
289 \ 'abbr': 'my-label3',
293 \ 'kind': 'function',
294 \ 'user_data': '{"vim-lsp/key":"0"}',
297 \ 'word': 'my-label1',
298 \ 'abbr': 'my-label1',
302 \ 'kind': 'function',
303 \ 'user_data': '{"vim-lsp/key":"1"}',
306 \ 'word': 'my-label2',
307 \ 'abbr': 'my-label2',
311 \ 'kind': 'function',
312 \ 'user_data': '{"vim-lsp/key":"2"}',
315 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
317 Assert Equals(lsp#omni#get_vim_completion_items(options), want)
320 It should sort by label(sortText not exists)
322 \ 'label': 'my-label3',
326 \ 'label': 'my-label1',
330 \ 'label': 'my-label2',
336 \ 'name': 'dummy-server',
338 \ 'sort': { 'max': 10 },
341 \ 'position': lsp#get_position(),
342 \ 'response': { 'result': items },
347 \ 'word': 'my-label1',
348 \ 'abbr': 'my-label1',
352 \ 'kind': 'function',
353 \ 'user_data': '{"vim-lsp/key":"0"}',
356 \ 'word': 'my-label2',
357 \ 'abbr': 'my-label2',
361 \ 'kind': 'function',
362 \ 'user_data': '{"vim-lsp/key":"1"}',
365 \ 'word': 'my-label3',
366 \ 'abbr': 'my-label3',
370 \ 'kind': 'function',
371 \ 'user_data': '{"vim-lsp/key":"2"}',
374 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
376 Assert Equals(lsp#omni#get_vim_completion_items(options), want)
379 It should sort by label(empty sortText)
381 \ 'label': 'my-label3',
386 \ 'label': 'my-label1',
391 \ 'label': 'my-label2',
398 \ 'name': 'dummy-server',
400 \ 'sort': { 'max': 10 },
403 \ 'position': lsp#get_position(),
404 \ 'response': { 'result': items },
409 \ 'word': 'my-label1',
410 \ 'abbr': 'my-label1',
414 \ 'kind': 'function',
415 \ 'user_data': '{"vim-lsp/key":"0"}',
418 \ 'word': 'my-label2',
419 \ 'abbr': 'my-label2',
423 \ 'kind': 'function',
424 \ 'user_data': '{"vim-lsp/key":"1"}',
427 \ 'word': 'my-label3',
428 \ 'abbr': 'my-label3',
432 \ 'kind': 'function',
433 \ 'user_data': '{"vim-lsp/key":"2"}',
436 \ 'startcol': lsp#utils#position#lsp_character_to_vim('%', lsp#get_position()),
438 Assert Equals(lsp#omni#get_vim_completion_items(options), want)
441 Describe g:lsp_ignorecase
443 let saved_ignorecase = get(g:, 'lsp_ignorecase', v:null)
447 if saved_ignorecase isnot v:null
448 let g:lsp_ignorecase = saved_ignorecase
452 It should sort completion items case-insensitive when true is set
453 let g:lsp_ignorecase = v:true
455 " 'B' < 'a' but 'a' < 'b'
457 \ 'label': 'my-label1',
462 \ 'label': 'my-label2',
469 \ 'name': 'dummy-server',
471 \ 'sort': { 'max': 10 },
474 \ 'position': lsp#get_position(),
475 \ 'response': { 'result': result },
479 \ 'word': 'my-label2',
480 \ 'abbr': 'my-label2',
484 \ 'kind': 'function',
485 \ 'user_data': '{"vim-lsp/key":"0"}',
488 \ 'word': 'my-label1',
489 \ 'abbr': 'my-label1',
493 \ 'kind': 'function',
494 \ 'user_data': '{"vim-lsp/key":"1"}',
497 Assert Equals(lsp#omni#get_vim_completion_items(options).items, want)