Suggest installing gadget if possible
This commit is contained in:
parent
cd5ca37ce1
commit
375ff4aa27
2 changed files with 38 additions and 31 deletions
|
|
@ -30,7 +30,8 @@ from vimspector import ( breakpoints,
|
||||||
stack_trace,
|
stack_trace,
|
||||||
utils,
|
utils,
|
||||||
variables,
|
variables,
|
||||||
settings )
|
settings,
|
||||||
|
installer )
|
||||||
from vimspector.vendor.json_minify import minify
|
from vimspector.vendor.json_minify import minify
|
||||||
|
|
||||||
# We cache this once, and don't allow it to change (FIXME?)
|
# We cache this once, and don't allow it to change (FIXME?)
|
||||||
|
|
@ -151,6 +152,24 @@ class DebugSession( object ):
|
||||||
adapter_dict = adapters.get( adapter )
|
adapter_dict = adapters.get( adapter )
|
||||||
|
|
||||||
if adapter_dict is None:
|
if adapter_dict is None:
|
||||||
|
suggested_gadgets = installer.FindGadgetForAdapter( adapter )
|
||||||
|
if suggested_gadgets:
|
||||||
|
response = utils.AskForInput(
|
||||||
|
f"The specified adapter '{adapter}' is not "
|
||||||
|
"installed. Would you like to install the following gadgets? ",
|
||||||
|
' '.join( suggested_gadgets ) )
|
||||||
|
if response:
|
||||||
|
new_launch_variables = dict( launch_variables )
|
||||||
|
new_launch_variables[ 'configuration' ] = configuration_name
|
||||||
|
|
||||||
|
installer.RunInstaller(
|
||||||
|
self._api_prefix,
|
||||||
|
*shlex.split( response ),
|
||||||
|
then = lambda: self.Start( new_launch_variables ) )
|
||||||
|
return
|
||||||
|
elif response is None:
|
||||||
|
return
|
||||||
|
|
||||||
utils.UserMessage( f"The specified adapter '{adapter}' is not "
|
utils.UserMessage( f"The specified adapter '{adapter}' is not "
|
||||||
"available. Did you forget to run "
|
"available. Did you forget to run "
|
||||||
"'install_gadget.py'?",
|
"'install_gadget.py'?",
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from vimspector import install
|
from vimspector import install, gadgets
|
||||||
|
|
||||||
OUTPUT_VIEW = None
|
OUTPUT_VIEW = None
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ def PathToAnyWorkingPython3():
|
||||||
raise RuntimeError( "Unable to find a working python3" )
|
raise RuntimeError( "Unable to find a working python3" )
|
||||||
|
|
||||||
|
|
||||||
def RunInstaller( api_prefix, *args ):
|
def RunInstaller( api_prefix, *args, **kwargs ):
|
||||||
from vimspector import utils, output, settings
|
from vimspector import utils, output, settings
|
||||||
import vim
|
import vim
|
||||||
|
|
||||||
|
|
@ -119,6 +119,8 @@ def RunInstaller( api_prefix, *args ):
|
||||||
OUTPUT_VIEW = None
|
OUTPUT_VIEW = None
|
||||||
utils.UserMessage( "Vimspector gadget installation complete!" )
|
utils.UserMessage( "Vimspector gadget installation complete!" )
|
||||||
vim.command( 'silent doautocmd User VimspectorInstallSuccess' )
|
vim.command( 'silent doautocmd User VimspectorInstallSuccess' )
|
||||||
|
if 'then' in kwargs:
|
||||||
|
kwargs[ 'then' ]()
|
||||||
else:
|
else:
|
||||||
utils.UserMessage( 'Vimspector gadget installation reported errors',
|
utils.UserMessage( 'Vimspector gadget installation reported errors',
|
||||||
error = True )
|
error = True )
|
||||||
|
|
@ -133,7 +135,6 @@ def RunInstaller( api_prefix, *args ):
|
||||||
|
|
||||||
def GadgetListToInstallerArgs( *gadget_list ):
|
def GadgetListToInstallerArgs( *gadget_list ):
|
||||||
installer_args = []
|
installer_args = []
|
||||||
from vimspector import gadgets
|
|
||||||
for name in gadget_list:
|
for name in gadget_list:
|
||||||
if name.startswith( '-' ):
|
if name.startswith( '-' ):
|
||||||
installer_args.append( name )
|
installer_args.append( name )
|
||||||
|
|
@ -152,34 +153,21 @@ def GadgetListToInstallerArgs( *gadget_list ):
|
||||||
return installer_args
|
return installer_args
|
||||||
|
|
||||||
|
|
||||||
# def Install( languages, force ):
|
def FindGadgetForAdapter( adapter_name ):
|
||||||
# all_enabled = 'all' in languages
|
candidates = []
|
||||||
# force_all = all_enabled and force
|
for name, gadget in gadgets.GADGETS.items():
|
||||||
#
|
v = {}
|
||||||
# install.MakeInstallDirs( options.vimspector_base )
|
v.update( gadget.get( 'all', {} ) )
|
||||||
# all_adapters = ReadAdapters()
|
v.update( gadget.get( install.GetOS(), {} ) )
|
||||||
# succeeded = []
|
|
||||||
# failed = []
|
|
||||||
#
|
|
||||||
# for name, gadget in gadgets.GADGETS.items():
|
|
||||||
# if not gadget.get( 'enabled', True ):
|
|
||||||
# if ( not force_all
|
|
||||||
# and not ( force and gadget[ 'language' ] in languages ) ):
|
|
||||||
# continue
|
|
||||||
# else:
|
|
||||||
# if not all_enabled and not gadget[ 'language' ] in languages:
|
|
||||||
# continue
|
|
||||||
#
|
|
||||||
# InstallGagdet( name,
|
|
||||||
# gadget,
|
|
||||||
# succeeded,
|
|
||||||
# failed,
|
|
||||||
# all_adapters )
|
|
||||||
#
|
|
||||||
# WriteAdapters( all_adapters )
|
|
||||||
#
|
|
||||||
# return succeeded, failed
|
|
||||||
|
|
||||||
|
adapters = {}
|
||||||
|
adapters.update( v.get( 'adapters', {} ) )
|
||||||
|
adapters.update( gadget.get( 'adapters', {} ) )
|
||||||
|
|
||||||
|
if adapter_name in adapters:
|
||||||
|
candidates.append( name )
|
||||||
|
|
||||||
|
return candidates
|
||||||
|
|
||||||
|
|
||||||
def InstallGeneric( name, root, gadget ):
|
def InstallGeneric( name, root, gadget ):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue