예제 #1
0
    def start_lsp_client(self, language):
        started = False
        if language in self.clients:
            language_client = self.clients[language]
            queue = self.register_queue[language]
            if (os.environ.get('CI', False) and
                    not os.environ.get('SPY_TEST_USE_INTROSPECTION')):
                return started
            started = language_client['status'] == self.RUNNING
            if language_client['status'] == self.STOPPED:
                config = language_client['config']
                if not config['external']:
                    port = select_port(default_port=config['port'])
                    config['port'] = port
                language_client['instance'] = LSPClient(
                    self, config['args'], config, config['external'],
                    plugin_configurations=config.get('configurations', {}),
                    language=language)

                for plugin in self.lsp_plugins:
                    language_client['instance'].register_plugin_type(
                        plugin, self.lsp_plugins[plugin])

                language_client['instance'].start()
                language_client['status'] = self.RUNNING
                for entry in queue:
                    language_client.register_file(*entry)
                self.register_queue[language] = []
        return started
예제 #2
0
def lsp_client(qtbot):
    config = CONF.get('lsp-server', 'python')
    lsp_editor = LSPEditor()
    lsp = LSPClient(parent=None, server_settings=config, language='python')
    lsp.register_plugin_type(LSPEventTypes.DOCUMENT,
                             lsp_editor.sig_lsp_notification)
    yield lsp, lsp_editor
    if os.name != 'nt':
        lsp.stop()
예제 #3
0
def lsp_client(qtbot):
    config = CONF.get('lsp-server', 'python')
    lsp_editor = LSPEditor()
    lsp = LSPClient(None,
                    config['args'],
                    config,
                    config['external'],
                    plugin_configurations=config.get('configurations', {}),
                    language='python')
    lsp.register_plugin_type(LSPEventTypes.DOCUMENT,
                             lsp_editor.sig_lsp_notification)
    # qtbot.addWidget(lsp)
    yield lsp, lsp_editor
    if os.name != 'nt':
        lsp.stop()
예제 #4
0
    def start_client(self, language):
        """Start an LSP client for a given language."""
        started = False
        if language in self.clients:
            language_client = self.clients[language]
            queue = self.register_queue[language]

            # Don't start LSP services when testing unless we demand
            # them.
            if running_under_pytest():
                if not os.environ.get('SPY_TEST_USE_INTROSPECTION'):
                    return started

            # Start client
            started = language_client['status'] == self.RUNNING
            if language_client['status'] == self.STOPPED:
                config = language_client['config']

                if not config['external']:
                    port = select_port(default_port=config['port'])
                    config['port'] = port

                language_client['instance'] = LSPClient(
                    parent=self,
                    server_settings=config,
                    folder=self.get_root_path(language),
                    language=language)

                # Connect signals emitted by the client to the methods that
                # can handle them
                if self.main and self.main.editor:
                    language_client['instance'].sig_initialize.connect(
                        self.main.editor.register_lsp_server_settings)

                logger.info("Starting LSP client for {}...".format(language))
                language_client['instance'].start()
                language_client['status'] = self.RUNNING
                for entry in queue:
                    language_client.register_file(*entry)
                self.register_queue[language] = []
        return started
예제 #5
0
파일: manager.py 프로젝트: zhuyuuc/spyder
    def start_client(self, language):
        """Start an LSP client for a given language."""
        started = False
        if language in self.clients:
            language_client = self.clients[language]
            queue = self.register_queue[language]

            # Don't start LSP services in our CIs unless we demand
            # them.
            if (os.environ.get('CI', False)
                    and not os.environ.get('SPY_TEST_USE_INTROSPECTION')):
                return started

            # Start client
            started = language_client['status'] == self.RUNNING
            if language_client['status'] == self.STOPPED:
                config = language_client['config']

                if not config['external']:
                    port = select_port(default_port=config['port'])
                    config['port'] = port

                language_client['instance'] = LSPClient(
                    parent=self,
                    server_settings=config,
                    folder=self.get_root_path(language),
                    language=language)

                for plugin in self.lsp_plugins:
                    language_client['instance'].register_plugin_type(
                        plugin, self.lsp_plugins[plugin])

                logger.info("Starting LSP client for {}...".format(language))
                language_client['instance'].start()
                language_client['status'] = self.RUNNING
                for entry in queue:
                    language_client.register_file(*entry)
                self.register_queue[language] = []
        return started