Smart completion after "from foo": add "import" and complete

This adds a new setting `jedi#smart_auto_mappings` (default 1).
This commit is contained in:
Ali Aliyev
2015-08-17 08:09:39 +05:00
committed by Daniel Hahler
parent d3484afe20
commit ac1615c647
3 changed files with 29 additions and 1 deletions

View File

@@ -32,7 +32,8 @@ let s:default_settings = {
\ 'popup_select_first': 1,
\ 'quickfix_window_height': 10,
\ 'completions_enabled': 1,
\ 'force_py_version': "'auto'"
\ 'force_py_version': "'auto'",
\ 'smart_auto_mappings': 1
\ }
for [key, val] in items(s:deprecations)
@@ -422,6 +423,16 @@ function! jedi#complete_opened(is_popup_on_dot)
endfunction
function! jedi#smart_auto_mappings(is_popup_on_dot)
" Auto put import statement after from module.name<space> and complete
if search('\<from\s\+[A-Za-z0-9._]\+\s*\%#\s*$', 'bcn', line('.'))
" Enter character and start completion.
return "\<space>import \<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
endif
return "\<space>"
endfunction
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)