通过Homebrew在Python和Python3支持下安装Vim [英] Install Vim via Homebrew with Python AND Python3 Support

查看:74
本文介绍了通过Homebrew在Python和Python3支持下安装Vim的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Vim中启用Python自动补全功能,所以也许这不是问题.这是我观察到的:

I would like to enable Python auto-completion in Vim so maybe this is a non-issue. This is what I've observed:

首先,虚拟环境提供了能够按项目分配口译员的能力.可以同时使用Python 2.x和Python 3.x的假设.

First, Virtual Environments provides the ability to assign an interpreter on a per-project basis. The assumption being both Python 2.x AND Python 3.x could potentially be used.

我已经安装了python 2.x和python3-没问题.

通过Homebrew安装Vim时,无论发生什么情况,都仅在以下一种编译方式中支持编译器:

While installing Vim via Homebrew, no matter what happens only support support for one interpreter is compiled in:

/usr/local/bin/vim --version
...

  • + python3 -python或
  • -python3 + python
  • Q:出于实现python自动完成的目的:

    Q: for the purposes of achieving python auto-completion:

    1. 这是一个真正的问题吗?
    2. 如果是,那有什么解决方案?

    推荐答案

    同时编译或使用'dynamic'编译的Vim仅在Windows版本上可用.Mac/* nix/etc只能使用一个版本的Python.

    Vim compiled with both, or with 'dynamic' is only available on Windows versions. Mac/*nix/etc can only use one version of Python.

    解决这个问题的方法是编译两个不同的vim,每个Python版本一个,然后在我的.vimrc中创建一个版本检查以使其与它们中的两个兼容.

    My way around this was to compile two different vims, one with each Python version, and then create a version check in my .vimrc to be co-compatible with the two of them.

    if has('python')
      let g:jedi#force_py_version = 2
      let g:syntastic_python_python_exec = 'python2'
      let g:pymode_python = 'python2'
    elseif has('python3')
      let g:jedi#force_py_version = 3
      let g:syntastic_python_python_exec = 'python3'
      let g:pymode_python = 'python3'
    else
      let g:loaded_jedi = 1
    endif
    

    当然可以使用您已安装的任何特定于python的插件或功能对其进行修改.

    Modifying this with whatever python-specific plugins or function you have installed, of course.

    这篇关于通过Homebrew在Python和Python3支持下安装Vim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