summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/test_completion_events.vader58
-rw-r--r--test/completion/test_lsp_completion_messages.vader10
-rw-r--r--test/completion/test_lsp_completion_parsing.vader31
3 files changed, 81 insertions, 18 deletions
diff --git a/test/completion/test_completion_events.vader b/test/completion/test_completion_events.vader
index 3f0bfa70..d04a8085 100644
--- a/test/completion/test_completion_events.vader
+++ b/test/completion/test_completion_events.vader
@@ -27,7 +27,7 @@ Before:
let g:get_completions_called = 0
" We just want to check if the function is called.
- function! ale#completion#GetCompletions()
+ function! ale#completion#GetCompletions(manual)
let g:get_completions_called = 1
endfunction
@@ -53,7 +53,7 @@ After:
unlet! g:fake_mode
unlet! g:get_completions_called
unlet! b:ale_old_omnifunc
- unlet! b:ale_old_completopt
+ unlet! b:ale_old_completeopt
unlet! b:ale_completion_info
unlet! b:ale_completion_response
unlet! b:ale_completion_parser
@@ -86,7 +86,7 @@ Execute(ale#completion#GetCompletions should not be called when the cursor posit
call setpos('.', [bufnr(''), 1, 2, 0])
" We just want to check if the function is called.
- function! ale#completion#GetCompletions()
+ function! ale#completion#GetCompletions(manual)
let g:get_completions_called = 1
endfunction
@@ -105,7 +105,7 @@ Execute(ale#completion#GetCompletions should not be called if you switch to norm
let g:fake_mode = 'n'
" We just want to check if the function is called.
- function! ale#completion#GetCompletions()
+ function! ale#completion#GetCompletions(manual)
let g:get_completions_called = 1
endfunction
@@ -138,7 +138,7 @@ Execute(ale#completion#Show() should remember the completeopt setting and replac
call ale#completion#Show('Response', 'Parser')
- AssertEqual 'menu', b:ale_old_completopt
+ AssertEqual 'menu', b:ale_old_completeopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
AssertEqual [], g:feedkeys_calls
@@ -150,19 +150,32 @@ Execute(ale#completion#Show() should set the preview option if it's set):
call ale#completion#Show('Response', 'Parser')
- AssertEqual 'menu,preview', b:ale_old_completopt
+ AssertEqual 'menu,preview', b:ale_old_completeopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
AssertEqual [], g:feedkeys_calls
sleep 1ms
AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
+Execute(ale#completion#Show() should not replace the completeopt setting for manual completion):
+ let b:ale_completion_info = {'manual': 1}
+
+ let &l:completeopt = 'menu,preview'
+
+ call ale#completion#Show('Response', 'Parser')
+
+ Assert !exists('b:ale_old_completeopt')
+
+ AssertEqual [], g:feedkeys_calls
+ sleep 1ms
+ AssertEqual [["\<Plug>(ale_show_completion_menu)"]], g:feedkeys_calls
+
Execute(ale#completion#OmniFunc() should also remember the completeopt setting and replace it):
let &l:completeopt = 'menu'
call ale#completion#OmniFunc(0, '')
- AssertEqual 'menu', b:ale_old_completopt
+ AssertEqual 'menu', b:ale_old_completeopt
AssertEqual 'menu,menuone,noselect,noinsert', &l:completeopt
Execute(ale#completion#OmniFunc() should set the preview option if it's set):
@@ -170,7 +183,7 @@ Execute(ale#completion#OmniFunc() should set the preview option if it's set):
call ale#completion#OmniFunc(0, '')
- AssertEqual 'menu,preview', b:ale_old_completopt
+ AssertEqual 'menu,preview', b:ale_old_completeopt
AssertEqual 'menu,menuone,preview,noselect,noinsert', &l:completeopt
Execute(ale#completion#Show() should make the correct feedkeys() call):
@@ -188,7 +201,7 @@ Execute(ale#completion#Show() shouldn't do anything if you switch back to normal
AssertEqual 'menu,preview', &l:completeopt
Assert !exists('b:ale_old_omnifunc')
- Assert !exists('b:ale_old_completopt')
+ Assert !exists('b:ale_old_completeopt')
Assert !exists('b:ale_completion_response')
Assert !exists('b:ale_completion_parser')
AssertEqual [], g:feedkeys_calls
@@ -209,12 +222,12 @@ Execute(ale#completion#Done() should restore old omnifunc values):
Assert !has_key(b:, 'ale_old_omnifunc')
Execute(ale#completion#Done() should restore the old completeopt setting):
- let b:ale_old_completopt = 'menu'
+ let b:ale_old_completeopt = 'menu'
call ale#completion#Done()
AssertEqual 'menu', &l:completeopt
- Assert !has_key(b:, 'ale_old_completopt')
+ Assert !has_key(b:, 'ale_old_completeopt')
Execute(ale#completion#Done() should leave settings alone when none were remembered):
let &l:omnifunc = 'BazBoz'
@@ -236,7 +249,23 @@ Execute(The completion request_id should be reset when queuing again):
Execute(b:ale_completion_info should be set up correctly when requesting completions):
call setpos('.', [bufnr(''), 3, 14, 0])
- call ale#completion#GetCompletions()
+ call ale#completion#GetCompletions(0)
+
+ AssertEqual
+ \ {
+ \ 'request_id': 0,
+ \ 'conn_id': 0,
+ \ 'column': 14,
+ \ 'line_length': 14,
+ \ 'line': 3,
+ \ 'prefix': 'ab',
+ \ 'manual': 0,
+ \ },
+ \ b:ale_completion_info
+
+Execute(b:ale_completion_info should be set up correctly when requesting completions):
+ call setpos('.', [bufnr(''), 3, 14, 0])
+ ALEComplete
AssertEqual
\ {
@@ -246,6 +275,7 @@ Execute(b:ale_completion_info should be set up correctly when requesting complet
\ 'line_length': 14,
\ 'line': 3,
\ 'prefix': 'ab',
+ \ 'manual': 1,
\ },
\ b:ale_completion_info
@@ -264,7 +294,7 @@ Execute(The correct keybinds should be configured):
Execute(Running the normal mode <Plug> keybind should reset the settings):
let b:ale_old_omnifunc = 'FooBar'
- let b:ale_old_completopt = 'menu'
+ let b:ale_old_completeopt = 'menu'
" We can't run the keybind, but we can call the function.
call ale#completion#RestoreCompletionOptions()
@@ -272,4 +302,4 @@ Execute(Running the normal mode <Plug> keybind should reset the settings):
AssertEqual 'FooBar', &l:omnifunc
AssertEqual 'menu', &l:completeopt
Assert !has_key(b:, 'ale_old_omnifunc')
- Assert !has_key(b:, 'ale_old_completopt')
+ Assert !has_key(b:, 'ale_old_completeopt')
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index c83ad8e1..dce61e36 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -67,7 +67,7 @@ After:
unlet! g:conn_id
unlet! g:Callback
unlet! b:ale_old_omnifunc
- unlet! b:ale_old_completopt
+ unlet! b:ale_old_completeopt
unlet! b:ale_completion_info
unlet! b:ale_completion_response
unlet! b:ale_completion_parser
@@ -102,7 +102,7 @@ Execute(The right message should be sent for the initial tsserver request):
" The cursor position needs to match what was saved before.
call setpos('.', [bufnr(''), 1, 3, 0])
- call ale#completion#GetCompletions()
+ call ale#completion#GetCompletions(0)
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)
@@ -129,6 +129,7 @@ Execute(The right message should be sent for the initial tsserver request):
\ 'request_id': 1,
\ 'line': 1,
\ 'prefix': 'fo',
+ \ 'manual': 0,
\ },
\ get(b:, 'ale_completion_info', {})
@@ -190,7 +191,7 @@ Execute(The right message should be sent for the initial LSP request):
" The cursor position needs to match what was saved before.
call setpos('.', [bufnr(''), 1, 5, 0])
- call ale#completion#GetCompletions()
+ call ale#completion#GetCompletions(0)
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)
@@ -233,6 +234,7 @@ Execute(The right message should be sent for the initial LSP request):
\ 'request_id': 1,
\ 'line': 1,
\ 'prefix': 'fo',
+ \ 'manual': 0,
\ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
\ },
\ get(b:, 'ale_completion_info', {})
@@ -258,7 +260,7 @@ Execute(Two completion requests shouldn't be sent in a row):
" The cursor position needs to match what was saved before.
call setpos('.', [bufnr(''), 1, 5, 0])
- call ale#completion#GetCompletions()
+ call ale#completion#GetCompletions(0)
" We shouldn't register the callback yet.
AssertEqual '''''', string(g:Callback)
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index 71e53ab6..a8e00260 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -471,3 +471,34 @@ Execute(Should handle documentation in the markdown format):
\ ],
\ },
\ })
+
+Execute(Should handle completion messages with textEdit objects):
+ AssertEqual
+ \ [
+ \ {'word': 'next_callback', 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1},
+ \ ],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'id': 226,
+ \ 'jsonrpc': '2.0',
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'detail': 'PlayTimeCallback',
+ \ 'filterText': 'next_callback',
+ \ 'insertText': 'next_callback',
+ \ 'insertTextFormat': 1,
+ \ 'kind': 6,
+ \ 'label': ' next_callback',
+ \ 'sortText': '3ee19999next_callback',
+ \ 'textEdit': {
+ \ 'newText': 'next_callback',
+ \ 'range': {
+ \ 'end': {'character': 13, 'line': 12},
+ \ 'start': {'character': 4, 'line': 12},
+ \ },
+ \ },
+ \ },
+ \ ],
+ \ },
+ \ })