spacevim/bundle/jedi-vim/pythonx/jedi_vim_debug.py
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

97 lines
3.0 KiB
Python

"""Used in jedi-vim's jedi#debug_info()"""
import sys
import vim
from jedi_vim import PythonToVimStr, jedi
def echo(msg):
vim.command('echo %r' % PythonToVimStr(msg))
def echo_error(msg):
vim.command('echohl ErrorMsg')
echo(msg)
vim.command('echohl None')
def format_exc_info(exc_info=None, tb_indent=2):
import traceback
if exc_info is None:
exc_info = sys.exc_info()
exc_msg = traceback.format_exception_only(exc_info[0], exc_info[1])
lines = ''.join(exc_msg).rstrip('\n').split('\n')
lines.append('Traceback (most recent call last):')
tb = traceback.format_tb(exc_info[2])
lines.extend(''.join(tb).rstrip('\n').split('\n'))
indent = ' ' * tb_indent
return '{0}'.format(('\n' + indent).join(lines))
def get_known_environments():
"""Get known Jedi environments."""
envs = list(jedi.find_virtualenvs())
envs.extend(jedi.find_system_environments())
return envs
def display_debug_info():
echo(' - global sys.executable: `{0}`'.format(sys.executable))
echo(' - global sys.version: `{0}`'.format(
', '.join([x.strip()
for x in sys.version.split('\n')])))
echo(' - global site module: `{0}`'.format(__import__('site').__file__))
try:
import jedi_vim
except Exception:
echo_error('ERROR: could not import jedi_vim: {0}'.format(
format_exc_info()))
return
if jedi_vim.jedi is None:
if hasattr(jedi_vim, 'jedi_import_error'):
error_msg = format_exc_info(jedi_vim.jedi_import_error)
else:
error_msg = 'unknown error'
echo_error('ERROR: could not import the "jedi" Python module: {0}'.format(
error_msg))
else:
echo('\n##### Jedi\n\n - path: `{0}`'.format(jedi_vim.jedi.__file__))
echo(' - version: {0}'.format(jedi_vim.jedi.__version__))
try:
project = jedi_vim.get_project()
environment = project.get_environment()
except AttributeError:
script_evaluator = jedi_vim.jedi.Script('')._evaluator
try:
sys_path = script_evaluator.project.sys_path
except AttributeError:
sys_path = script_evaluator.sys_path
else:
echo('\n##### Jedi environment: {0}\n\n'.format(environment))
echo(' - executable: {0}'.format(environment.executable))
try:
sys_path = environment.get_sys_path()
except Exception:
echo_error('ERROR: failed to get sys path from environment: {0}'.format(
format_exc_info()))
return
echo(' - sys_path:')
for p in sys_path:
echo(' - `{0}`'.format(p))
if environment:
echo('\n##### Known environments\n\n')
for environment in get_known_environments():
echo(' - {0} ({1})\n'.format(
environment,
environment.executable,
))