diff --git a/README.rst b/README.rst index 0a5a7fa..f660f8e 100644 --- a/README.rst +++ b/README.rst @@ -60,6 +60,8 @@ Changelog +---------+------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Version | Date | Author | Notes | +=========+============+================+===========================================================================================================================================================================================+ +| 1.1 | 2016-12-10 | Roman Dobosz | Fixed python3 enabled vim (without python2) | ++---------+------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 1.0 | 2016-05-30 | Roman Dobosz | Rewrite python part (simplifying the code, clean it up, separate from vimscript, add some tests), make it Python3 compatible, lots of other changes | +---------+------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | | 2012-02-12 | cheater | `Several bug fixes`_, code cleanup, docs update | diff --git a/ftplugin/python/pythonhelper.vim b/ftplugin/python/pythonhelper.vim index b2bec21..8819ecf 100644 --- a/ftplugin/python/pythonhelper.vim +++ b/ftplugin/python/pythonhelper.vim @@ -1,28 +1,33 @@ " File: pythonhelper.vim " Author: Michal Vitecek " Author: Roman Dobosz -" Version: 1.0 +" Version: 1.1 " License: 3-clause BSD license -" Last Modified: 2016-05-24 +" Last Modified: 2016-12-10 " VIM functions {{{ -let g:pythonhelper_python = 'python' let s:plugin_path = expand(':p:h', 1) -function! s:PHLoader() - if !exists('g:pythonhelper_py_loaded') +function! s:SetPython(msg) + if !exists('g:_python') if has('python') - exe 'pyfile ' . s:plugin_path . '/pythonhelper.py' + let g:_python = {'exec': 'python', 'file': 'pyfile'} elseif has('python3') - let g:pythonhelper_python = 'python3' - exe 'py3file ' . s:plugin_path . '/pythonhelper.py' + let g:_python = {'exec': 'python3', 'file': 'py3file'} else - echohl WarningMsg|echomsg - \ "PythonHelper unavailable: " - \ "requires Vim with Python support"|echohl None + echohl WarningMsg|echomsg a:msg|echohl None finish endif + endif +endfunction + + +function! s:PHLoader() + if !exists('g:pythonhelper_py_loaded') + call s:SetPython("PythonHelper unavailable: " + \ "requires Vim with Python support") + execute g:_python['file'] . ' ' . s:plugin_path . '/pythonhelper.py' let g:pythonhelper_py_loaded = 1 else echohl "already loaded" @@ -42,7 +47,7 @@ function! PHCursorHold() " call Python function findTag() with the current buffer number and change " status indicator - execute g:pythonhelper_python . ' PythonHelper.find_tag(' . expand("") . + execute g:_python['exec'] . ' PythonHelper.find_tag(' . expand("") . \ ', ' . b:changedtick . ')' endfunction @@ -55,7 +60,7 @@ function! PHBufferDelete() " call Python function deleteTags() with the current buffer number and " change status indicator - execute g:pythonhelper_python . ' PythonHelper.delete_tags(' . expand("") . ')' + execute g:_python['exec'] . ' PythonHelper.delete_tags(' . expand("") . ')' endfunction