def RunInstaller( api_prefix, leave_open, *args, **kwargs ): from vimspector import utils, output, settings import vim if not args: args = settings.List( 'install_gadgets' ) if not args: return args = GadgetListToInstallerArgs( *args ) vimspector_home = utils.GetVimValue( vim.vars, 'vimspector_home' ) vimspector_base_dir = utils.GetVimspectorBase() global OUTPUT_VIEW _ResetInstaller() with utils.RestoreCurrentWindow(): vim.command( f'botright { settings.Int( "bottombar_height" ) }new' ) win = vim.current.window OUTPUT_VIEW = output.OutputView( win, api_prefix ) cmd = [ PathToAnyWorkingPython3(), '-u', os.path.join( vimspector_home, 'install_gadget.py' ), '--quiet', '--update-gadget-config', ] if not vimspector_base_dir == vimspector_home: cmd.extend( [ '--basedir', vimspector_base_dir ] ) cmd.extend( args ) def handler( exit_code ): if exit_code == 0: if not leave_open: _ResetInstaller() utils.UserMessage( "Vimspector gadget installation complete!" ) vim.command( 'silent doautocmd User VimspectorInstallSuccess' ) if 'then' in kwargs: kwargs[ 'then' ]() else: utils.UserMessage( 'Vimspector gadget installation reported errors', error = True ) vim.command( 'silent doautocmd User VimspectorInstallFailed' ) OUTPUT_VIEW.RunJobWithOutput( 'Installer', cmd, completion_handler = handler, syntax = 'vimspector-installer' ) OUTPUT_VIEW.ShowOutput( 'Installer' )
def RunUpdate(api_prefix, leave_open, *args): from vimspector import utils, settings Configure(vimspector_base=utils.GetVimspectorBase()) insatller_args = list(args) insatller_args.extend(settings.List('install_gadgets')) current_adapters = ReadAdapters(read_existing=True) for adapter_name in current_adapters.keys(): insatller_args.extend(FindGadgetForAdapter(adapter_name)) if insatller_args: RunInstaller(api_prefix, leave_open, *insatller_args)
def SetUpDebugpy(wait=False, port=5678): sys.path.insert( 1, os.path.join(install.GetGadgetDir(utils.GetVimspectorBase()), 'debugpy', 'build', 'lib')) import debugpy exe = sys.executable try: # debugpy uses sys.executable (which is `vim`, so we hack it) sys.executable = installer.PathToAnyWorkingPython3() debugpy.listen(port) finally: sys.executable = exe if wait: debugpy.wait_for_client()
import glob import json import logging import os import shlex import subprocess import functools import vim from vimspector import (breakpoints, code, debug_adapter_connection, install, output, stack_trace, utils, variables, settings, terminal, installer) from vimspector.vendor.json_minify import minify # We cache this once, and don't allow it to change (FIXME?) VIMSPECTOR_HOME = utils.GetVimspectorBase() # cache of what the user entered for any option we ask them USER_CHOICES = {} class DebugSession(object): def __init__(self, api_prefix): self._logger = logging.getLogger(__name__) utils.SetUpLogging(self._logger) self._api_prefix = api_prefix self._logger.info("**** INITIALISING NEW VIMSPECTOR SESSION ****") self._logger.info("API is: {}".format(api_prefix)) self._logger.info('VIMSPECTOR_HOME = %s', VIMSPECTOR_HOME)