Add VimspectorInstall command with sort-of completion
This commit is contained in:
parent
f945dbcfdd
commit
025d193493
3 changed files with 83 additions and 1 deletions
|
|
@ -150,6 +150,52 @@ function! vimspector#CompleteExpr( ArgLead, CmdLine, CursorPos ) abort
|
|||
\ "\n" )
|
||||
endfunction
|
||||
|
||||
function! vimspector#Install( ... ) abort
|
||||
if a:0 < 1
|
||||
return
|
||||
endif
|
||||
|
||||
let gadgets = a:000
|
||||
let force = a:1 ==# '--force'
|
||||
if force
|
||||
let gadgets = a:000[ 1: ]
|
||||
endif
|
||||
|
||||
py3 << EOF
|
||||
from vimspector import installer as vimspector_installer
|
||||
from vimspector import utils as vimspector_utils
|
||||
vimspector_installer.Configure(
|
||||
vimspector_base = vimspector_utils.GetVimspectorBase() )
|
||||
vimspector_installer.Install( vim.eval( 'gadgets'), vim.eval( 'force' ) )
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! vimspector#CompleteInstall( ArgLead, CmdLine, CursorPos ) abort
|
||||
let words = split( a:CmdLine )
|
||||
let done_options = v:false
|
||||
for word in words
|
||||
if ! word =~# '^--'
|
||||
let done_options = v:true
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
let options = []
|
||||
|
||||
if !done_options
|
||||
call extend( options, [ '--force' ] )
|
||||
endif
|
||||
|
||||
py3 from vimspector import installer as vimspector_installer
|
||||
call extend( options, [ 'all' ] )
|
||||
call extend(
|
||||
\ options,
|
||||
\ py3eval(
|
||||
\ '[ g[ "language" ] for g in vimspector_installer.GADGETS.values() ]' ) )
|
||||
|
||||
return join( options, "\n" )
|
||||
endfunction
|
||||
|
||||
" Boilerplate {{{
|
||||
let &cpoptions=s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
|
|
|||
|
|
@ -97,6 +97,11 @@ command! -bar
|
|||
\ VimspectorReset
|
||||
\ call vimspector#Reset()
|
||||
|
||||
" Installer commands
|
||||
command! -bar -nargs=* -complete=custom,vimspector#CompleteInstall
|
||||
\ VimspectorInstall
|
||||
\ call vimspector#Install( <f-args> )
|
||||
|
||||
" Dummy autocommands so that we can call this whenever
|
||||
augroup VimspectorUserAutoCmds
|
||||
au!
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# TODO: Chnage `print` to some other mechanism that can be displayed in a vim
|
||||
# buffer?
|
||||
|
||||
from urllib import request
|
||||
import contextlib
|
||||
import functools
|
||||
|
|
@ -33,7 +36,8 @@ import traceback
|
|||
import zipfile
|
||||
import json
|
||||
|
||||
from vimspector import install
|
||||
from vimspector import install, gadgets
|
||||
|
||||
|
||||
class Options:
|
||||
vimspector_base = None
|
||||
|
|
@ -48,6 +52,33 @@ def Configure( **kwargs ):
|
|||
setattr( options, k, v )
|
||||
|
||||
|
||||
def Install( languages, force ):
|
||||
all_enabled = 'all' in languages
|
||||
force_all = all_enabled and force
|
||||
|
||||
install.MakeInstallDirs( options.vimspector_base )
|
||||
all_adapters = ReadAdapters()
|
||||
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,
|
||||
failed,
|
||||
all_adapters )
|
||||
|
||||
WriteAdapters( all_adapters )
|
||||
|
||||
return failed
|
||||
|
||||
|
||||
def InstallGeneric( name, root, gadget ):
|
||||
extension = os.path.join( root, 'extension' )
|
||||
for f in gadget.get( 'make_executable', [] ):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue