Improve JediDebugInfo for envs (#858)

Improve JediDebugInfo for envs

This is taken out of https://github.com/davidhalter/jedi-vim/pull/836.
This commit is contained in:
Daniel Hahler
2018-07-28 01:46:12 +02:00
committed by Dave Halter
parent 40fc5ab27f
commit 4c430ed536
3 changed files with 32 additions and 9 deletions

View File

@@ -170,7 +170,19 @@ function! jedi#debug_info() abort
endif endif
endif endif
echo '#### Jedi-vim debug information' echo '#### Jedi-vim debug information'
echo 'Using Python version:' s:python_version echo "\n"
echo '##### jedi-vim version'
echo "\n"
echo ' - jedi-vim git version: '
echon substitute(system('git -C '.s:script_path.' describe --tags --always --dirty'), '\v\n$', '', '')
echo ' - jedi git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/jedi'), '\v\n$', '', '')
echo ' - parso git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/parso'), '\v\n$', '', '')
echo "\n"
echo '##### Global Python'
echo "\n"
echo 'Using Python version '.s:python_version.' to access Jedi.'
let pyeval = s:python_version == 3 ? 'py3eval' : 'pyeval' let pyeval = s:python_version == 3 ? 'py3eval' : 'pyeval'
let s:pythonjedi_called = 0 let s:pythonjedi_called = 0
PythonJedi import vim; vim.command('let s:pythonjedi_called = 1') PythonJedi import vim; vim.command('let s:pythonjedi_called = 1')
@@ -185,14 +197,9 @@ function! jedi#debug_info() abort
PythonJedi from jedi_vim_debug import display_debug_info PythonJedi from jedi_vim_debug import display_debug_info
PythonJedi display_debug_info() PythonJedi display_debug_info()
endif endif
echo ' - jedi-vim git version: '
echon substitute(system('git -C '.s:script_path.' describe --tags --always --dirty'), '\v\n$', '', '')
echo ' - jedi git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/jedi'), '\v\n$', '', '')
echo ' - parso git submodule status: '
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/parso'), '\v\n$', '', '')
echo "\n" echo "\n"
echo '##### Settings' echo '##### Settings'
echo "\n"
echo '```' echo '```'
let jedi_settings = items(filter(copy(g:), "v:key =~# '\\v^jedi#'")) let jedi_settings = items(filter(copy(g:), "v:key =~# '\\v^jedi#'"))
let has_nondefault_settings = 0 let has_nondefault_settings = 0

View File

@@ -193,6 +193,13 @@ def get_environment(use_cache=True):
return environment return environment
def get_known_environments():
"""Get known Jedi environments."""
envs = list(jedi.api.environment.find_virtualenvs())
envs.extend(jedi.api.environment.find_system_environments())
return envs
@catch_and_print_exceptions @catch_and_print_exceptions
def get_script(source=None, column=None): def get_script(source=None, column=None):
jedi.settings.additional_dynamic_modules = [ jedi.settings.additional_dynamic_modules = [

View File

@@ -53,7 +53,7 @@ def display_debug_info():
echo_error('ERROR: could not import the "jedi" Python module: {0}'.format( echo_error('ERROR: could not import the "jedi" Python module: {0}'.format(
error_msg)) error_msg))
else: else:
echo('Jedi path: `{0}`'.format(jedi_vim.jedi.__file__)) echo('\n##### Jedi\n\n - path: `{0}`'.format(jedi_vim.jedi.__file__))
echo(' - version: {0}'.format(jedi_vim.jedi.__version__)) echo(' - version: {0}'.format(jedi_vim.jedi.__version__))
try: try:
@@ -65,7 +65,8 @@ def display_debug_info():
except AttributeError: except AttributeError:
sys_path = script_evaluator.sys_path sys_path = script_evaluator.sys_path
else: else:
echo(' - environment: `{0}`'.format(environment)) echo('\n##### Jedi environment: {0}\n\n'.format(environment))
echo(' - executable: {0}'.format(environment.executable))
try: try:
sys_path = environment.get_sys_path() sys_path = environment.get_sys_path()
except Exception: except Exception:
@@ -76,3 +77,11 @@ def display_debug_info():
echo(' - sys_path:') echo(' - sys_path:')
for p in sys_path: for p in sys_path:
echo(' - `{0}`'.format(p)) echo(' - `{0}`'.format(p))
if environment:
echo('\n##### Known environments\n\n')
for environment in jedi_vim.get_known_environments():
echo(' - {0} ({1})\n'.format(
environment,
environment.executable,
))