Files
2020-04-19 10:14:38 -07:00

95 lines
2.8 KiB
Plaintext

Describe lsp#omni
Before each
call lsp#omni#_clear_managed_user_data_map()
End
Describe lsp#omni#get_vim_completion_item
It should return item with proper kind
let item = {
\ 'label': 'my-label',
\ 'documentation': 'my documentation.',
\ 'detail': 'my-detail',
\ 'kind': '3'
\}
let want = {
\ 'word': 'my-label',
\ 'abbr': 'my-label',
\ 'info': 'my documentation.',
\ 'icase': 1,
\ 'dup': 1,
\ 'empty': 1,
\ 'kind': 'function',
\ 'menu': 'my-detail',
\ 'user_data': '{"vim-lsp/key":"0"}'
\}
Assert Equals(lsp#omni#get_vim_completion_item(item), want)
End
It should get user_data by the item
if !has('patch-8.0.1493')
Skip This test requires 'patch-8.0.1493'
endif
let item = {
\ 'label': 'my-label',
\ 'documentation': 'my documentation.',
\ 'detail': 'my-detail',
\ 'kind': '3',
\ 'textEdit': {
\ 'range': {
\ 'start': {'line': 5, 'character': 0},
\ 'end': {'line': 5, 'character': 5}
\ },
\ 'newText': 'yyy'
\ }
\}
let want = {
\ 'word': 'my-label',
\ 'abbr': 'my-label~',
\ 'info': 'my documentation.',
\ 'icase': 1,
\ 'dup': 1,
\ 'empty': 1,
\ 'kind': 'function',
\ 'menu': 'my-detail',
\ 'user_data': '{"vim-lsp/key":"0"}'
\}
let got = lsp#omni#get_vim_completion_item(item, '', { 'line': 1, 'character': 1 })
Assert Equals(got, want)
Assert Equals(lsp#omni#get_managed_user_data_from_completed_item(got), {
\ 'server_name': '',
\ 'completion_item': item,
\ 'complete_position': { 'line': 1, 'character': 1 }
\ })
End
It should return item with newlines in 'menu' replaced
let item = {
\ 'label': 'my-label',
\ 'documentation': 'my documentation.',
\ 'detail': "my-detail\nmore-detail",
\ 'kind': '3'
\}
let want = {
\ 'word': 'my-label',
\ 'abbr': 'my-label',
\ 'info': 'my documentation.',
\ 'icase': 1,
\ 'dup': 1,
\ 'empty': 1,
\ 'kind': 'function',
\ 'menu': 'my-detail more-detail',
\ 'user_data': '{"vim-lsp/key":"0"}'
\}
Assert Equals(lsp#omni#get_vim_completion_item(item), want)
End
End
End