autocomplete function simplified, #136

This commit is contained in:
David Halter
2013-08-28 15:42:02 +04:30
parent 111cca5106
commit 3ce655f428
2 changed files with 27 additions and 6 deletions

View File

@@ -169,6 +169,24 @@ function! jedi#_vim_exceptions(str, is_eval)
return l:result return l:result
endfunction endfunction
function! jedi#auto_complete_string()
if pumvisible()
return "\<C-n>"
else
return "\<C-x>\<C-o>\<C-r>=jedi#auto_complete_opened()\<CR>"
end
endfunction
function! jedi#auto_complete_opened()
if pumvisible()
return "\<Down>"
end
return ""
endfunction
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------
" deprecations " deprecations
" ------------------------------------------------------------------------ " ------------------------------------------------------------------------

View File

@@ -14,11 +14,14 @@ if g:jedi#auto_initialization
" map ctrl+space for autocompletion " map ctrl+space for autocompletion
if g:jedi#completions_command == "<C-Space>" if g:jedi#completions_command == "<C-Space>"
" in terminals, <C-Space> sometimes equals <Nul> " in terminals, <C-Space> sometimes equals <Nul>
inoremap <expr> <Nul> pumvisible() \|\| &omnifunc == '' ? "
\ "\<lt>C-n>" : "if g:jedi#popup_select_first
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" . "inoremap <expr> <Nul> pumvisible() ?
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" . " \ "<C-n>" :
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>" " \ "<C-x><C-o><c-r>=pumvisible() ?" .
" \ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
" \ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
inoremap <expr> <Nul> jedi#auto_complete_string()
endif endif
if g:jedi#completions_command != "" if g:jedi#completions_command != ""
execute "inoremap <buffer>".g:jedi#completions_command." <C-X><C-O>" execute "inoremap <buffer>".g:jedi#completions_command." <C-X><C-O>"
@@ -59,7 +62,7 @@ end
if g:jedi#popup_on_dot if g:jedi#popup_on_dot
if stridx(&completeopt, 'longest') > -1 if stridx(&completeopt, 'longest') > -1
if g:jedi#popup_select_first if g:jedi#popup_select_first
inoremap <silent> <buffer> . .<C-R>=jedi#do_popup_on_dot() ? "\<lt>C-X>\<lt>C-O>\<lt>C-N>" : ""<CR> inoremap <silent> <buffer> . .<C-R>=jedi#do_popup_on_dot() ? "\<lt>C-X>\<lt>C-O>\<lt>Down>" : ""<CR>
else else
inoremap <silent> <buffer> . .<C-R>=jedi#do_popup_on_dot() ? "\<lt>C-X>\<lt>C-O>" : ""<CR> inoremap <silent> <buffer> . .<C-R>=jedi#do_popup_on_dot() ? "\<lt>C-X>\<lt>C-O>" : ""<CR>
end end