Switch to running the actual install_gadget.py

This re-uses the OutputView code to run the installer script. Refactor
to remove connection from the base OutputView (and other places, it
wasn't used - only used after ConnectionUp).

This also consolidates the stdout and stderr buffers for running jobs.
The distinction was always arbitrary and probably an error, based on the
fact that they were separate in the APIs not based on usability.
This commit is contained in:
Ben Jackson 2020-07-21 16:43:39 +01:00
commit 23e5f6bbf4
12 changed files with 236 additions and 167 deletions

View file

@ -132,6 +132,14 @@ function! vimspector#ShowOutput( category ) abort
py3 _vimspector_session.ShowOutput( vim.eval( 'a:category' ) )
endfunction
function! vimspector#ShowOutputInWindow( win_id, category ) abort
py3 <<EOF
from vimspector import output as vimspector_output
vimspector_output.ShowOutputInWindow( int( vim.eval( 'a:win_id' ) ),
vim.eval( 'a:category' ) )
EOF
endfunction
function! vimspector#ListBreakpoints() abort
py3 _vimspector_session.ListBreakpoints()
endfunction
@ -154,48 +162,13 @@ 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
let prefix = vimspector#internal#state#GetAPIPrefix()
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' ) )
vimspector_installer.RunInstaller( vim.eval( 'prefix' ), *vim.eval( 'a:000' ) )
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

View file

@ -157,14 +157,16 @@ function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
let l:index = len( s:commands[ a:category ] )
let buf = '_vimspector_log_' . a:category
call add( s:commands[ a:category ], job_start(
\ a:cmd,
\ {
\ 'out_io': 'buffer',
\ 'in_io': 'null',
\ 'err_io': 'buffer',
\ 'out_name': '_vimspector_log_' . a:category . '_out',
\ 'err_name': '_vimspector_log_' . a:category . '_err',
\ 'out_name': buf,
\ 'err_name': buf,
\ 'out_modifiable': 0,
\ 'err_modifiable': 0,
\ 'stoponexit': 'kill'
@ -176,12 +178,7 @@ function! vimspector#internal#job#StartCommandWithLog( cmd, category ) abort
return v:none
endif
let l:stdout = ch_getbufnr(
\ job_getchannel( s:commands[ a:category ][ index ] ), 'out' )
let l:stderr = ch_getbufnr(
\ job_getchannel( s:commands[ a:category ][ index ] ), 'err' )
return [ l:stdout, l:stderr ]
return bufnr( buf )
endfunction

View file

@ -198,14 +198,12 @@ function! vimspector#internal#neojob#StartCommandWithLog( cmd, category ) abort
let s:commands[ a:category ] = {}
endif
let stdout_buf = bufnr( '_vimspector_log_' . a:category . '_out', v:true )
let stderr_buf = bufnr( '_vimspector_log_' . a:category . '_err', v:true )
let buf = bufnr( '_vimspector_log_' . a:category, v:true )
" FIXME: This largely duplicates the same stuff in the python layer, but we
" don't want to potentially mess up Vim behaviour where the job output is
" attached to a buffer set up by Vim. So we sort o mimic that here.
call s:SetUpHiddenBuffer( stdout_buf )
call s:SetUpHiddenBuffer( stderr_buf )
call s:SetUpHiddenBuffer( buf )
let id = jobstart(a:cmd,
\ {
@ -216,11 +214,11 @@ function! vimspector#internal#neojob#StartCommandWithLog( cmd, category ) abort
\ } )
let s:commands[ a:category ][ id ] = {
\ 'stdout': stdout_buf,
\ 'stderr': stderr_buf
\ 'stdout': buf,
\ 'stderr': buf
\ }
return [ stdout_buf, stderr_buf ]
return buf
endfunction
function! vimspector#internal#neojob#CleanUpCommand( category ) abort

View file

@ -19,20 +19,23 @@ let s:save_cpo = &cpoptions
set cpoptions&vim
" }}}
let s:is_neovim = has( 'nvim' )
let s:prefix = ''
if has( 'nvim' )
let s:prefix='neo'
endif
function! vimspector#internal#state#Reset() abort
let prefix = ''
if s:is_neovim
let prefix='neo'
endif
py3 << EOF
import vim
from vimspector import debug_session
_vimspector_session = debug_session.DebugSession( vim.eval( 'prefix' ) )
_vimspector_session = debug_session.DebugSession( vim.eval( 's:prefix' ) )
EOF
endfunction
function! vimspector#internal#state#GetAPIPrefix() abort
return s:prefix
endfunction
" Boilerplate {{{
let &cpoptions=s:save_cpo
unlet s:save_cpo