Switch Python Version for Vim & Syntastic

后端 未结 8 1134
忘了有多久
忘了有多久 2020-12-24 05:15

Is it possible to change the python version used by syntastic for syntax checking?

As the Issue https://github.com/scrooloose/syntastic/issues/385 indicates I could

8条回答
  •  无人及你
    2020-12-24 05:50

    If you working under virtualenv, you can use a script that detects current python version and invokes flake8 accordingly. Put the following somewhere in your path and name is flake8.sh:

    #!/bin/sh
    PYMAJOR=$(python --version | awk '{print $2}'| awk -F. '{print $1}')
    exec "/usr/bin/python$PYMAJOR" /usr/bin/flake8 "$@"
    

    Now in you vimrc add:

    let g:syntastic_python_flake8_exe='flake8.sh'
    

    Also make sure that both python-flake8 and python3-flake8 (on Ubuntu) are installed.

提交回复
热议问题