diff --git a/plugin/vimspector.vim b/plugin/vimspector.vim index cb921eb..1a6ffdc 100644 --- a/plugin/vimspector.vim +++ b/plugin/vimspector.vim @@ -97,6 +97,12 @@ command! -bar \ VimspectorReset \ call vimspector#Reset() +" Dummy autocommands so that we can call this whenever +augroup VimspectorUserAutoCmds + au! + au User VimspectorUICreated silent +augroup END + " boilerplate {{{ call s:restore_cpo() " }}} diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index eb3c701..61d7a6c 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -335,6 +335,8 @@ class DebugSession( object ): self._logger.info( "Debugging complete." ) if self._uiTab: self._logger.debug( "Clearing down UI" ) + + del vim.vars[ 'vimspector_session_windows' ] vim.current.tabpage = self._uiTab self._splash_screen = utils.HideSplash( self._api_prefix, @@ -473,42 +475,60 @@ class DebugSession( object ): self._uiTab = vim.current.tabpage # Code window - self._codeView = code.CodeView( vim.current.window, - self._api_prefix ) + code_window = vim.current.window + self._codeView = code.CodeView( code_window, self._api_prefix ) # Call stack with utils.TemporaryVimOptions( { 'splitright': False, 'equalalways': False, } ): vim.command( 'topleft vertical 50new' ) + stack_trace_window = vim.current.window self._stackTraceView = stack_trace.StackTraceView( self, self._connection, - vim.current.buffer ) + stack_trace_window ) with utils.TemporaryVimOptions( { 'splitbelow': False, 'eadirection': 'ver', 'equalalways': True } ): # Watches vim.command( 'new' ) - watch_win = vim.current.window + watch_window = vim.current.window # Variables vim.command( 'new' ) - vars_win = vim.current.window + vars_window = vim.current.window self._variablesView = variables.VariablesView( self._connection, - vars_win, - watch_win ) + vars_window, + watch_window ) with utils.TemporaryVimOption( 'splitbelow', True ): - vim.current.window = self._codeView._window + vim.current.window = code_window # Output/logging vim.command( '10new' ) + output_window = vim.current.window self._outputView = output.OutputView( self._connection, - vim.current.window, + output_window, 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 ): self.SetCurrentFrame( None ) diff --git a/python3/vimspector/stack_trace.py b/python3/vimspector/stack_trace.py index 0afeb81..d5ea0b5 100644 --- a/python3/vimspector/stack_trace.py +++ b/python3/vimspector/stack_trace.py @@ -21,11 +21,11 @@ from vimspector import utils class StackTraceView( object ): - def __init__( self, session, connection, buf ): + def __init__( self, session, connection, win ): self._logger = logging.getLogger( __name__ ) utils.SetUpLogging( self._logger ) - self._buf = buf + self._buf = win.buffer self._session = session self._connection = connection @@ -38,9 +38,7 @@ class StackTraceView( object ): self._scratch_buffers = [] utils.SetUpHiddenBuffer( self._buf, 'vimspector.StackTrace' ) - - vim.current.buffer = self._buf - utils.SetUpUIWindow( vim.current.window ) + utils.SetUpUIWindow( win ) vim.command( 'nnoremap :call vimspector#GoToFrame()' ) diff --git a/python3/vimspector/utils.py b/python3/vimspector/utils.py index 48991f7..d4a7749 100644 --- a/python3/vimspector/utils.py +++ b/python3/vimspector/utils.py @@ -639,3 +639,7 @@ def GetUnusedLocalPort(): port = sock.getsockname()[ 1 ] sock.close() return port + + +def WindowID( window, tab ): + return int( Call( 'win_getid', window.number, tab.number ) ) diff --git a/support/custom_ui_vimrc b/support/custom_ui_vimrc new file mode 100644 index 0000000..1f30aeb --- /dev/null +++ b/support/custom_ui_vimrc @@ -0,0 +1,23 @@ +execute 'source' expand( ':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 diff --git a/support/minimal_vimrc b/support/minimal_vimrc new file mode 100644 index 0000000..3626d39 --- /dev/null +++ b/support/minimal_vimrc @@ -0,0 +1,4 @@ +let s:vimspector_path = expand( ':p:h:h' ) +let g:vimspector_enable_mappings = 'HUMAN' +exe 'source ' . s:vimspector_path . '/tests/vimrc' +