| 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 |
|
| 12 |
let g:jedi#popup_select_first = 1 |
| 13 |
bd! |
| 14 |
end |
| 15 |
|
| 16 |
it 'longest in completeopt' |
| 17 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 48 |
|
| 49 |
normal! a().filena |
| 50 |
|
| 51 |
normal aX |
| 52 |
Expect getline('.') == 'IndentationError().filename' |
| 53 |
end |
| 54 |
|
| 55 |
it 'cycling through entries popup_select_first=0' |
| 56 |
set completeopt+=longest |
| 57 |
let g:jedi#popup_select_first = 0 |
| 58 |
execute "normal oraise impX\<C-n>" |
| 59 |
|
| 60 |
Expect getline('.') == 'raise ImportError' |
| 61 |
set completeopt-=longest |
| 62 |
end |
| 63 |
|
| 64 |
it 'cycling through entries popup_select_first=1' |
| 65 |
execute "normal oraise impX\<C-n>" |
| 66 |
Expect getline('.') == 'raise ImportWarning' |
| 67 |
end |
| 68 |
|
| 69 |
it 'cycling through entries popup_select_first=1 and longest' |
| 70 |
set completeopt+=longest |
| 71 |
execute "normal oraise impX" |
| 72 |
Expect getline('.') == 'raise Import' |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
if has('nvim') |
| 77 |
execute "normal oraise impX\<C-n>" |
| 78 |
Expect getline('.') == 'raise ImportWarning' |
| 79 |
|
| 80 |
execute "normal oraise impX\<C-n>\<C-n>" |
| 81 |
Expect getline('.') == 'raise imp' |
| 82 |
else |
| 83 |
execute "normal oraise impX\<C-n>" |
| 84 |
Expect getline('.') == 'raise ImportError' |
| 85 |
|
| 86 |
execute "normal oraise impX\<C-n>\<C-n>" |
| 87 |
Expect getline('.') == 'raise ImportWarning' |
| 88 |
endif |
| 89 |
set completeopt-=longest |
| 90 |
end |
| 91 |
end |
| 92 |
|
| 93 |
describe 'smart completions' |
| 94 |
before |
| 95 |
new |
| 96 |
let g:jedi#smart_auto_mappings = 1 |
| 97 |
set filetype=python |
| 98 |
end |
| 99 |
|
| 100 |
after |
| 101 |
|
| 102 |
let g:jedi#smart_auto_mappings = 0 |
| 103 |
bd! |
| 104 |
end |
| 105 |
|
| 106 |
it 'smart import' |
| 107 |
exec "normal ifrom os " |
| 108 |
Expect getline('.') == 'from os import ' |
| 109 |
end |
| 110 |
|
| 111 |
it 'no smart import after space' |
| 112 |
exec "normal! ifrom os " |
| 113 |
exec "normal a " |
| 114 |
Expect getline('.') == 'from os ' |
| 115 |
end |
| 116 |
end |
| 117 |
|
| 118 |
|