| 1 |
let g:jedi#completions_command = 'X' |
| 2 |
source plugin/jedi.vim |
| 3 |
|
| 4 |
describe 'completions' |
| 5 |
before |
| 6 |
new |
| 7 |
set filetype=python |
| 8 |
end |
| 9 |
|
| 10 |
after |
| 11 |
" default |
| 12 |
let g:jedi#popup_select_first = 1 |
| 13 |
bd! |
| 14 |
end |
| 15 |
|
| 16 |
it 'longest in completeopt' |
| 17 |
" This gets set up with Vim only on VimEnter. |
| 18 |
if has('nvim') |
| 19 |
Expect stridx(&completeopt, 'longest') > -1 |
| 20 |
else |
| 21 |
Expect stridx(&completeopt, 'longest') == -1 |
| 22 |
doautocmd VimEnter |
| 23 |
Expect stridx(&completeopt, 'longest') > -1 |
| 24 |
endif |
| 25 |
|
| 26 |
" Do not use it for following tests. |
| 27 |
set completeopt-=longest |
| 28 |
end |
| 29 |
|
| 30 |
it 'no smart import by default' |
| 31 |
exec "normal ifrom os " |
| 32 |
Expect getline('.') == 'from os ' |
| 33 |
end |
| 34 |
|
| 35 |
it 'import' |
| 36 |
" X is the completion command |
| 37 |
normal oimporX |
| 38 |
Expect getline('.') == 'import' |
| 39 |
normal a subproX |
| 40 |
Expect getline('.') == 'import subprocess' |
| 41 |
end |
| 42 |
|
| 43 |
it 'exception' |
| 44 |
normal oIndentationErrX |
| 45 |
Expect getline('.') == 'IndentationError' |
| 46 |
|
| 47 |
" Do not remap keys (".") here, otherwise this triggers completion in |
| 48 |
" Neovim already. |
| 49 |
normal! a().filena |
| 50 |
|
| 51 |
normal aX |
| 52 |
Expect getline('.') == 'IndentationError().filename' |
| 53 |
end |
| 54 |
|
| 55 |
it 'multi complete' |
| 56 |
" NOTE: nvim results in "importErr()" here with completeopt+=longest, |
| 57 |
" but Vim is fine. |
| 58 |
" This is due to `pumvisible()` in jedi#complete_opened being true |
| 59 |
" with nvim still, but it is 0 with Vim, i.e. Vim appears to close |
| 60 |
" the pum already (with the tests). |
| 61 |
" |
| 62 |
" This might be a misunderstanding though, since the test might not |
| 63 |
" expect the "import" keyword to be offered for completion?! |
| 64 |
normal oImpXErrX() |
| 65 |
Expect getline('.') == 'ImportError()' |
| 66 |
end |
| 67 |
|
| 68 |
it 'cycling through entries popup_select_first=0' |
| 69 |
set completeopt+=longest |
| 70 |
let g:jedi#popup_select_first = 0 |
| 71 |
execute "normal oraise impX\<C-n>" |
| 72 |
|
| 73 |
Expect getline('.') == 'raise ImportError' |
| 74 |
set completeopt-=longest |
| 75 |
end |
| 76 |
|
| 77 |
it 'cycling through entries popup_select_first=1' |
| 78 |
execute "normal oraise impX\<C-n>" |
| 79 |
Expect getline('.') == 'raise ImportWarning' |
| 80 |
end |
| 81 |
|
| 82 |
it 'cycling through entries popup_select_first=1 and longest' |
| 83 |
set completeopt+=longest |
| 84 |
execute "normal oraise impX" |
| 85 |
Expect getline('.') == 'raise Import' |
| 86 |
|
| 87 |
" With Neovim pumvisible() is 1 in jedi#complete_opened, which then |
| 88 |
" triggers the <Down>. This is not the case with Vim. |
| 89 |
if has('nvim') |
| 90 |
execute "normal oraise impX\<C-n>" |
| 91 |
Expect getline('.') == 'raise ImportWarning' |
| 92 |
|
| 93 |
execute "normal oraise impX\<C-n>\<C-n>" |
| 94 |
Expect getline('.') == 'raise imp' |
| 95 |
else |
| 96 |
execute "normal oraise impX\<C-n>" |
| 97 |
Expect getline('.') == 'raise ImportError' |
| 98 |
|
| 99 |
execute "normal oraise impX\<C-n>\<C-n>" |
| 100 |
Expect getline('.') == 'raise ImportWarning' |
| 101 |
endif |
| 102 |
set completeopt-=longest |
| 103 |
end |
| 104 |
end |
| 105 |
|
| 106 |
describe 'smart completions' |
| 107 |
before |
| 108 |
new |
| 109 |
let g:jedi#smart_auto_mappings = 1 |
| 110 |
set filetype=python |
| 111 |
end |
| 112 |
|
| 113 |
after |
| 114 |
" default |
| 115 |
let g:jedi#smart_auto_mappings = 0 |
| 116 |
bd! |
| 117 |
end |
| 118 |
|
| 119 |
it 'smart import' |
| 120 |
exec "normal ifrom os " |
| 121 |
Expect getline('.') == 'from os import ' |
| 122 |
end |
| 123 |
|
| 124 |
it 'no smart import after space' |
| 125 |
exec "normal! ifrom os " |
| 126 |
exec "normal a " |
| 127 |
Expect getline('.') == 'from os ' |
| 128 |
end |
| 129 |
end |
| 130 |
|
| 131 |
" vim: et:ts=4:sw=4 |