This commit is contained in:
Steve Losh 2011-09-19 08:37:53 -04:00
commit 12b6f67aeb

View File

@ -19,24 +19,6 @@ if v:version < '703'"{{{
finish finish
endif"}}} endif"}}}
if has('python3')"{{{
let s:has_supported_python = 2
elseif has('python')
let s:has_supported_python = 1
else
let s:has_supported_python = 0
endif
if !s:has_supported_python
function! s:GundoDidNotLoad()
echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None
endfunction
command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
finish
endif"}}}
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
if !exists('g:gundo_width')"{{{ if !exists('g:gundo_width')"{{{
let g:gundo_width = 45 let g:gundo_width = 45
endif"}}} endif"}}}
@ -61,7 +43,26 @@ endif"}}}
if !exists("g:gundo_close_on_revert")"{{{ if !exists("g:gundo_close_on_revert")"{{{
let g:gundo_close_on_revert = 0 let g:gundo_close_on_revert = 0
endif"}}} endif"}}}
if !exists("g:gundo_prefer_python3")"{{{
let g:gundo_prefer_python3 = 0
endif"}}}
let s:has_supported_python = 0
if g:gundo_prefer_python3 && has('python3')"{{{
let s:has_supported_python = 2
elseif has('python')"
let s:has_supported_python = 1
endif
if !s:has_supported_python
function! s:GundoDidNotLoad()
echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None
endfunction
command! -nargs=0 GundoToggle call s:GundoDidNotLoad()
finish
endif"}}}
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
"}}} "}}}
"{{{ Gundo utility functions "{{{ Gundo utility functions
@ -265,7 +266,7 @@ endfunction"}}}
function! s:GundoOpen()"{{{ function! s:GundoOpen()"{{{
if !exists('g:gundo_py_loaded') if !exists('g:gundo_py_loaded')
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
exe 'py3file ' . s:plugin_path . '/gundo.py' exe 'py3file ' . s:plugin_path . '/gundo.py'
python3 initPythonModule() python3 initPythonModule()
else else
@ -370,7 +371,7 @@ endfunction"}}}
"{{{ Gundo rendering "{{{ Gundo rendering
function! s:GundoRenderGraph()"{{{ function! s:GundoRenderGraph()"{{{
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderGraph() python3 GundoRenderGraph()
else else
python GundoRenderGraph() python GundoRenderGraph()
@ -378,7 +379,7 @@ function! s:GundoRenderGraph()"{{{
endfunction"}}} endfunction"}}}
function! s:GundoRenderPreview()"{{{ function! s:GundoRenderPreview()"{{{
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderPreview() python3 GundoRenderPreview()
else else
python GundoRenderPreview() python GundoRenderPreview()
@ -386,7 +387,7 @@ function! s:GundoRenderPreview()"{{{
endfunction"}}} endfunction"}}}
function! s:GundoRenderChangePreview()"{{{ function! s:GundoRenderChangePreview()"{{{
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRenderChangePreview() python3 GundoRenderChangePreview()
else else
python GundoRenderChangePreview() python GundoRenderChangePreview()
@ -398,7 +399,7 @@ endfunction"}}}
"{{{ Gundo undo/redo "{{{ Gundo undo/redo
function! s:GundoRevert()"{{{ function! s:GundoRevert()"{{{
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoRevert() python3 GundoRevert()
else else
python GundoRevert() python GundoRevert()
@ -406,7 +407,7 @@ function! s:GundoRevert()"{{{
endfunction"}}} endfunction"}}}
function! s:GundoPlayTo()"{{{ function! s:GundoPlayTo()"{{{
if s:has_supported_python == 2 if s:has_supported_python == 2 && g:gundo_prefer_python3
python3 GundoPlayTo() python3 GundoPlayTo()
else else
python GundoPlayTo() python GundoPlayTo()