diff --git a/ftplugin/python/ipy.vim b/ftplugin/python/ipy.vim index 8c7011b..ea1d882 100644 --- a/ftplugin/python/ipy.vim +++ b/ftplugin/python/ipy.vim @@ -1,3 +1,4 @@ + " Vim integration with IPython 0.11+ " " A two-way integration between Vim and IPython. @@ -18,7 +19,7 @@ " " written by Paul Ivanov (http://pirsquared.org) " -if !has('python') +if !has('python3') " exit if python is not available. " XXX: raise an error message here finish @@ -41,7 +42,7 @@ if !exists('g:ipy_completefunc') let g:ipy_completefunc = 'global' endif -python << EOF +python3 << EOF import vim import sys vim_ipython_path = vim.eval("expand(':h')") @@ -53,7 +54,7 @@ EOF fun! toggle_send_on_save() if exists("s:ssos") && s:ssos == 0 let s:ssos = 1 - au BufWritePost *.py :py run_this_file() + au BufWritePost *.py :py3 run_this_file() echo "Autosend On" else let s:ssos = 0 @@ -77,37 +78,37 @@ endfun " buffer we may have opened up doesn't get closed just because of an idle " event (i.e. user pressed \d and then left the buffer that popped up, but " expects it to stay there). -au CursorHold *.*,vim-ipython :python if update_subchannel_msgs(): echo("vim-ipython shell updated (on idle)",'Operator') +au CursorHold *.*,vim-ipython :python3 if update_subchannel_msgs(): echo("vim-ipython shell updated (on idle)",'Operator') " XXX: broken - cursor hold update for insert mode moves the cursor one " character to the left of the last character (update_subchannel_msgs must be " doing this) -"au CursorHoldI *.* :python if update_subchannel_msgs(): echo("vim-ipython shell updated (on idle)",'Operator') +"au CursorHoldI *.* :python3 if update_subchannel_msgs(): echo("vim-ipython shell updated (on idle)",'Operator') " Same as above, but on regaining window focus (mostly for GUIs) -au FocusGained *.*,vim-ipython :python if update_subchannel_msgs(): echo("vim-ipython shell updated (on input focus)",'Operator') +au FocusGained *.*,vim-ipython :python3 if update_subchannel_msgs(): echo("vim-ipython shell updated (on input focus)",'Operator') " Update vim-ipython buffer when we move the cursor there. A message is only " displayed if vim-ipython buffer has been updated. -au BufEnter vim-ipython :python if update_subchannel_msgs(): echo("vim-ipython shell updated (on buffer enter)",'Operator') +au BufEnter vim-ipython :python3 if update_subchannel_msgs(): echo("vim-ipython shell updated (on buffer enter)",'Operator') " Setup plugin mappings for the most common ways to interact with ipython. -noremap (IPython-RunFile) :python run_this_file() -noremap (IPython-RunLine) :python run_this_line() -noremap (IPython-RunLines) :python run_these_lines() -noremap (IPython-OpenPyDoc) :python get_doc_buffer() -noremap (IPython-UpdateShell) :python if update_subchannel_msgs(force=True): echo("vim-ipython shell updated",'Operator') -noremap (IPython-ToggleReselect) :python toggle_reselect() -"noremap (IPython-StartDebugging) :python send('%pdb') -"noremap (IPython-BreakpointSet) :python set_breakpoint() -"noremap (IPython-BreakpointClear) :python clear_breakpoint() -"noremap (IPython-DebugThisFile) :python run_this_file_pdb() -"noremap (IPython-BreakpointClearAll) :python clear_all_breaks() +noremap (IPython-RunFile) :python3 run_this_file() +noremap (IPython-RunLine) :python3 run_this_line() +noremap (IPython-RunLines) :python3 run_these_lines() +noremap (IPython-OpenPyDoc) :python3 get_doc_buffer() +noremap (IPython-UpdateShell) :python3 if update_subchannel_msgs(force=True): echo("vim-ipython shell updated",'Operator') +noremap (IPython-ToggleReselect) :python3 toggle_reselect() +"noremap (IPython-StartDebugging) :python3 send('%pdb') +"noremap (IPython-BreakpointSet) :python3 set_breakpoint() +"noremap (IPython-BreakpointClear) :python3 clear_breakpoint() +"noremap (IPython-DebugThisFile) :python3 run_this_file_pdb() +"noremap (IPython-BreakpointClearAll) :python3 clear_all_breaks() noremap (IPython-ToggleSendOnSave) :call toggle_send_on_save() -noremap (IPython-PlotClearCurrent) :python run_command("plt.clf()") -noremap (IPython-PlotCloseAll) :python run_command("plt.close('all')") -noremap (IPython-RunLineAsTopLevel) :python dedent_run_this_line() -xnoremap (IPython-RunLinesAsTopLevel) :python dedent_run_these_lines() +noremap (IPython-PlotClearCurrent) :python3 run_command("plt.clf()") +noremap (IPython-PlotCloseAll) :python3 run_command("plt.close('all')") +noremap (IPython-RunLineAsTopLevel) :python3 dedent_run_this_line() +xnoremap (IPython-RunLinesAsTopLevel) :python3 dedent_run_these_lines() if g:ipy_perform_mappings != 0 map (IPython-RunFile) @@ -144,15 +145,15 @@ if g:ipy_perform_mappings != 0 xnoremap :s/^\([ \t]*\)#/\1/ endif -command! -nargs=* IPython :py km_from_string("") -command! -nargs=0 IPythonClipboard :py km_from_string(vim.eval('@+')) -command! -nargs=0 IPythonXSelection :py km_from_string(vim.eval('@*')) -command! -nargs=* IPythonNew :py new_ipy("") -command! -nargs=* IPythonInterrupt :py interrupt_kernel_hack("") -command! -nargs=0 IPythonTerminate :py terminate_kernel_hack() +command! -nargs=* IPython :py3 km_from_string("") +command! -nargs=0 IPythonClipboard :py3 km_from_string(vim.eval('@+')) +command! -nargs=0 IPythonXSelection :py3 km_from_string(vim.eval('@*')) +command! -nargs=* IPythonNew :py3 new_ipy("") +command! -nargs=* IPythonInterrupt :py3 interrupt_kernel_hack("") +command! -nargs=0 IPythonTerminate :py3 terminate_kernel_hack() function! IPythonBalloonExpr() -python << endpython +python3 << endpython word = vim.eval('v:beval_text') reply = get_doc(word) vim.command("let l:doc = %s"% reply) @@ -169,14 +170,14 @@ fun! CompleteIPython(findstart, base) let start -= 1 endwhile echo start - python << endpython + python3 << endpython current_line = vim.current.line endpython return start else " find months matching with "a:base" let res = [] - python << endpython + python3 << endpython base = vim.eval("a:base") findstart = vim.eval("a:findstart") matches = ipy_complete(base, current_line, vim.eval("col('.')"))