Пример #1
0
def add_spec(spec: str) -> Do:
    yield NS.lift(present_venv(name))
    yield NS.lift(variable_set_prefixed('interpreter', '/usr/bin/python3.7'))
    yield NS.lift(variable_set_prefixed('debug_pythonpath', True))
    yield request('cram', spec, name=name)
    data = yield NS.inspect(lambda a: a.data)
    return k(data.venvs).must(contain(name)) & k(data.active).must(contain(target))
Пример #2
0
def hs_spec() -> Do:
    yield NS.lift(variable_set_prefixed('autostart', True))
    yield request('cram',
                  f'hs:nvim-hs-ghcid',
                  name='nvim-hs-ghcid',
                  track=False)
    yield NS.lift(wait_for_command('GhcidStart', timeout=1))
    return k(1) == 1
Пример #3
0
def python_path_spec() -> Do:
    dir = fixture_path('rplugin', 'path_spec')
    extra_path_pkg = fixture_path('rplugin', 'extra_path_pkg')
    yield NS.lift(variable_set_prefixed('autostart', True))
    yield request('cram',
                  f'dir:{dir}',
                  name='path_spec',
                  pythonpath=[extra_path_pkg])
    result = yield NS.lift(call_once_defined('PathSpecTest', timeout=10))
    return k(result) == 13
Пример #4
0
def deactivate_rplugin(active_rplugin: ActiveRplugin) -> Do:
    rplugin = active_rplugin.rplugin
    meta = active_rplugin.meta
    cname = camelcaseify(rplugin.name)
    rpc_triggers_fun = f'{cname}RpcTriggers'
    triggers = yield NS.lift(nvim_call_json(rpc_triggers_fun))
    yield NS.modify(lambda a: a.deactivate_rplugin(meta))
    yield NS.lift(stop_rplugin(rplugin.name, meta.channel, triggers))
    log.debug(f'deactivated {active_rplugin}')
    yield NS.pure(None)
Пример #5
0
def one_spec() -> Do:
    yield NS.lift(present_venv(name))
    yield update_data(
        rplugins=List(rplugin),
        venvs=List(name),
        active=List(active_rplugin),
        ready=List(name),
    )
    yield request('update', 'flagellum')
    log_buffer = yield NS.inspect(lambda a: a.data.log_buffer)
    return k(log_buffer).must(
        contain(Echo.info(resources.updated_plugin(rplugin.name))))
Пример #6
0
def extension_spec() -> Do:
    dir = fixture_path('rplugin', name)
    extension_path = fixture_path('rplugin', ext_name)
    yield NS.lift(variable_set_prefixed('autostart', True))
    yield NS.lift(variable_set(f'{name}_components', List(f'{ext_name}.ext')))
    yield request('cram',
                  f'dir:{dir}',
                  name='extension_spec',
                  extensions=[extension_path])
    result1 = yield NS.lift(call_once_defined('XTest', timeout=1))
    result2 = yield NS.lift(call_once_defined('XExtTest', timeout=1))
    return (k(result1) == 13) & (k(result2) == 23)
Пример #7
0
def bootstrap_result(result: List[Either[str, str]]) -> Do:
    def split(z: Tuple[List[str], List[Venv]],
              a: Either[str, Venv]) -> Tuple[List[str], List[Venv]]:
        err, vs = z
        return a.cata((lambda e: (err.cat(e), vs)), (lambda v:
                                                     (err, vs.cat(v))))

    errors, venvs = result.fold_left((Nil, Nil))(split)
    ribo_log.debug(f'bootstrapped venvs: {venvs}')
    yield venvs.traverse(add_venv, State).nvim
    yield NS.modify(store_errors(errors))
    yield NS.error(f'failed to setup venvs: {errors.map(str).join_comma}'
                   ) if errors else NS.unit
Пример #8
0
def install_plugins_procs(names: List[str], update: Boolean) -> Do:
    action = 'updating' if update else 'installing'
    log.debug(f'{action} rplugins: {names}')
    rplugins = yield installable_rplugins_from_names(names)
    procs = yield NS.lift(
        rplugins.traverse(lambda a: install_rplugin_subproc(a)(a.meta),
                          NvimIO))
    return GatherSubprocesses(procs, timeout=600)
Пример #9
0
def bootstrap_rplugins_io() -> Do:
    vr = yield installable_plugins()
    dir = yield Ribo.setting(venv_dir)
    global_interpreter = yield Ribo.setting_raw(interpreter)
    ios = yield vr.traverse(
        lambda a: bootstrap_rplugin(a, dir, global_interpreter.to_maybe)
        (a.meta), NS)
    yield NS.pure(GatherIOs(ios, timeout=30))
Пример #10
0
def install_plugins_result(
    results: List[Either[IOException, SubprocessResult[str]]]
) -> NS[Env, Tuple[List[SubprocessResult[str]], List[str]]]:
    venvs = results.flat_map(lambda a: a.cata(ReplaceVal(Nil), List))
    errors = results.flat_map(lambda a: a.cata(List, ReplaceVal(Nil)))
    log.debug(f'installed plugins: {venvs}')
    if errors:
        log.debug(f'error installing plugins: {errors}')
    return NS.pure((venvs, errors))
