Support basic UI customisation via a User autocommand
This commit is contained in:
parent
de2a924c38
commit
2c5937c2c1
6 changed files with 69 additions and 14 deletions
|
|
@ -97,6 +97,12 @@ command! -bar
|
||||||
\ VimspectorReset
|
\ VimspectorReset
|
||||||
\ call vimspector#Reset()
|
\ call vimspector#Reset()
|
||||||
|
|
||||||
|
" Dummy autocommands so that we can call this whenever
|
||||||
|
augroup VimspectorUserAutoCmds
|
||||||
|
au!
|
||||||
|
au User VimspectorUICreated silent
|
||||||
|
augroup END
|
||||||
|
|
||||||
" boilerplate {{{
|
" boilerplate {{{
|
||||||
call s:restore_cpo()
|
call s:restore_cpo()
|
||||||
" }}}
|
" }}}
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,8 @@ class DebugSession( object ):
|
||||||
self._logger.info( "Debugging complete." )
|
self._logger.info( "Debugging complete." )
|
||||||
if self._uiTab:
|
if self._uiTab:
|
||||||
self._logger.debug( "Clearing down UI" )
|
self._logger.debug( "Clearing down UI" )
|
||||||
|
|
||||||
|
del vim.vars[ 'vimspector_session_windows' ]
|
||||||
vim.current.tabpage = self._uiTab
|
vim.current.tabpage = self._uiTab
|
||||||
|
|
||||||
self._splash_screen = utils.HideSplash( self._api_prefix,
|
self._splash_screen = utils.HideSplash( self._api_prefix,
|
||||||
|
|
@ -473,42 +475,60 @@ class DebugSession( object ):
|
||||||
self._uiTab = vim.current.tabpage
|
self._uiTab = vim.current.tabpage
|
||||||
|
|
||||||
# Code window
|
# Code window
|
||||||
self._codeView = code.CodeView( vim.current.window,
|
code_window = vim.current.window
|
||||||
self._api_prefix )
|
self._codeView = code.CodeView( code_window, self._api_prefix )
|
||||||
|
|
||||||
# Call stack
|
# Call stack
|
||||||
with utils.TemporaryVimOptions( { 'splitright': False,
|
with utils.TemporaryVimOptions( { 'splitright': False,
|
||||||
'equalalways': False, } ):
|
'equalalways': False, } ):
|
||||||
vim.command( 'topleft vertical 50new' )
|
vim.command( 'topleft vertical 50new' )
|
||||||
|
stack_trace_window = vim.current.window
|
||||||
self._stackTraceView = stack_trace.StackTraceView( self,
|
self._stackTraceView = stack_trace.StackTraceView( self,
|
||||||
self._connection,
|
self._connection,
|
||||||
vim.current.buffer )
|
stack_trace_window )
|
||||||
|
|
||||||
with utils.TemporaryVimOptions( { 'splitbelow': False,
|
with utils.TemporaryVimOptions( { 'splitbelow': False,
|
||||||
'eadirection': 'ver',
|
'eadirection': 'ver',
|
||||||
'equalalways': True } ):
|
'equalalways': True } ):
|
||||||
# Watches
|
# Watches
|
||||||
vim.command( 'new' )
|
vim.command( 'new' )
|
||||||
watch_win = vim.current.window
|
watch_window = vim.current.window
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
vim.command( 'new' )
|
vim.command( 'new' )
|
||||||
vars_win = vim.current.window
|
vars_window = vim.current.window
|
||||||
|
|
||||||
self._variablesView = variables.VariablesView( self._connection,
|
self._variablesView = variables.VariablesView( self._connection,
|
||||||
vars_win,
|
vars_window,
|
||||||
watch_win )
|
watch_window )
|
||||||
|
|
||||||
|
|
||||||
with utils.TemporaryVimOption( 'splitbelow', True ):
|
with utils.TemporaryVimOption( 'splitbelow', True ):
|
||||||
vim.current.window = self._codeView._window
|
vim.current.window = code_window
|
||||||
|
|
||||||
# Output/logging
|
# Output/logging
|
||||||
vim.command( '10new' )
|
vim.command( '10new' )
|
||||||
|
output_window = vim.current.window
|
||||||
self._outputView = output.OutputView( self._connection,
|
self._outputView = output.OutputView( self._connection,
|
||||||
vim.current.window,
|
output_window,
|
||||||
self._api_prefix )
|
self._api_prefix )
|
||||||
|
|
||||||
|
# TODO: If/when we support multiple sessions, we'll need some way to
|
||||||
|
# indicate which tab was created and store all the tabs
|
||||||
|
vim.vars[ 'vimspector_session_windows' ] = {
|
||||||
|
'tabpage': self._uiTab.number,
|
||||||
|
'code': utils.WindowID( code_window, self._uiTab ),
|
||||||
|
'stack_trace': utils.WindowID( stack_trace_window, self._uiTab ),
|
||||||
|
'variables': utils.WindowID( vars_window, self._uiTab ),
|
||||||
|
'watches': utils.WindowID( watch_window, self._uiTab ),
|
||||||
|
'output': utils.WindowID( output_window, self._uiTab ),
|
||||||
|
}
|
||||||
|
with utils.RestoreCursorPosition():
|
||||||
|
with utils.RestoreCurrentWindow():
|
||||||
|
with utils.RestoreCurrentBuffer( vim.current.window ):
|
||||||
|
vim.command( 'doautocmd User VimspectorUICreated' )
|
||||||
|
|
||||||
|
|
||||||
def ClearCurrentFrame( self ):
|
def ClearCurrentFrame( self ):
|
||||||
self.SetCurrentFrame( None )
|
self.SetCurrentFrame( None )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ from vimspector import utils
|
||||||
|
|
||||||
|
|
||||||
class StackTraceView( object ):
|
class StackTraceView( object ):
|
||||||
def __init__( self, session, connection, buf ):
|
def __init__( self, session, connection, win ):
|
||||||
self._logger = logging.getLogger( __name__ )
|
self._logger = logging.getLogger( __name__ )
|
||||||
utils.SetUpLogging( self._logger )
|
utils.SetUpLogging( self._logger )
|
||||||
|
|
||||||
self._buf = buf
|
self._buf = win.buffer
|
||||||
self._session = session
|
self._session = session
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
||||||
|
|
@ -38,9 +38,7 @@ class StackTraceView( object ):
|
||||||
self._scratch_buffers = []
|
self._scratch_buffers = []
|
||||||
|
|
||||||
utils.SetUpHiddenBuffer( self._buf, 'vimspector.StackTrace' )
|
utils.SetUpHiddenBuffer( self._buf, 'vimspector.StackTrace' )
|
||||||
|
utils.SetUpUIWindow( win )
|
||||||
vim.current.buffer = self._buf
|
|
||||||
utils.SetUpUIWindow( vim.current.window )
|
|
||||||
|
|
||||||
vim.command( 'nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>' )
|
vim.command( 'nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>' )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -639,3 +639,7 @@ def GetUnusedLocalPort():
|
||||||
port = sock.getsockname()[ 1 ]
|
port = sock.getsockname()[ 1 ]
|
||||||
sock.close()
|
sock.close()
|
||||||
return port
|
return port
|
||||||
|
|
||||||
|
|
||||||
|
def WindowID( window, tab ):
|
||||||
|
return int( Call( 'win_getid', window.number, tab.number ) )
|
||||||
|
|
|
||||||
23
support/custom_ui_vimrc
Normal file
23
support/custom_ui_vimrc
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
execute 'source' expand( '<sfile>:p:h' ) . '/minimal_vimrc'
|
||||||
|
set noequalalways
|
||||||
|
|
||||||
|
function! s:CustomiseUI()
|
||||||
|
let wins = g:vimspector_session_windows
|
||||||
|
|
||||||
|
" Close the Variables window
|
||||||
|
call win_execute( wins.variables, 'q' )
|
||||||
|
|
||||||
|
" Put the stack trace at the top of the "left bar" (rotate)
|
||||||
|
call win_gotoid( wins.stack_trace )
|
||||||
|
wincmd r
|
||||||
|
|
||||||
|
" Make the output window 10 lines high and right at the top of the screen
|
||||||
|
call win_gotoid( wins.output )
|
||||||
|
10wincmd _
|
||||||
|
wincmd K
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup TestUICustomistaion
|
||||||
|
autocmd!
|
||||||
|
autocmd User VimspectorUICreated call s:CustomiseUI()
|
||||||
|
augroup END
|
||||||
4
support/minimal_vimrc
Normal file
4
support/minimal_vimrc
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
let s:vimspector_path = expand( '<sfile>:p:h:h' )
|
||||||
|
let g:vimspector_enable_mappings = 'HUMAN'
|
||||||
|
exe 'source ' . s:vimspector_path . '/tests/vimrc'
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue