ãï¼åãã£ãã Python ã®ãã¼ã¸ã§ã³ç®¡çã« pyenv 使ã£ã¦ãã®ã« Vim ã®è£å®ã¯ã·ã¹ãã ã©ã¤ãã©ãªåç §ãã¦ãã®ï¼
ã©ããããç¡æ²æ±°ãã¦ã¾ãææ«ã§ãã Pythonistaãªãpyenvã ããã¼ã£ã¦ãã¨ã§å½åããããªããªä½¿ããã¦ããã ãã¦ããã®ã§ãããæè¿djangoã®ããã¸ã§ã¯ããæ¸ãéã«å°ã£ãã®ã§ã¾ã¨ãã¦ããã¾ãã å ·ä½çã«ã¯pyenvã§Pytho 3ãã¤ã³ã¹ãã¼ã«ããpyenv-virtualenvãç¨ãã¦ä»®æ³ç°å¢ãæ§ç¯ãããã®ä»®æ³ç°å¢ã« django ãã¤ã³ã¹ãã¼ã«ããã ãã§ã¯ jedi-vim ã®è£å®ãå¹ããªãã¨ããåé¡ã§ãã ããã¤ãã®è¦å ãè¤åãã¦è¤éã«æã£ã¦ããã®ã§ãã²ã¨ã¤ãã¤ã¡ã¢ãã¦ããã¾ãã
å¿ãã人ã®ããã®ç°¡ææ¸
æ®æ®µããpyenvã¨pyenv-virtualenvã使ç¨ãã¦ãã¦jedi-vimã§djangoã®è£å®ãå¹ããªãã¦å°ã£ã¦ããã
ã¨ã«ããè£å®ãå¹ããããã
æ¯è¨ãªãã¦ã©ãã§ãããã¨ãã人ã¯ä¸è¨ã~/.vimrc
ã«è¨è¼ãã¦ãã ããã
" ~/.pyenv/shimsã$PATHã«è¿½å " jedi-vim ã vim-pyenc ã®ãã¼ããããå ã«è¡ãå¿ è¦ããããã¯ãã let $PATH = "~/.pyenv/shims:".$PATH " ... neobundle.vim åæåç " DJANGO_SETTINGS_MODULE ãèªåè¨å® NeoBundleLazy "lambdalisue/vim-django-support", { \ "autoload": { \ "filetypes": ["python", "python3", "djangohtml"] \ }} " è£å®ç¨ã« jedi-vim ã追å NeoBundle "davidhalter/jedi-vim" " pyenv å¦çç¨ã« vim-pyenv ã追å " Note: depends ãæå®ããã¦ãããã jedi-vim ããå¾ã«ãã¼ããããï¼ãã¨ãæå¾ ï¼ NeoBundleLazy "lambdalisue/vim-pyenv", { \ "depends": ['davidhalter/jedi-vim'], \ "autoload": { \ "filetypes": ["python", "python3", "djangohtml"] \ }} " ... neobundle.vim çµäºå¦çç
ããã«ããç¾å¨ä½¿ç¨ãã¦ããï¼pyenvæ¹å¼ï¼ã® virtualenv ãèªåçã«Vimä¸ã§é©ç¨ãã¾ãã
æåã«ãã virtualenv ã®é©ç¨ã»è§£é¤ã¯ãããã :PyenvActivate
㨠:PyenvDeactivate
ã§è¡ãã¾ãã
ã¾ã DJANGO_SETTINGS_MODULE
ãèªåçã«è¨å®ãããããã«ãªã£ãã®ã§ãjedi-vimã«ããdjangoã®è£å®ãå¹ãã¾ãã
ãªãneobundle.vimã使ã£ã¦ãããã¨ãåæã§æ¸ãã¦ãã¾ããã以ä¸ã®äºç¹ã«æ°ãã¤ãã¦ããã°ä»ã®æ¹æ³ã§ãæ§ãã¾ããã
- jedi-vimãvim-pyenvãèªã¿è¾¼ã¾ããåã«
~/.pyenv/shims
ï¼ãããã¯ããã«æºãããã£ã¬ã¯ããªï¼ã$PATH
ã«å ãã£ã¦ãã - vim-pyenvã¯jedi-vimãããå¾ã«ãã¼ãããã
æ®éã®virtualenvã使ç¨ãã¦ããå ´åã¯Vimãæå¼·ã®Pythonéçºç°å¢ã«ãã2ã«ç¿ã£ã¦vim-pyenvã®ä»£ããã«vim-virtualenvã使ç¨ãã¦ãã ããã
Python2ãããã¯Python3ã®ã¿ã使ç¨ããå ´å
pyenvã¨pyenv-virtualenvã¯ä½¿ã£ã¦ãããPython2ãPython3ãã使ããªãã¨ããæ¹åãã®æ¹æ³ã§ãã ãã ãä½åº¦ãåãäºã説æããã®ãé¢åãªã®ã§ãPython2ã¨Python3ã©ã¡ãã使ç¨ãã人ãåãè¨å®ãæ½ãã¦ãã ããã
Vimã§ã¤ã³ã¹ãã¼ã«ããã©ã¤ãã©ãªãªã©ãä¸é¨ã®è£å®ãå¹ããªãå ´åã¨ããã®ã¯é常 sys.path
ã®è¨å®ãé©åã§ãªãããã«çºçãã¾ãã
Vimã¯å
é¨ã§ç¬èªã«Pythonã®å®è¡ç°å¢ãæã£ã¦ãããããTerminalä¸ã§ããã pyenv virtualenv Hello; pyenv local Hello
ãªã©ã¨ãã¦ãç¡é§è¶³ã¨ãªãã¾ãã
ããã§Vimã®å
é¨Pythonã® sys.path
ãé©åã«æ¸ãæãã¦ããããã«æåå³åã§ãã vim-pyenv ã¨ãããã©ã°ã¤ã³ãå©ç¨ãã¾ãã
vim-pyenv 㯠pyenv local Hello
ãªã©ã®ã³ãã³ãã«ããé©ç¨ãããå¤æ´ãèªåçã«èªã¿åããVimå
é¨ã®Pythonã«é©ç¨ãã¾ãã
ããã«ãã Hello
ã«ã¤ã³ã¹ãã¼ã«ãããã©ã¤ãã©ãªãæ¤ç´¢ãã¹ã«å«ã¾ããããã«ãªããã jedi-vim ã§ã®è£å®ãå¯è½ã¨ãªãã¾ãã
ã¾ã django ã®ã±ã¼ã¹ã§ãããè£å®ãå¹ããªãæã大ããªçç±ã¯ DJANGO_SETTINGS_MODULE
ãé©åã«è¨å®ããã¦ããªããã¨ã§ãã
django ã®ä¸é¨ã®ã¢ã¸ã¥ã¼ã«ï¼ä¾ django.db
ï¼ã¯èªã¿è¾¼ãéã« DJANGO_SETTINGS_MODULE
ã®å¤ã使ç¨ãã¦èªèº«ã®è¨å®ã³ã¼ããå¼ã³åºãã¾ãã
ãããã£ã¦ DJANGO_SETTINGS_MODULE
ãè¨å®ããã¦ããªããä¸é©åãªå ´å㯠jedi-vim ã®ãããªãã¢ã¸ã¥ã¼ã«ããã¼ããã¦è£å®ãªã¹ããçµã¿ä¸ããã¿ã¤ããã®ãã©ã°ã¤ã³ã§ã¯ãé©åã«è£å®ãªã¹ããçµããè£å®ãã§ããªããªãã¾ãã
é©åã« DJANGO_SETTINGS_MODULE
ãè¨å®ããã®ã¯éª¨ãæããã®ã§ããããæåå³åã§ãã vim-django-support ã¨ãããã©ã°ã¤ã³ãå©ç¨ãã¾ãã
ãæ³åéãããã®ãã©ã°ã¤ã³ã¯ç¶æ³ã«ããé©åã« DJANGO_SETTINGS_MODULE
ãè¨å®ããããã®ãã®ã§ãã
æå¾ã« pyenv ã使ç¨ããéã®æ³¨æã§ãã
pyenv ã使ç¨ããå ´åPythonã®å®è¡ãã¹ã¯ ~/.pyenv/shims/python
ã¨ãªãããã㯠pyenv init
ã«ãã PATH
ãé©åã«è¨å®ãããããã«å®ç¾ãã¾ãã
ããã Vim ã¯ç¬èªã« PATH
ãæã£ã¦ããããããã®ã¾ã¾ã§ã¯ pyenv ã®Pythonãåç
§ãããã¨ãã§ãã¾ããã
ãããã£ã¦ä¸è¨ã®ããã« PATH
ãæ¸ãæãã¦ããå¿
è¦ãããã¾ãã
let PATH = expand("~/.pyenv/shims") . ":" . $PATH
ãã ãããã®ã¾ã¾ã 㨠~/.vimrc
ã®ãªãã¼ããªã©ã«ãã PATH
ãåããã¨ã«ãªã£ã¦ãã¾ãã®ã§ä¸è¨ã®ãããªé¢æ°ãä½ã£ã¦ç»é²ããããã«ãã¾ãããã
" PATHã®èªåæ´æ°é¢æ° " | æå®ããã path ã $PATH ã«åå¨ããããã£ã¬ã¯ããªã¨ãã¦åå¨ãã¦ããå ´å " | ã®ã¿ $PATH ã«å ãã function! IncludePath(path) " define delimiter depends on platform if has('win16') || has('win32') || has('win64') let delimiter = ";" else let delimiter = ":" endif let pathlist = split($PATH, delimiter) if isdirectory(a:path) && index(pathlist, a:path) == -1 let $PATH=a:path.delimiter.$PATH endif endfunction " ~/.pyenv/shims ã $PATH ã«è¿½å ãã " ãããè¡ããªãã¨pythonãæ£ããæ¤ç´¢ãããªã IncludePath(expand("~/.pyenv/shims"))
ãã®è¨å®ã¯Pythonãæ±ããã©ã°ã¤ã³ãèªã¿è¾¼ã¾ããåã«è¡ãå¿
è¦ãããã¾ãã
ãããã£ã¦ ~/.vimrc
ã®å
é ãããã«æ¸ãã¦ããã¨ããã§ãããã
ä¸è¨ãè¸ã¾ãã ~/.vimrc
ã¯ä¸è¨ã®ããã«ãªãã¾ãããªã neobundle.vim ã使ç¨ãããã¨ãåæã¨ãã¦ãã¾ããä»ã®ããã±ã¼ã¸ããã¼ã¸ã£ãç¨ãã¦ãæ§ãã¾ããã
" ... çç¥ " PATHã®èªåæ´æ°é¢æ° " | æå®ããã path ã $PATH ã«åå¨ããããã£ã¬ã¯ããªã¨ãã¦åå¨ãã¦ããå ´å " | ã®ã¿ $PATH ã«å ãã function! IncludePath(path) " define delimiter depends on platform if has('win16') || has('win32') || has('win64') let delimiter = ";" else let delimiter = ":" endif let pathlist = split($PATH, delimiter) if isdirectory(a:path) && index(pathlist, a:path) == -1 let $PATH=a:path.delimiter.$PATH endif endfunction " ~/.pyenv/shims ã $PATH ã«è¿½å ãã " ãããè¡ããªãã¨pythonãæ£ããæ¤ç´¢ãããªã IncludePath(expand("~/.pyenv/shims")) " ... neobundle.vim åæåç " DJANGO_SETTINGS_MODULE ãèªåè¨å® NeoBundleLazy "lambdalisue/vim-django-support", { \ "autoload": { \ "filetypes": ["python", "python3", "djangohtml"] \ }} " è£å®ç¨ã« jedi-vim ã追å NeoBundleLazy "davidhalter/jedi-vim", { \ "autoload": { \ "filetypes": ["python", "python3", "djangohtml"] \ }} " pyenv å¦çç¨ã« vim-pyenv ã追å " Note: depends ãæå®ããã¦ãããã jedi-vim ããå¾ã«ãã¼ãããã NeoBundleLazy "lambdalisue/vim-pyenv", { \ "depends": ['davidhalter/jedi-vim'], \ "autoload": { \ "filetypes": ["python", "python3", "djangohtml"] \ }} " ... neobundle.vim çµäºå¦çç
vim-pyenv ã¯ããã©ã«ãã§ç¾å¨é¸æããã¦ãã virtualenv ãé©ç¨ãã¾ãã
virtualenvãã®åãæ¿ã㯠:PyenvActivate
㨠:PyenvDeactivate
ã§è¡ãã¾ãã
ãã®ãããã®è©³ãã説æ㯠:help vim-pyenv
ãã覧ãã ããã
Python2ã¨Python3ã©ã¡ãã使ç¨ããå ´å
ä½åº¦ãåãäºã説æããã®ãé¢åãªã®ã§ãåç« ãèªãã§ããªãããã¯ãã¾ãåç« ã¨åãè¨å®ãæ½ãã¦ãã ããã
pyenv ã使ãä¸çªã®ã¡ãªããã¯Pythonã®ãã¼ã¸ã§ã³ãç°¡åã«åãæ¿ãããããã¨ã ã¨æãã¾ãã
ãã®ã¡ãªãããæ大éã«Vimã§æ´»ããããã«ã¯ãVimã +python/+python3
ã§ã³ã³ãã¤ã«ããã¦ããå¿
è¦ãããã¾ãã
ãã®ç¢ºèªã¯ vim --version
ã使ã£ã¦ä»¥ä¸ã®ããã«è¡ãã¾ãã
$ vim --version VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 20 2014 18:20:07) é©ç¨æ¸ããã: 1-295 Compiled by alisue@alisue-labdesk é常 ç with GTK2-GNOME GUI. æ©è½ã®ä¸è¦§ æå¹(+)/ç¡å¹(-) ...ç¥... +cryptv +linebreak +python/dyn +viminfo +cscope +lispindent +python3/dyn +vreplace ...ç¥...
å®è¡çµæã®ä¸ã« +python/dyn
㨠+python3/dyn
ã¨ããæåãããã¾ãããããã +python/+python3
ã®ç¶æ
ã§ãã
ã©ã¡ããã®é ã« -
ãã¤ãã¦ããå ´åã¯ãæ®å¿µãªããPython2ãPython3ã®ã©ã¡ãããæ£ããæ©è½ãã¾ããã
ã¾ã確èªãé¢åãããã®ã§è¡ãªã£ã¦ãã¾ããã /dyn
ã¨ããæåãã¤ãã¦ããªãå ´åã¯ã©ã¡ããã使ããªãããããã¾ããï¼è¦åºå
¸ï¼ã
ã©ã¡ãã使ãããã©ãã確èªããã«ã¯ãVimãèµ·åãã¦ä¸è¨äºã¤ã®ã³ãã³ãã§æ£ããå¤ã帰ã£ã¦ãããã¨ã確èªãã¦ãã ããã
:python print(sys.version) :python3 print(sys.version)
Macã¦ã¼ã¶ã¼ã®æ¹ã¯Mac-Vim-Kaoriyaã®ãã¤ããªã+python/+python3
ãªãããªã®ã§ãããå©ç¨ããã°è¯ãããã§ãï¼æªç¢ºèªï¼ã
Linuxã¦ã¼ã¶ã¼ã®æ¹ã§ +python/+python3
ã§ã¯ç¡ãã£ãæ¹ã¯ä¸è¨æ¹æ³ã«ãããã£ã¦ pyenv ã§ã¤ã³ã¹ãã¼ã«ãã Python2, Python3 ãåç
§ããVimãã³ã³ãã¤ã«ããªããã¦ãã ããã
Vimã+python/+python3ã§ã³ã³ãã¤ã«
é常Vimã¯Pythoã¨éçãªã³ã¯ãã¾ãããPython 2,3 ãå
±åããããå ´åã¯åçãªã³ã¯ã«ããå¿
è¦ãããã¾ãã
詳ãããã¨ã¯å²æãã¾ãããåçãªã³ã¯ãå¯è½ã«ããããã«--enable-shared
ãªãã·ã§ã³ãæå®ãã¦Pythonãã³ã³ãã¤ã«ãããå¿
è¦ãããã¾ãã
pyenv ã§ãã®ãªãã·ã§ã³ãæå®ã㦠Python2, 3 ãã¤ã³ã¹ãã¼ã«ãã¾ãã
ä¸è¨ã«å¾ã£ã¦ãã ããã
ãªããæ£ãã --enable-shared
ã§ã¤ã³ã¹ãã¼ã«ããããã©ãã㯠libpython2.7.so.1.0
ã libpython3.4m.so.1.0
ã $HOME/.pyenv/versions/XXXX/lib/
ã®ä¸ã«çæããã¦ãããã©ããã§ç¢ºããããã¨ãã§ãã¾ãã
$ CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.6 $ CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.0
次ã«ãã®äºã¤ã® Python ããªã³ã¯ãããVimãã³ã³ãã¤ã«ãã¾ãã ã¾ãã¯æ£ãã Python 2, 3 ãæ¢ããããã«ä¸è¨ã®ããã«åæã«äºã¤ã®ãã¼ã¸ã§ã³ãæå®ãã¾ã
$ pyenv local --unset $ pyenv shell --unset $ pyenv global 2.7.6 3.4.0 $ pyenv versions system * 2.7.6 (set by /home/XXXX/.pyenv/version) * 3.4.0 (set by /home/XXXX/.pyenv/version) XXXXX $ python --version Python 2.7.6 $ python3 --version Python 3.4.0
ããã¾ã§ã§å©ç¨ãã Python ã®ã¤ã³ã¹ãã¼ã«ãçµãã£ãã®ã§ã³ã³ãã¤ã«ãã Vim ã®ã½ã¼ã¹ã³ã¼ãã Marcurial ã§ã¬ãã¸ããªããè½ã¨ãã¦ãã¾ãã ä¸è¨ã«å¾ã£ã¦ãã ãã
$ hg clone https://code.google.com/p/vim/
$ cd vim
ããã§é©åãªãªãã·ã§ã³ãä»å ã㦠./configure {options}
ããã° Vim ã®ã³ã³ãã¤ã«ãè¡ããã¾ãããåçãªã³ã¯ã§ããããåºæ¥ä¸ãã£ããã¤ããªãã¡ã¤ã«ã pyenv ã§ã¤ã³ã¹ãã¼ã«ãã Python ãè¦ã¤ãããã¨ãã§ãã¾ããã
LD_LIBRARY_PATH
ãªã©ã§ãªã³ã¯å
ãæå®ãã¦ãè¯ãã®ã§ãããã¤ããªåºæã®ã©ã¤ãã©ãªæ¤ç´¢ãã¹ã¨ã㦠-rpath
ãªãã·ã§ã³ãããã®ã§ããããç¨ãã¦ä¸è¨ã®ããã«ã©ã¤ãã©ãªæ¤ç´¢ãã¹ãæå®ãã¾ãã
ãªãä¸è¨ãããªãã·ã§ã³ã¯ãã¹ã¦ ./configure --help
ã«è§£èª¬ãæ¸ãã¦ããã®ã§å¿
è¦ã«å¿ãã¦è¿½å ã»åé¤ãã¦ãã ããã
$ LDFLAGS="-Wl,-rpath=${HOME}/.pyenv/versions/2.7.6/lib:${HOME}/.pyenv/versions/3.4.0/lib" ./configure \ --enable-fail-if-missing \ --enable-luainterp \ --enable-perlinterp \ --enable-pythoninterp=dynamic \ --enable-python3interp=dynamic \ --enable-tclinterp \ --enable-rubyinterp=yes \ --enable-multibyte \ --enable-fontset \ --enable-gui=gnome2 \ --with-features=huge \ --with-luajit $ make
ãã㧠src/vim
ã«ãã¤ããªãã¡ã¤ã«ãä½æãããã®ã§ srv/vim --version
ãå®è¡ã㦠+python/+python3
ãªãã¤ããªãåºæ¥ä¸ãã£ããã確èªãã¦ãã ããã
ã¾ã -rpath
ãé©åã«è¨å®ããããã©ãã㯠readelf -d srv/vim
ã§è¡¨ç¤ºããã Library rpath:
ã«ã¦ç¢ºèªãããã¨ãã§ãã¾ãã
æå¾ã«å¿µã®çºVimãèµ·åããä¸è¨ã³ãã³ã㧠Python 2, 3 åæ¹ãå®è¡ã§ãããã¨ã確èªã㦠sudo make install
ãã¦ãã ããã
:python print(sys.version) :python3 print(sys.version)
åè
- Can't figure out how to build a python that uses the .SO file #65
- Debianç³»ã®Linuxã§Python 2.xã¨3.xãåæå©ç¨ã§ããªãåé¡ã®åå ã¨å¯¾ç #301
+python/+python3 ã§ãªããã°è¡ããªãçç±
ã¨ããããä½æ
ãã®æ§ãªé¢åãªãã¨ãããå¿
è¦ãåã£ããã«ã¤ãã¦ç°¡åã«èª¬æãã¾ãã
ãåç¥ã®éã Python ã«ã¯ 2x ç³»å㨠3x ç³»åãåå¨ãã¾ãã
両è
ã¯æ§æã¬ãã«ã§ã®äºææ§ãæ¨ã¦ã¦ãããããPython2ã®ã³ã¼ããPython3ã§èªããã¾ããã®éãåºæ¥ã¾ããã
ãã¦ããã㧠pyenv ã使ç¨ãã㨠Python2 㨠Python3 ãç°¡åã«åãæ¿ãããã¨ãã§ãã¾ãã
ããã«è¨ãã° pyenv-virtualenv ã使ç¨ããã¨ãã¼ã¹ã Python2 ã Python3 ã®æ§ã
ãªä»®æ³ç°å¢ãæ§ç¯ãããã¨ãã§ãã¾ãã
ãã®ãããè£å®ãå¹ãããããããã«ç¡çãã sys.path
ã PYTHONPATH
ãæ¸ãæãã㨠Python3 㧠Python2 ã®ã©ã¤ãã©ãªãèªã¿è¾¼ããã¹ãçºçããåµã®å¦ãã¨ã©ã¼ã«è¦èããããã¨ã«ãªãã¾ãã
ãããã£ã¦ãè£å®ãã©ã°ã¤ã³ã¯èªã¿è¾¼ãã©ã¤ãã©ãªãã©ã¡ãã«åããã©ã¤ãã©ãªãªã®ããææ¡ããé©åã«ä½¿ç¨ããPythonãé¸æããå¿
è¦ãããã¾ãã
ãããåãããã¨ã¯æãã¾ããããã®åãæ¿ããè¡ãããã«ã¯ Vim ã +python/+python3
ã§ã³ã³ãã¤ã«ããã¦ããå¿
è¦ããã£ãã®ã§ãé¢åã§ããä¸è¨ã®ãããªæé ããµã¿ã¾ããã
ã¡ãªã¿ã«ããã® Python2/3 ã®åãæ¿ãã«å¯¾å¿ãã¦ããè£å®ãã©ã°ã¤ã³ã¯ãåãç¥ãéãã§ã¯ jedi-vim ã®ã¿ã§ãã ãã ãããã®jedi-vimã¯ã¦ã¼ã¶ã¼ãäºåã«è¨å®ããPython2/3ã使ç¨ãã¦è£å®ã試ã¿ãã ããªã®ã§ãä»®æ³ç°å¢ãåãæ¿ããã ãã§ã¯å ã®åé¡ã解決ã§ãã¾ããã ãããã£ã¦ vim-pyenv ã§ã¯é¸æãããä»®æ³ç°å¢ã«å¿ãã¦é©åã«èªèº«ã¨ jedi-vim ã使ç¨ããPythonã®ãã¼ã¸ã§ã³ãåãæ¿ããè¨è¨ã«ãªã£ã¦ãã¾ãã
vim-pyenv ã使ç¨ãã¦åçã«ä»®æ³ç°å¢ã¨ä½¿ç¨Pythonãåãæ¿ãã
vim-pyenv ã +python/+python3
㪠Vim ã«ã¤ã³ã¹ãã¼ã«ãããã¨èªå㧠Python ã®ãã¼ã¸ã§ã³åãæ¿ãæ©è½ãæå¹åããã¾ãã
ãã¹ã¦ã®å¦çãããã¯ã°ã©ã¦ã³ãã§è¡ãããã®ã§é常ã¯æèããå¿
è¦ãããã¾ããããä»åã¯ç¢ºèªãå
¼ãã¦ä¸ã¤ã¥ã¤ã¹ããããè¸ãã§ããã¾ãã
ã¾ã㯠Python 2/3 ããããããã¼ã¹ã¨ããä»®æ³ç°å¢ django2/3 ãä½æããããããã«djangoãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ pyenv virtualenv 2.7.6 django2 $ pyenv virtualenv 3.4.0 django3 $ pyenv shell django2 $ pip install django $ pyenv shell django3 $ pip install django $ pyenv rehash
ãã㧠Vim ãèµ·åãã㨠vim-pyenv, jed-vim ã使ç¨ãã Python ã®ãã¼ã¸ã§ã³ã¯ä¸è¨ã®ããã«å¤é¨ã® Python ã®ãã¼ã¸ã§ã³ã«ãããã¦åæåããã¾ã
Name | èµ·åç´å¾ | jedi-vim åæå | vim-pyenv åæå | pyenv#activate() |
---|---|---|---|---|
Terminal | 3.4.0 | 3.4.0 | 3.4.0 | 3.4.0 |
jedi-vim | 2.7.6 | 2.7.6 | 3.4.0 | |
vim-pyenv | 2.7.6 | 3.4.0 |
ãããã£ã¦ã仮㫠vim-pyenv ã jedi-vim ããå ã«èªã¿è¾¼ã¾ãã¦ãã¾ãã¨ãä¸è¨ã®ããã«ãªã£ã¦ãã¾ãæ£ããåæåãè¡ããªããã¨ã«ãªãã¾ãã
Name | èµ·åç´å¾ | vim-pyenv åæå | pyenv#activate() | jedi-vim åæå |
---|---|---|---|---|
Terminal | 3.4.0 | 3.4.0 | 3.4.0 | 3.4.0 |
vim-pyenv | 2.7.6 | 3.4.0 | 3.4.0 | |
jedi-vim | 3.4.0 | 2.7.6 |
å®éã«æ£ãããã¼ã¸ã§ã³ã® Python ã使ç¨ããã¦ãããã©ããã¯ä¸è¨ã®ã³ãã³ãã§èª¿ã¹ããã¨ãã§ãã¾ãã
:Python print("jedi-vim", sys.path) :PyenvPython print("vim-pyenv", sys.path)
ã¾ãæ£ããè¨å®ããã¦ããã¨ä»®å®ãã¾ãã 次ã«ä»®æ³ç°å¢ã django2ï¼Python 2.7.4 ãã¼ã¹ï¼ã«åãæ¿ãã¦ã¿ã¾ãããã ä¸è¨ã³ãã³ããå®è¡ãã¦ãã ããã
:PyenvActivate django2
ããã§èªåçã« jedi-vim, vim-pyenv ã Python 2 ãåç
§ããããã«ãªãã¾ãã
ã¾ãã©ã¤ãã©ãªã®åç
§å
ã Python 3 åãã®ãã®ï¼~/.pyenv/versions/django3/lib/python3.4/site-packages
ï¼ ãã Python 2 åãã®ãã®ï¼~/.pyenv/versions/django2/lib/python2.7/site-packages
ï¼ã«å¤æ´ããã¾ãã
lightline ã«ç¾å¨ã®ä»®æ³ç°å¢ã¨Pythonã®ãã¼ã¸ã§ã³ã表示ãã
vim-pyenv ã¯ã¹ã¯ãªã¼ã³ã·ã§ããã®ãããªã¤ã³ãã£ã±ã¼ã¿ãæä¾ãã¦ãã¾ãã
æååãè¿ãé¢æ°ãªã®ã§ lightline.vim ã ãã§ãªãVimæ¨æºã®statuslineãªã©ã§ãå©ç¨ã§ãã¾ãã
詳ããç¥ãããæ¹ã¯ :help pyenv#statusline#component()
ã¨ãã¦ãã ããã
ã¨ããããåã® lightline.vim ã®è¨å®ãä¸è¨ãã¾ãã
let g:lightline = { \ 'colorscheme': 'hybrid', \ 'active': { \ 'left': [ \ [ 'mode', 'paste' ], \ [ 'pyenv' ], " <= ãã \ [ 'fugitive', 'filename' ] \ ], \ 'right': [ \ [ 'syntastic', 'lineinfo' ], \ [ 'percent' ], \ [ 'fileformat', 'fileencoding', 'filetype' ] \ ] \ }, \ 'component_expand': { \ 'syntastic': 'SyntasticStatuslineFlag', \ }, \ 'component_type': { \ 'syntastic': 'error', \ }, \ 'component_function': { \ 'fugitive': 'MyFugitive', \ 'filename': 'MyFilename', \ 'fileformat': 'MyFileformat', \ 'filetype': 'MyFiletype', \ 'fileencoding': 'MyFileencoding', \ 'mode': 'MyMode', \ 'pyenv': 'pyenv#statusline#component', " <= ãã \ }, \ 'separator': { 'left': 'â®', 'right': 'â®' }, \ 'subseparator': { 'left': 'â®', 'right': 'â®' } \ }
ãã£ã±ãç¾ãããªãã¨ãï¼