Add Python3 support

This commit is contained in:
lilydjwg 2011-07-30 17:07:25 +08:00
parent deff7ccc23
commit b1a9bae565

View File

@ -19,7 +19,9 @@ if v:version < '703'"{{{
finish finish
endif"}}} endif"}}}
if has('python')"{{{ if has('python3')"{{{
let s:has_supported_python = 2
elseif has('python')
let s:has_supported_python = 1 let s:has_supported_python = 1
else else
let s:has_supported_python = 0 let s:has_supported_python = 0
@ -263,8 +265,13 @@ endfunction"}}}
function! s:GundoOpen()"{{{ function! s:GundoOpen()"{{{
if !exists('g:gundo_py_loaded') if !exists('g:gundo_py_loaded')
exe 'pyfile ' . s:plugin_path . '/gundo.py' if s:has_supported_python == 2
python initPythonModule() exe 'py3file ' . s:plugin_path . '/gundo.py'
python3 initPythonModule()
else
exe 'pyfile ' . s:plugin_path . '/gundo.py'
python initPythonModule()
endif
if !s:has_supported_python if !s:has_supported_python
function! s:GundoDidNotLoad() function! s:GundoDidNotLoad()
@ -363,15 +370,27 @@ endfunction"}}}
"{{{ Gundo rendering "{{{ Gundo rendering
function! s:GundoRenderGraph()"{{{ function! s:GundoRenderGraph()"{{{
python GundoRenderGraph() if s:has_supported_python == 2
python3 GundoRenderGraph()
else
python GundoRenderGraph()
endif
endfunction"}}} endfunction"}}}
function! s:GundoRenderPreview()"{{{ function! s:GundoRenderPreview()"{{{
python GundoRenderPreview() if s:has_supported_python == 2
python3 GundoRenderPreview()
else
python GundoRenderPreview()
endif
endfunction"}}} endfunction"}}}
function! s:GundoRenderChangePreview()"{{{ function! s:GundoRenderChangePreview()"{{{
python GundoRenderChangePreview() if s:has_supported_python == 2
python3 GundoRenderChangePreview()
else
python GundoRenderChangePreview()
endif
endfunction"}}} endfunction"}}}
"}}} "}}}
@ -379,11 +398,19 @@ endfunction"}}}
"{{{ Gundo undo/redo "{{{ Gundo undo/redo
function! s:GundoRevert()"{{{ function! s:GundoRevert()"{{{
python GundoRevert() if s:has_supported_python == 2
python3 GundoRevert()
else
python GundoRevert()
endif
endfunction"}}} endfunction"}}}
function! s:GundoPlayTo()"{{{ function! s:GundoPlayTo()"{{{
python GundoPlayTo() if s:has_supported_python == 2
python3 GundoPlayTo()
else
python GundoPlayTo()
endif
endfunction"}}} endfunction"}}}
"}}} "}}}
@ -404,4 +431,4 @@ augroup GundoAug
autocmd BufNewFile __Gundo_Preview__ call s:GundoSettingsPreview() autocmd BufNewFile __Gundo_Preview__ call s:GundoSettingsPreview()
augroup END augroup END
"}}} "}}}