Ejemplo n.º 1
0
def choose_environment():
    args = shsplit(vim.eval('a:args'))

    envs = list(jedi.find_system_environments())
    envs.extend(jedi.find_virtualenvs(paths=args or None))

    env_paths = [env.executable for env in envs]

    vim_command('belowright new')
    vim.current.buffer[:] = env_paths
    vim.current.buffer.name = "Hit Enter to Choose an Environment"
    vim_command(
        'setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted readonly nomodifiable'
    )
    vim_command('noremap <buffer> <ESC> :bw<CR>')
    vim_command(
        'noremap <buffer> <CR> :python3 jedi_vim.choose_environment_hit_enter()<CR>'
    )
Ejemplo n.º 2
0
def select_env():
    items = list(jedi.find_system_environments())
    names = [repr(i).replace('Environment:', 'Python') for i in items]
    names.append('Other...')
    i = ct.dlg_menu(ct.MENU_LIST, names, caption='Select Python interpreter')
    if i is None:
        return
    elif i == len(names) - 1:
        filters = 'Executables|*.exe' if IS_NT else ''
        fn = ct.dlg_file(True, '!', '', filters)
        if not fn:
            return
    else:
        fn = items[i].executable
    env = create_env(fn)
    if env:
        ct.ini_write(cfg_file, cfg_section, cfg_opt_env, fn)
        return env