Allow a statically configured list of gadgets
Useful for storing config in source control
This commit is contained in:
parent
5fbc70165d
commit
8f5b928e4b
5 changed files with 57 additions and 18 deletions
|
|
@ -99,9 +99,15 @@ 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.GetVimString( vim.vars, 'vimspector_home' )
|
||||
vimspector_home = utils.GetVimValue( vim.vars, 'vimspector_home' )
|
||||
vimspector_base_dir = utils.GetVimspectorBase()
|
||||
|
||||
global OUTPUT_VIEW
|
||||
|
|
@ -145,16 +151,18 @@ def RunInstaller( api_prefix, leave_open, *args, **kwargs ):
|
|||
|
||||
|
||||
def RunUpdate( api_prefix, leave_open, *args ):
|
||||
from vimspector import utils
|
||||
from vimspector import utils, settings
|
||||
Configure( vimspector_base = utils.GetVimspectorBase() )
|
||||
|
||||
args = list( args )
|
||||
insatller_args = list( args )
|
||||
insatller_args.extend( settings.List( 'install_gadgets' ) )
|
||||
|
||||
current_adapters = ReadAdapters( read_existing = True )
|
||||
for adapter_name in current_adapters.keys():
|
||||
args.extend( FindGadgetForAdapter( adapter_name ) )
|
||||
insatller_args.extend( FindGadgetForAdapter( adapter_name ) )
|
||||
|
||||
if args:
|
||||
RunInstaller( api_prefix, leave_open, *args )
|
||||
if insatller_args:
|
||||
RunInstaller( api_prefix, leave_open, *insatller_args )
|
||||
|
||||
|
||||
def _ResetInstaller():
|
||||
|
|
|
|||
|
|
@ -16,11 +16,18 @@
|
|||
|
||||
import vim
|
||||
import builtins
|
||||
from vimspector import utils
|
||||
|
||||
|
||||
def Get( option: str, default=None, cls=str ):
|
||||
return cls( vim.vars.get( f'vimspector_{ option }', default ) )
|
||||
return cls( utils.GetVimValue( vim.vars,
|
||||
f'vimspector_{ option }',
|
||||
default ) )
|
||||
|
||||
|
||||
def Int( option: str, default=0 ):
|
||||
return Get( option, default=default, cls=builtins.int )
|
||||
|
||||
|
||||
def List( option: str, default=[] ):
|
||||
return utils.GetVimList( vim.vars, f'vimspector_{ option }', default )
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import string
|
|||
import functools
|
||||
import subprocess
|
||||
import shlex
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
LOG_FILE = os.path.expanduser( os.path.join( '~', '.vimspector.log' ) )
|
||||
|
|
@ -646,7 +646,7 @@ def HideSplash( api_prefix, splash ):
|
|||
return None
|
||||
|
||||
|
||||
def GetVimString( vim_dict, name, default=None ):
|
||||
def GetVimValue( vim_dict, name, default=None ):
|
||||
|
||||
# FIXME: use 'encoding' ?
|
||||
try:
|
||||
|
|
@ -659,13 +659,27 @@ def GetVimString( vim_dict, name, default=None ):
|
|||
return value
|
||||
|
||||
|
||||
def GetVimList( vim_dict, name, default=None ):
|
||||
try:
|
||||
value = vim_dict[ name ]
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
if not isinstance( value, collections.abc.Iterable ):
|
||||
raise ValueError( f"Expected a list for { name }, but found "
|
||||
f"{ type( value ) }" )
|
||||
|
||||
return [ i.decode( 'utf-8' ) if isinstance( i, bytes ) else i for i in value ]
|
||||
|
||||
|
||||
|
||||
def GetVimspectorBase():
|
||||
return GetVimString( vim.vars,
|
||||
'vimspector_base_dir',
|
||||
os.path.abspath(
|
||||
os.path.join( os.path.dirname( __file__ ),
|
||||
'..',
|
||||
'..' ) ) )
|
||||
return GetVimValue( vim.vars,
|
||||
'vimspector_base_dir',
|
||||
os.path.abspath(
|
||||
os.path.join( os.path.dirname( __file__ ),
|
||||
'..',
|
||||
'..' ) ) )
|
||||
|
||||
|
||||
def GetUnusedLocalPort():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue