Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal vim invokes GUI in the background when omni-completing python #392

Closed
mario-grgic opened this issue Oct 21, 2016 · 5 comments
Closed

Comments

@mario-grgic
Copy link

I can reproduce this on macOS 10.12 Sierra and MacVim 8 Snapshot 112 (downloaded from here) but also MacVim compiled from source and with either against only system python or both system python and python3.

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 21 2016 17:45:24)
MacOS X (unix) version
Included patches: 1-45
Compiled by Mario Grgic
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +cursorbind      +fullscreen      +modify_fname    +path_extra      +syntax          +viminfo
+arabic          +cursorshape     -gettext         +mouse           +perl            +tag_binary      +vreplace
+autocmd         +dialog_con_gui  -hangul_input    +mouseshape      +persistent_undo +tag_old_static  +wildignore
+balloon_eval    +diff            +iconv           +mouse_dec       +postscript      -tag_any_white   +wildmenu
+browse          +digraphs        +insert_expand   -mouse_gpm       +printer         -tcl             +windows
++builtin_terms  +dnd             +job             -mouse_jsbterm   +profile         +termguicolors   +writebackup
+byte_offset     -ebcdic          +jumplist        +mouse_netterm   +python          +terminfo        -X11
+channel         +emacs_tags      +keymap          +mouse_sgr       -python3         +termresponse    -xfontset
+cindent         +eval            +lambda          -mouse_sysmouse  +quickfix        +textobjects     +xim
+clientserver    +ex_extra        +langmap         +mouse_urxvt     +reltime         +timers          -xpm
+clipboard       +extra_search    +libcall         +mouse_xterm     +rightleft       +title           -xsmp
+cmdline_compl   +farsi           +linebreak       +multi_byte      +ruby            +toolbar         -xterm_clipboard
+cmdline_hist    +file_in_path    +lispindent      +multi_lang      +scrollbind      +transparency    -xterm_save
+cmdline_info    +find_in_path    +listcmds        -mzscheme        +signs           +user_commands   
+comments        +float           +localmap        +netbeans_intg   +smartindent     +vertsplit       
+conceal         +folding         -lua             +num64           +startuptime     +virtualedit     
+cryptv          -footer          +menu            +odbeditor       +statusline      +visual          
+cscope          +fork()          +mksession       +packages        -sun_workshop    +visualextra     
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -F/System/Library/Frameworks -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -L/usr/local/lib -L. -L/usr/local/lib -I/System/Library/Frameworks/lib/python2.7/config -F/System/Library/Frameworks -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm -lncurses  -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -framework Ruby    

Lets' say I have following code snippet:

#!/usr/bin/env python

import matplotlib.pyplot as plt 

plt.

If I edit it in Terminal vim, navigate to the end of plt. enter INSERT mode and hit CTRL+x CTRL+o to omnicomplete the methods on plt.

This seems to invoke GUI version of MacVim in the background. The MacVim dock icon starts bouncing and remains bouncing until you exit the Terminal version of vim.

If you try to launch GUI macvim from Finder you get an error message "The application MacVim is not open anymore".

Note that this only seems to happen with matplotlib python package. I have tried a few others and this does not happen with them.

Note also that if I use vim 8 patch 46 that I compiled from source with system python support (no python3 support), this does not happen, most likely because it is not compiled with GUI support:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 21 2016 15:01:47)
MacOS X (unix) version
Included patches: 1-46
Compiled by Mario Grgic
Huge version without GUI.  Features included (+) or not (-):
+acl             +cscope          -footer          +menu            +num64           +startuptime     +virtualedit
+arabic          +cursorbind      +fork()          +mksession       +packages        +statusline      +visual
+autocmd         +cursorshape     -gettext         +modify_fname    +path_extra      -sun_workshop    +visualextra
-balloon_eval    +dialog_con      -hangul_input    +mouse           +perl            +syntax          +viminfo
-browse          +diff            +iconv           -mouseshape      +persistent_undo +tag_binary      +vreplace
++builtin_terms  +digraphs        +insert_expand   +mouse_dec       +postscript      +tag_old_static  +wildignore
+byte_offset     -dnd             +job             -mouse_gpm       +printer         -tag_any_white   +wildmenu
+channel         -ebcdic          +jumplist        -mouse_jsbterm   +profile         -tcl             +windows
+cindent         +emacs_tags      +keymap          +mouse_netterm   +python          +termguicolors   +writebackup
-clientserver    +eval            +lambda          +mouse_sgr       -python3         +terminfo        -X11
+clipboard       +ex_extra        +langmap         -mouse_sysmouse  +quickfix        +termresponse    -xfontset
+cmdline_compl   +extra_search    +libcall         +mouse_urxvt     +reltime         +textobjects     -xim
+cmdline_hist    +farsi           +linebreak       +mouse_xterm     +rightleft       +timers          -xpm
+cmdline_info    +file_in_path    +lispindent      +multi_byte      +ruby            +title           -xsmp
+comments        +find_in_path    +listcmds        +multi_lang      +scrollbind      -toolbar         -xterm_clipboard
+conceal         +float           +localmap        -mzscheme        +signs           +user_commands   -xterm_save
+cryptv          +folding         -lua             +netbeans_intg   +smartindent     +vertsplit       
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -F/System/Library/Frameworks -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -L/usr/local/lib -I/System/Library/Frameworks/lib/python2.7/config -F/System/Library/Frameworks -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc    

However, the completion for matplotlib does not work. You get "Patten not found" error. But it works for other python packages.

@mario-grgic mario-grgic changed the title Terminal vim invokes GUI in the background when completing python Terminal vim invokes GUI in the background when omni-completing python Oct 21, 2016
@splhack
Copy link
Contributor

splhack commented Oct 22, 2016

can you repro it with this option?

$ /Applications/MacVim.app/Contents/MacOS/Vim -g -u NONE -U NONE --noplugin

I think the root cause might be some python omnicompletion plugin?

@mario-grgic
Copy link
Author

First, the problem is with command line version of MacVim not GUI (problem is that command line MacVim invokes GUI in the background). So invoking GUI version of MacVim is pointless.

Second, you must have filetype detection on or else omnifunction is not set for any file type. So, no I cannot reproduce it with the suggested options since there is no omnifunc defined with those options.

Note that omnifunc is set by Vim's default filetype plugin located in

/Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin/python.vim

So, if I rename my ~/.vim directory I can still reproduce this. It is not a third party plugin that I may have installed or anything like that.

@splhack
Copy link
Contributor

splhack commented Oct 22, 2016

@mario-grgic
Copy link
Author

Yes, as mentioned in the original report, if I compile vim (not macvim) from source and install in /usr/local/bin the problem is not there. But then again this vim is built without GUI support. And as mentioned already python completion does not work for matplotlib. It works for everything else.

Not sure why only matplotlib completion is special and has this weird behavior.

@mario-grgic
Copy link
Author

OK, so I spent some time debugging this. It turns out

/Applications/MacVim.app/Contents/Resources/vim/runtime/autoload/pythoncomplete.vim

script invokes python script, which in turn evals the statement

import matplotlib.pyplot as plt

which in turn launches GUI python.

Normally, if you invoke the above import from IPython, it will also load and bounce the Python's rocketship icon on the dock. This is because matplotlib invokes interactive plot backend. But in Terminal MacVim version's case, it bounces the MacVim GUI icon instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants