diff --git a/autoload/jedi.vim b/autoload/jedi.vim index 2786e2e..82184b6 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -428,6 +428,10 @@ function! jedi#choose_environment(args) abort PythonJedi jedi_vim.choose_environment() endfun +function! jedi#load_project(args) abort + PythonJedi jedi_vim.load_project() +endfun + function! jedi#py_import_completions(argl, cmdl, pos) abort PythonJedi jedi_vim.py_import_completions() endfun diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 245548a..d409240 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -54,6 +54,7 @@ endif command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import() command! -nargs=? -complete=file JediChooseEnvironment :call jedi#choose_environment() +command! -nargs=? -complete=file JediLoadProject :call jedi#load_project() function! s:jedi_debug_info() diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 42d3828..b215f8a 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -240,6 +240,7 @@ def get_project(): return project +@catch_and_print_exceptions def choose_environment(): args = shsplit(vim.eval('a:args')) @@ -257,11 +258,35 @@ def choose_environment(): vim_command('noremap :PythonJedi jedi_vim.choose_environment_hit_enter()') +@catch_and_print_exceptions def choose_environment_hit_enter(): vim.vars['jedi#environment_path'] = vim.current.line vim_command('bd') +@catch_and_print_exceptions +def load_project(): + path = vim.eval('a:args') + vim.vars['jedi#project_path'] = path + env_path = vim_eval("g:jedi#environment_path") + if env_path == 'auto': + env_path = None + if path: + try: + project = jedi.Project.load(path) + except FileNotFoundError: + project = jedi.Project(path, environment_path=env_path) + project.save() + else: + project = jedi.get_default_project() + path = project.path + project.save() + + global _current_project_cache + cache_key = dict(project_path=path, environment_path=env_path) + _current_project_cache = cache_key, project + + @catch_and_print_exceptions def get_script(source=None): jedi.settings.additional_dynamic_modules = [