Merge pull request #216 from puremourning/installer-list
Allow a statically configured list of gadgets
This commit is contained in:
commit
56418e3233
5 changed files with 57 additions and 18 deletions
13
README.md
13
README.md
|
|
@ -325,6 +325,19 @@ If the installation is successful, the output window is closed (and the output
|
|||
lost forever). Use a `!` to keep it open (e.g. `:VimspectorInstall! --verbose
|
||||
--all` or `:VimspectorUpdate!` (etc.).
|
||||
|
||||
If you know in advance which gadgets you want to install, for example so that
|
||||
you can reproduce your config from source control, you can set
|
||||
`g:vimspector_install_gadgets` to a list of gadgets. This will be used when:
|
||||
|
||||
* Running `:VimspectorInstall` with no arguments, or
|
||||
* Running `:VimspectorUpdate`
|
||||
|
||||
For example:
|
||||
|
||||
```viml
|
||||
let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-cpptools', 'CodeLLDB' ]
|
||||
```
|
||||
|
||||
### install\_gadget.py
|
||||
|
||||
By default `install_gadget.py` will overwrite your `.gadgets.json` with the set
|
||||
|
|
|
|||
|
|
@ -236,9 +236,6 @@ function! vimspector#Install( bang, ... ) abort
|
|||
if !s:enabled
|
||||
return
|
||||
endif
|
||||
if a:0 < 1
|
||||
return
|
||||
endif
|
||||
let prefix = vimspector#internal#state#GetAPIPrefix()
|
||||
py3 __import__( 'vimspector',
|
||||
\ fromlist = [ 'installer' ] ).installer.RunInstaller(
|
||||
|
|
|
|||
|
|
@ -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