get_project: simplify getting b:jedi_environment_path override

- the common case is having an exception here (with no buffer setting),
  which results in the exception handler always
- vim_eval has overhead, especially with Neovim, so the less calls the
  better

This patch changes it to query the `b:` dict, using the (always
set/initialized) global setting as the default.
This commit is contained in:
Daniel Hahler
2022-01-17 14:56:29 +01:00
parent e1afc904e4
commit 7d2fc14f4f

View File

@@ -218,13 +218,9 @@ _current_project_cache = None, None
def get_project():
try:
vim_environment_path = vim_eval("b:jedi_environment_path")
except VimError:
vim_environment_path = ""
if vim_environment_path in ("", None):
vim_environment_path = vim_eval("g:jedi#environment_path")
vim_environment_path = vim_eval(
"get(b:, 'jedi_environment_path', g:jedi#environment_path)"
)
vim_project_path = vim_eval("g:jedi#project_path")
vim_added_sys_path = vim_eval("g:jedi#added_sys_path")