Ejemplo n.º 1
0
def show_configuration_thread(ls: AILanguageServer, *args):
    """Gets exampleConfiguration from the client settings using thread pool."""
    try:
        config = ls.get_configuration(ConfigurationParams([
            ConfigurationItem('', AILanguageServer.CONFIGURATION_SECTION)
        ])).result(2)

        example_config = config[0].exampleConfiguration

        ls.show_message(
            'AICoderServer.exampleConfiguration value: {}'.format(example_config)
        )

    except Exception as e:
        ls.show_message_log('Error ocurred: {}'.format(e))
Ejemplo n.º 2
0
Archivo: server.py Proyecto: yav3/pygls
async def show_configuration_async(ls: JsonLanguageServer, *args):
    """Gets exampleConfiguration from the client settings using coroutines."""
    try:
        config = await ls.get_configuration_async(ConfigurationParams([
            ConfigurationItem('', JsonLanguageServer.CONFIGURATION_SECTION)
        ]))

        example_config = config[0].exampleConfiguration

        ls.show_message(
            'jsonServer.exampleConfiguration value: {}'.format(example_config)
        )

    except Exception as e:
        ls.show_message_log('Error ocurred: {}'.format(e))
Ejemplo n.º 3
0
def show_configuration_callback(ls: JsonLanguageServer, *args):
    """Gets exampleConfiguration from the client settings using callback."""
    def _config_callback(config):
        try:
            example_config = config[0].exampleConfiguration

            ls.show_message('jsonServer.exampleConfiguration value: {}'.format(
                example_config))

        except Exception as e:
            ls.show_message_log('Error ocurred: {}'.format(e))

    ls.get_configuration(
        ConfigurationParams(
            [ConfigurationItem('', JsonLanguageServer.CONFIGURATION_SECTION)]),
        _config_callback)
Ejemplo n.º 4
0
async def _load_client_config_async(server: GalaxyToolsLanguageServer) -> None:
    """Loads the client configuration from user or workspace settings and updates
    the language server configuration.

    Args:
        server (GalaxyToolsLanguageServer): The language server instance.
    """
    try:
        config = await server.get_configuration_async(
            ConfigurationParams(
                [ConfigurationItem(section=GalaxyToolsConfiguration.SECTION)]))
        server.configuration = GalaxyToolsConfiguration(config[0])
    except BaseException as err:
        server.configuration = GalaxyToolsConfiguration()
        server.show_message_log(f"Error loading configuration: {err}")
        server.show_message(
            "Error loading configuration. Using default settings.",
            MessageType.Error)
Ejemplo n.º 5
0
def _get_client_config(ls: Server):
    config = ls.get_configuration(ConfigurationParams([
        ConfigurationItem(section=Server.CONFIG_SECTION)
    ])).result()
    return config[0]