Пример #11
0
def crm_rplugin_spec() -> Do:
    temp_dir('rplugin', 'venv', name, 'lib', 'python3.7')
    yield request('init')
    data = yield NS.inspect(lambda a: a.data)
    rplugin = data.chromatin_rplugin.to_either('no chromatin rplugin')
    venv = data.chromatin_venv.to_either('no chromatin venv')
    return (
        k(rplugin).must(be_right(DistRplugin.cons('chromatin', 'chromatin')))
        & k(venv).must(eq(rplugin / _.name)))
Пример #12
0
 def dir(self, rplugin: DirVenvRplugin) -> Do:
     venv = yield NS.lift(venv_from_rplugin(self.rplugin))
     args = List('-c', f'import {self.rplugin.name}')
     path = join_pythonpath(self.rplugin.pythonpath.cons(rplugin.dir))
     return GatherSubprocess(
         Subprocess(str(venv.meta.python_executable),
                    args,
                    self.rplugin.name,
                    timeout=1,
                    env=dict(PYTHONPATH=path)))
Пример #13
0
def stage_4() -> NS[None, None]:
    return NS.simple(ribo_log.info, f'{name} initialized')
Пример #14
0
def test() -> NS[None, None]:
    return NS.simple(ribo_log.info, f'{name} working')
Пример #15
0
def stage_2() -> NS[None, None]:
    return NS.lift(variable_set('flag', 2))
Пример #16
0
def one_spec() -> Do:
    yield update_data(rplugins=List(rplugin))
    yield request('show_plugins')
    log_buffer = yield NS.inspect(lambda a: a.data.log_buffer)
    return k(log_buffer).must(
        contain(Echo.info(resources.show_plugins(dir, List(rplugin)))))
Пример #17
0
def stage_1() -> NS[None, None]:
    return NS.lift(variable_set('cil', 2))
Пример #18
0
def activation_complete() -> Do:
    rplugins = yield NS.inspect_either(lambda a: a.uninitialized_rplugins)
    tracked = rplugins.filter(lambda a: a.rplugin.track)
    failed = yield NS.lift(initialize_plugins(tracked))
    yield NS.modify(lambda a: a.initialization_complete(failed))
Пример #19
0
def activated(active_rplugin: ActiveRplugin) -> Do:
    log.debug(f'activated {active_rplugin}')
    spec = active_rplugin.rplugin
    yield NS.lift(runtime(f'chromatin/{spec.name}/*'))
    yield NS.modify(lambda a: a.host_started(active_rplugin.meta))
Пример #20
0
def activate_multi(new_rplugins: List[Rplugin]) -> Do:
    active = yield Ribo.zoom_main(
        NS.inspect_either(lambda a: a.active_rplugins))
    active_rplugins = active.map(lambda a: a.rplugin)
    already_active, inactive = new_rplugins.split(active_rplugins.contains)
    yield inactive.traverse(activate_rplugin, NS).replace(already_active)
Пример #21
0
 def hackage(
         self, a: HsHackageRplugin
 ) -> NS[CrmRibosome, GatherItem[Tuple[str, bool]]]:
     exe = cabal_rplugin_executable(self.rplugin)
     return NS.pure(GatherIO(IO.pure((self.rplugin.name, exe.is_file()))))
Пример #22
0
def read_conf() -> Do:
    plugin_conf = yield Ribo.setting(rplugins)
    specs = plugin_conf.traverse(Rplugin.from_config, Either)
    yield NS.from_either(specs)
Пример #23
0
 def dist(self, rplugin: DistVenvRplugin) -> Do:
     venv = yield NS.lift(venv_from_rplugin(self.rplugin))
     return GatherIO(
         venv_package_installed(venv).map(lambda status:
                                          (self.rplugin.name, status)))
Пример #24
0
def activate_by_names(plugins: List[str]) -> Do:
    getter = (lambda a: a.ready_rplugins) if plugins.empty else (
        lambda a: a.ready_by_name(plugins))
    rplugins = yield Ribo.zoom_main(NS.inspect_either(getter))
    yield (NS.error(resources.no_plugins_match_for_activation(plugins))
           if rplugins.empty else activate_multi(rplugins))
Пример #25
0
def quit() -> NS[None, None]:
    return NS.lift(variable_set('quit', 1))
Пример #26
0
def activate_newly_installed() -> Do:
    new = yield Ribo.zoom_main(NS.inspect_either(lambda a: a.inactive))
    yield activate_multi(new)
    yield Ribo.zoom_main(activation_complete())
Пример #27
0
def vim_enter() -> NS[None, None]:
    return NS.simple(ribo_log.info, 'autocmd works')
Пример #28
0
 def dir(self, a: HsStackDirRplugin
         ) -> NS[CrmRibosome, GatherItem[Tuple[str, bool]]]:
     return NS.pure(GatherIO(IO.pure((self.rplugin.name, False))))
Пример #29
0
def activate_rplugin(rplugin: Rplugin) -> Do:
    active_rplugin = yield NS.lift(activate_rplugin_io.match(rplugin))
    yield Ribo.zoom_main(activated(active_rplugin))
Пример #30
0
def deactivate_by_names(plugins: List[str]) -> Do:
    getter = (lambda a: a.active_rplugins) if plugins.empty else (
        lambda a: a.active_rplugins_by_name(plugins))
    rplugins = yield NS.inspect_either(getter)
    yield (NS.error(resources.no_plugins_match_for_deactivation(plugins))
           if rplugins.empty else deactivate_multi(rplugins))