diff --git a/README.md b/README.md index 37b05c5..93dd747 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,12 @@ For a tutorial and usage overview, take a look at the * [Windows differences](#windows-differences) * [Clone the plugin](#clone-the-plugin) * [Install some gadgets](#install-some-gadgets) + * [VimspectorInstall and VimspectorUpdate commands](#vimspectorinstall-and-vimspectorupdate-commands) + * [install_gadget.py](#install_gadgetpy) * [Manual gadget installation](#manual-gadget-installation) * [The gadget directory](#the-gadget-directory) * [Trying it out](#trying-it-out) + * [Upgrade](#upgrade) * [About](#about) * [Background](#background) * [Status](#status) @@ -71,7 +74,7 @@ For a tutorial and usage overview, take a look at the * [License](#license) * [Sponsorship](#sponsorship) - + @@ -307,9 +310,23 @@ To install the tested debug adapter for a language, run: | Supported and experimental adapters | `./install_gadget.py --all --force-all` | `:VimspectorInstall --all` | | Adapter for specific debug config | | Suggested by Vimspector when starting debugging | -`"VimspectorInstall` runs `install_gadget.py` in the background with some of +### VimspectorInstall and VimspectorUpdate commands + +`:VimspectorInstall` runs `install_gadget.py` in the background with some of the options defaulted. +`:VimspectorUpdate` runs `install_gadget.py` to re-install (i.e. update) any +gadgets already installed in your `.gadgets.json`. + +The output is minimal, to see the full output add `--verbose` to the command, as +in `:VimspectorInstall --verbose ...` or `:VimspectorUpdate --verbose ...`. + +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.). + +### install\_gadget.py + By default `install_gadget.py` will overwrite your `.gadgets.json` with the set of adapters just installed, whereas `:VimspectorInstall` will _update_ it, overwriting only newly changed or installed adapters. diff --git a/autoload/vimspector.vim b/autoload/vimspector.vim index 1ada223..afbd52c 100644 --- a/autoload/vimspector.vim +++ b/autoload/vimspector.vim @@ -232,7 +232,7 @@ function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort \ "\n" ) endfunction -function! vimspector#Install( ... ) abort +function! vimspector#Install( bang, ... ) abort if !s:enabled return endif @@ -243,6 +243,7 @@ function! vimspector#Install( ... ) abort py3 __import__( 'vimspector', \ fromlist = [ 'installer' ] ).installer.RunInstaller( \ vim.eval( 'prefix' ), + \ vim.eval( 'a:bang' ) == '!', \ *vim.eval( 'a:000' ) ) endfunction @@ -256,7 +257,7 @@ function! vimspector#CompleteInstall( ArgLead, CmdLine, CursorPos ) abort \ . ')' ) endfunction -function! vimspector#Update( ... ) abort +function! vimspector#Update( bang, ... ) abort if !s:enabled return endif @@ -265,6 +266,7 @@ function! vimspector#Update( ... ) abort py3 __import__( 'vimspector', \ fromlist = [ 'installer' ] ).installer.RunUpdate( \ vim.eval( 'prefix' ), + \ vim.eval( 'a:bang' ) == '!', \ *vim.eval( 'a:000' ) ) endfunction diff --git a/plugin/vimspector.vim b/plugin/vimspector.vim index 3e937da..416eb04 100644 --- a/plugin/vimspector.vim +++ b/plugin/vimspector.vim @@ -99,12 +99,12 @@ command! -bar \ call vimspector#Reset() " Installer commands -command! -bar -nargs=* -complete=custom,vimspector#CompleteInstall +command! -bar -bang -nargs=* -complete=custom,vimspector#CompleteInstall \ VimspectorInstall - \ call vimspector#Install( ) -command! -bar -nargs=* + \ call vimspector#Install( , ) +command! -bar -bang -nargs=* \ VimspectorUpdate - \ call vimspector#Update( ) + \ call vimspector#Update( , ) command! -bar -nargs=0 \ VimspectorAbortInstall \ call vimspector#AbortInstall() diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index cc23a47..15ff90c 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -164,6 +164,7 @@ class DebugSession( object ): installer.RunInstaller( self._api_prefix, + False, # Don't leave open *shlex.split( response ), then = lambda: self.Start( new_launch_variables ) ) return diff --git a/python3/vimspector/installer.py b/python3/vimspector/installer.py index 4175946..52497b5 100644 --- a/python3/vimspector/installer.py +++ b/python3/vimspector/installer.py @@ -95,7 +95,7 @@ def PathToAnyWorkingPython3(): raise RuntimeError( "Unable to find a working python3" ) -def RunInstaller( api_prefix, *args, **kwargs ): +def RunInstaller( api_prefix, leave_open, *args, **kwargs ): from vimspector import utils, output, settings import vim @@ -125,7 +125,8 @@ def RunInstaller( api_prefix, *args, **kwargs ): def handler( exit_code ): if exit_code == 0: - _ResetInstaller() + if not leave_open: + _ResetInstaller() utils.UserMessage( "Vimspector gadget installation complete!" ) vim.command( 'silent doautocmd User VimspectorInstallSuccess' ) if 'then' in kwargs: @@ -143,7 +144,7 @@ def RunInstaller( api_prefix, *args, **kwargs ): OUTPUT_VIEW.ShowOutput( 'Installer' ) -def RunUpdate( api_prefix, *args ): +def RunUpdate( api_prefix, leave_open, *args ): from vimspector import utils Configure( vimspector_base = utils.GetVimspectorBase() ) @@ -153,7 +154,7 @@ def RunUpdate( api_prefix, *args ): args.extend( FindGadgetForAdapter( adapter_name ) ) if args: - RunInstaller( api_prefix, *args ) + RunInstaller( api_prefix, leave_open, *args ) def _ResetInstaller():