def _StartDebugAdapter( self ): self._splash_screen = utils.DisplaySplash( self._api_prefix, self._splash_screen, "Starting debug adapter..." ) if self._connection: utils.UserMessage( 'The connection is already created. Please try again', persist = True ) return self._logger.info( 'Starting debug adapter with: %s', json.dumps( self._adapter ) ) self._init_complete = False self._on_init_complete_handlers = [] self._launch_complete = False self._run_on_server_exit = None self._connection_type = 'job' if 'port' in self._adapter: self._connection_type = 'channel' if self._adapter[ 'port' ] == 'ask': port = utils.AskForInput( 'Enter port to connect to: ' ) if port is None: self._Reset() return self._adapter[ 'port' ] = port self._connection_type = self._api_prefix + self._connection_type # TODO: Do we actually need to copy and update or does Vim do that? env = os.environ.copy() if os.name == "nt": env = {} if 'env' in self._adapter: env.update( self._adapter[ 'env' ] ) self._adapter[ 'env' ] = env if 'cwd' not in self._adapter: self._adapter[ 'cwd' ] = os.getcwd() vim.vars[ '_vimspector_adapter_spec' ] = self._adapter if not vim.eval( "vimspector#internal#{}#StartDebugSession( " " g:_vimspector_adapter_spec " ")".format( self._connection_type ) ): self._logger.error( "Unable to start debug server" ) self._splash_screen = utils.DisplaySplash( self._api_prefix, self._splash_screen, "Unable to start adapter" ) else: self._connection = debug_adapter_connection.DebugAdapterConnection( self, lambda msg: utils.Call( "vimspector#internal#{}#Send".format( self._connection_type ), msg ) ) self._logger.info( 'Debug Adapter Started' )
def _StartDebugAdapter(self): self._logger.info('Starting debug adapter with: {0}'.format( json.dumps(self._adapter))) channel_send_func = vim.bindeval( "vimspector#internal#job#StartDebugSession( {0} )".format( json.dumps(self._adapter))) self._connection = debug_adapter_connection.DebugAdapterConnection( self, channel_send_func) self._logger.info('Debug Adapter Started') vim.command('augroup vimspector_cleanup') vim.command('autocmd!') vim.command( 'autocmd VimLeavePre * py3 _vimspector_session.CloseDown()') vim.command('augroup END')
def _StartDebugAdapter( self ): if self._connection: utils.UserMessage( 'The connection is already created. Please try again', persist = True ) return self._logger.info( 'Starting debug adapter with: %s', json.dumps( self._adapter ) ) self._init_complete = False self._on_init_complete_handlers = [] self._launch_complete = False self._run_on_server_exit = None self._connection_type = 'job' if 'port' in self._adapter: self._connection_type = 'channel' if self._adapter[ 'port' ] == 'ask': port = utils.AskForInput( 'Enter port to connect to: ' ) self._adapter[ 'port' ] = port # TODO: Do we actually need to copy and update or does Vim do that? env = os.environ.copy() if 'env' in self._adapter: env.update( self._adapter[ 'env' ] ) self._adapter[ 'env' ] = env if 'cwd' not in self._adapter: self._adapter[ 'cwd' ] = os.getcwd() channel_send_func = vim.bindeval( "vimspector#internal#{}#StartDebugSession( {} )".format( self._connection_type, json.dumps( self._adapter ) ) ) if channel_send_func is None: self._logger.error( "Unable to start debug server" ) else: self._connection = debug_adapter_connection.DebugAdapterConnection( self, channel_send_func ) self._logger.info( 'Debug Adapter Started' )
def _StartDebugAdapter(self): self._splash_screen = utils.DisplaySplash(self._api_prefix, self._splash_screen, "Starting debug adapter...") if self._connection: utils.UserMessage( 'The connection is already created. Please try again', persist=True) return # There is the problem with the current flow when we try to use a debugger # which is located fully on the remote server e.g container or SSH Server. # The problem is in the order: it tries to connect to debugger before it is even started # To solve that problem, I offer adding an optional boolean key "bootstrap" to a configuration. # If we have that key, we should perform launch or attach commands to first bootstrap a remote debugger. # Then we can skip that step in the _Launch() function if self._adapter.get('bootstrap'): self._BootstrapRemoteDebugger() self._logger.info('Starting debug adapter with: %s', json.dumps(self._adapter)) self._init_complete = False self._on_init_complete_handlers = [] self._launch_complete = False self._run_on_server_exit = None self._connection_type = 'job' if 'port' in self._adapter: self._connection_type = 'channel' if self._adapter['port'] == 'ask': port = utils.AskForInput('Enter port to connect to: ') if port is None: self._Reset() return self._adapter['port'] = port self._connection_type = self._api_prefix + self._connection_type # TODO: Do we actually need to copy and update or does Vim do that? env = os.environ.copy() if 'env' in self._adapter: env.update(self._adapter['env']) self._adapter['env'] = env if 'cwd' not in self._adapter: self._adapter['cwd'] = os.getcwd() vim.vars['_vimspector_adapter_spec'] = self._adapter if not vim.eval("vimspector#internal#{}#StartDebugSession( " " g:_vimspector_adapter_spec " ")".format(self._connection_type)): self._logger.error("Unable to start debug server") self._splash_screen = utils.DisplaySplash( self._api_prefix, self._splash_screen, "Unable to start adapter") else: self._connection = debug_adapter_connection.DebugAdapterConnection( self, lambda msg: utils.Call( "vimspector#internal#{}#Send".format(self._connection_type ), msg)) self._logger.info('Debug Adapter Started')
def _StartDebugAdapter( self ): self._splash_screen = utils.DisplaySplash( self._api_prefix, self._splash_screen, "Starting debug adapter..." ) if self._connection: utils.UserMessage( 'The connection is already created. Please try again', persist = True ) return self._logger.info( 'Starting debug adapter with: %s', json.dumps( self._adapter ) ) self._init_complete = False self._launch_complete = False self._run_on_server_exit = None self._connection_type = 'job' if 'port' in self._adapter: self._connection_type = 'channel' if self._adapter[ 'port' ] == 'ask': port = utils.AskForInput( 'Enter port to connect to: ' ) if port is None: self._Reset() return self._adapter[ 'port' ] = port self._connection_type = self._api_prefix + self._connection_type self._logger.debug( f"Connection Type: { self._connection_type }" ) self._adapter[ 'env' ] = self._adapter.get( 'env', {} ) if 'cwd' not in self._adapter: self._adapter[ 'cwd' ] = os.getcwd() vim.vars[ '_vimspector_adapter_spec' ] = self._adapter if not vim.eval( "vimspector#internal#{}#StartDebugSession( " " g:_vimspector_adapter_spec " ")".format( self._connection_type ) ): self._logger.error( "Unable to start debug server" ) self._splash_screen = utils.DisplaySplash( self._api_prefix, self._splash_screen, "Unable to start adapter" ) else: if 'custom_handler' in self._adapter: spec = self._adapter[ 'custom_handler' ] if isinstance( spec, dict ): module = spec[ 'module' ] cls = spec[ 'class' ] else: module, cls = spec.rsplit( '.', 1 ) CustomHandler = getattr( importlib.import_module( module ), cls ) handlers = [ CustomHandler( self ), self ] else: handlers = [ self ] self._connection = debug_adapter_connection.DebugAdapterConnection( handlers, lambda msg: utils.Call( "vimspector#internal#{}#Send".format( self._connection_type ), msg ) ) self._logger.info( 'Debug Adapter Started' )