diff --git a/README.mdown b/README.mdown index 8fe7b711..45394542 100644 --- a/README.mdown +++ b/README.mdown @@ -170,3 +170,7 @@ put that in your `.vimrc`: let g:jedi#use_tabs_not_buffers = 1 +Jedi automatically starts the completion, if you type a dot, e.g. `str.`, if +you don't want this: + + let g:jedi#popup_on_dot = 0 diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 83781484..0b0f722d 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -174,6 +174,26 @@ function! jedi#goto_window_on_enter() echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None endif endfunction + +function! jedi#syn_stack() + if !exists("*synstack") + return [] + endif + return map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")') +endfunc + +function! jedi#do_popup_on_dot() + let highlight_groups = jedi#syn_stack() + for a in highlight_groups + for b in ['pythonString', 'pythonComment'] + if a == b + return 0 + endif + endfor + endfor + return 1 +endfunc + " ------------------------------------------------------------------------ " Initialization of jedi-vim " ------------------------------------------------------------------------ @@ -188,6 +208,9 @@ endif if !exists("g:jedi#goto_command") let g:jedi#goto_command = "g" endif +if !exists("g:jedi#popup_on_dot") + let g:jedi#popup_on_dot = 1 +endif if g:jedi#auto_initialization autocmd FileType python set omnifunc=jedi#complete @@ -197,6 +220,10 @@ if g:jedi#auto_initialization execute "map ".g:jedi#goto_command." :call jedi#goto()" end +if g:jedi#popup_on_dot + autocmd FileType python imap . .=jedi#do_popup_on_dot() ? "\C-X>\C-O>" : "" +end + let s:current_file=expand("") python << PYTHONEOF diff --git a/settings.py b/settings.py index c8b25095..685e9438 100644 --- a/settings.py +++ b/settings.py @@ -6,8 +6,9 @@ case_insensitive_completion = True # Adds a dot after a module, because a module that is not accessed this way is -# definitely not the normal case. -add_dot_after_module = True +# definitely not the normal case. However, in VIM this doesn't work, that's why +# it isn't used at the moment. +add_dot_after_module = False # Adds an opening bracket after a function, because that's normal behaviour. add_bracket_after_function = True