Re: Running win32 vim and gvim under Cygwin and pure Windows XP
On 2006-07-27, Luc Hermitte [EMAIL PROTECTED] wrote: More over I don't have any c:/ drive, and the shell can be anything. I'm having a little trouble understanding how the shell can be anything. What I think you're saying, and what I've understood from reading your web pages, is that you launch Cygwin programs from within vim using a set of macros, and that if you execute :sh or :! you will be using Windows' cmd.exe. Is that true? What I've been trying to achieve is a vim configuration that looks and feels the same under Cygwin as it does under Linux or Solaris; so for example, executing :sh gives me a Cygwin bash shell and executing :r !ls inserts the contents of the current directory into the current buffer. BTW, we can also detect cygwin presence with executable('cygpath') ; as long as cygwin paths are in the $PATH, because the windows box is set to have cygwin in the $PATH, or because vim is launched from cygwin. I was trying to allow vim to distinguish between being started from a bash shell or from the Command Prompt. The executable('cygpath') test will give the wrong answer if C:\cygwin\bin is in the Windows PATH. The problem is deeper than just having the right vim executable. There are many different vim executables running on various system. As plugin writers, we have to make our plugins portable. Discarding one vim binary because there is another (patched) one that is compatible with the plugin is not the solution. Note: in case you are interrested, you will found on my web site: - a shell script that lauches win32-vim from cygwin and that translates pathnames (and only pathnames) - cyg-wrapper.sh - a plugin that provides a few functions to detect the current system - .vimrc specific settings according to the current box vim is running on - a few plugins that call external programs (lh-vim-spell, triggers) - a compiler plugin-filter for cygwin that translates :make outputs from posix pathnames to windows pathnames. (- experimental plugin BuildToolWrapper (lh-BTW.tar.gz in vim/ressources/) This is great! Thank you for the pointers. I'm still reading and digesting this and the results of a few related Google searches. I think I will be using your cyg-wrapper.sh script and your aliases for vim, gvim and explorer. I just installed rxvt using Cygwin setup.exe and it seems to work fine except when I execute vim: then my CPU usage goes to 50% and I can see vim.exe in the Task Manager process list, but vim never appears in the rxvt window. I finally just kill vim with ^C in the rxvt window. I can execute vim from the Command Prompt and from the Cygwin prompt, and I can execute gvim from all three. I have been executing vim as vim -u NONE so the problem shouldn't be any of my vim files. Using -V20 didn't show anything, either. Any idea why I can't run vim from rxvt? Regards, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: Running win32 vim and gvim under Cygwin and pure Windows XP
Hello, Gary Johnson [EMAIL PROTECTED] wrote: On 2006-07-27, Luc Hermitte [EMAIL PROTECTED] wrote: More over I don't have any c:/ drive, and the shell can be anything. I'm having a little trouble understanding how the shell can be anything. I just meant it can be bash, sh, tcsh, ksh, ... In a general way, we cannot assume it is always bash. What I think you're saying, and what I've understood from reading your web pages, is that you launch Cygwin programs from within vim using a set of macros, and that if you execute :sh or :! you will be using Windows' cmd.exe. Is that true? No. The only times I use $COMSPEC as my main shell (from vim - 'shell') is when I test my plugins under different environments. I have two commands :GoBash and :GoCmd when I need to switch the current shell, which is quite always bash -- I used to use zsh for a few years. What I've been trying to achieve is a vim configuration that looks and feels the same under Cygwin as it does under Linux or Solaris; so for example, executing :sh gives me a Cygwin bash shell and executing :r !ls inserts the contents of the current directory into the current buffer. That's the easiest part. However, it will become tricky when you will have to convert posix pathss to windows paths, assuming you are using win32-vim. This path convertions issue is what motivated cyg-wrapper.sh and one of the compiler-filter plugins from BuildToolWrapper. If you want to have the exact same look and feel, using cygwin-vim is probably the best solution. BTW, we can also detect cygwin presence with executable('cygpath') ; as long as cygwin paths are in the $PATH, because the windows box is set to have cygwin in the $PATH, or because vim is launched from cygwin. I was trying to allow vim to distinguish between being started from a bash shell or from the Command Prompt. The executable('cygpath') test will give the wrong answer if C:\cygwin\bin is in the Windows PATH. IIRC, then test if shell =~ '^.*sh'. Vim uses as the default shell the shell it as been launched from. I will have a look at it tonight on the box I have cygwin installed. (NB for plugin writers: the tricky part with just testing '^.*sh' is that there are other ports of *nix tools to windows ; I guess a better test would be sh =~ '^.*sh' globpath(substitute($PATH, ':',',','g'), sh) =~ '.*cygwin') [...] This is great! Thank you for the pointers. You're welcome. I think I will be using your cyg-wrapper.sh script and your aliases for vim, gvim and explorer. If you have any comment, do not hesitate. I just installed rxvt using Cygwin setup.exe and it seems to work fine except when I execute vim: then my CPU usage goes to 50% and I can see vim.exe in the Task Manager process list, but vim never appears in the rxvt window. I finally just kill vim with ^C in the rxvt window. I can execute vim from the Command Prompt and from the Cygwin prompt, and I can execute gvim from all three. I have been executing vim as vim -u NONE so the problem shouldn't be any of my vim files. Using -V20 didn't show anything, either. Any idea why I can't run vim from rxvt? As I never use rxvt, I cannot help you here. We will have to know which version of vim you are using: cygwin-vim or vim32-vim ? In the former case, may be you can try to start vim with the -X option (- do not try to connect to the X server) -- Luc Hermitte
Re: Running win32 vim and gvim under Cygwin and pure Windows XP
On 2006-07-31, [EMAIL PROTECTED] wrote: Gary Johnson [EMAIL PROTECTED] wrote: I just installed rxvt using Cygwin setup.exe and it seems to work fine except when I execute vim: then my CPU usage goes to 50% and I can see vim.exe in the Task Manager process list, but vim never appears in the rxvt window. I finally just kill vim with ^C in the rxvt window. I can execute vim from the Command Prompt and from the Cygwin prompt, and I can execute gvim from all three. I have been executing vim as vim -u NONE so the problem shouldn't be any of my vim files. Using -V20 didn't show anything, either. Any idea why I can't run vim from rxvt? As I never use rxvt, I cannot help you here. We will have to know which version of vim you are using: cygwin-vim or vim32-vim ? In the former case, may be you can try to start vim with the -X option (- do not try to connect to the X server) I am using the win32 version. I even tried launching that version with -X, just in case, but as you might expect, it made no difference. Thanks, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: Running win32 vim and gvim under Cygwin and pure Windows XP
Hello, I run vim on Solaris, Linux and Cygwin (actually I use only the win32 native version of vim, generally the one compiled by Tony). And I have one set of scripts for all systems. * On Tue, Jul 25, 2006 at 12:14:43AM -0700, Gary Johnson [EMAIL PROTECTED] wrote: To that end, I have done a standard install of Cygwin, installed the standard vim for Windows from vim.sf.net, put C:\Program Files\Vim\vim70 in my Windows PATH, added export SHELL to my $HOME/.bash_profile, and added the following lines to the top of my _vimrc (C:\Program Files\Vim\_vimrc): if has(win32) $SHELL == /bin/bash executable(C:/cygwin/bin/bash) Running in Cygwin. I though I was detecting cygwin presence on $CYGWIN -- as it is more likelly to be widelly spread. But it seems I'm using either $OSTYPE or $TERM. More over I don't have any c:/ drive, and the shell can be anything. BTW, we can also detect cygwin presence with executable('cygpath') ; as long as cygwin paths are in the $PATH, because the windows box is set to have cygwin in the $PATH, or because vim is launched from cygwin. In addition, I have found it necessary to make some changes to some plugins (ctags.vim and ccase.vim) following this example in $VIMRUNTIME/ftplugin/perl.vim: Indeed. Plugins need to transform a few things in order to be portable. In my plugin system_utils.vim, I provide a few functions that help in that purpose. I use them in my other plugins when I need to call external programs like aspell, mkdir, ... So my questions to anyone else using Vim and Cygwin on Windows XP are: Does what I'm doing make sense? Yes. Is there some way to fix the 'shellxquote' problem other than modifying every plugin I use as I've done above? None that I know of. Is there a better way of doing any of this? I suppose I could build a Cygwin-aware vim binary, but I have successfully avoided having to compile anything under Windows so far and would really like to avoid that headache. The problem is deeper than just having the right vim executable. There are many different vim executables running on various system. As plugin writers, we have to make our plugins portable. Discarding one vim binary because there is another (patched) one that is compatible with the plugin is not the solution. Note: in case you are interrested, you will found on my web site: - a shell script that lauches win32-vim from cygwin and that translates pathnames (and only pathnames) - cyg-wrapper.sh - a plugin that provides a few functions to detect the current system - .vimrc specific settings according to the current box vim is running on - a few plugins that call external programs (lh-vim-spell, triggers) - a compiler plugin-filter for cygwin that translates :make outputs from posix pathnames to windows pathnames. (- experimental plugin BuildToolWrapper (lh-BTW.tar.gz in vim/ressources/) HTH, -- Luc Hermitte http://hermitte.free.fr/vim/
Re: Running win32 vim and gvim under Cygwin and pure Windows XP
Luc Hermitte wrote: Hello, I run vim on Solaris, Linux and Cygwin (actually I use only the win32 native version of vim, generally the one compiled by Tony). [...] I'm not distributing them anymore at the moment. My latest Vim for Windows was a v7.0aa ALPHA, now outdated. Please fall back on those compiled by Steve Hall https://sourceforge.net/project/showfiles.php?group_id=43866package_id=39721 . As I'm writing this I see a 7.0.42 listed there for downloading: that's currently the latest version and patchlevel. Note: That page belongs to the Cream sourceforge project but it's not the Cream download, it's the Vim download, with standard gvim and runtime files. Clicking Notes shows you the gvim :version listing: Big version, +ole -mzscheme +perl/dyn +python/dyn +ruby/dyn +tcl/dyn Best regards, Tony.
Re: Running win32 vim and gvim under Cygwin and pure Windows XP
Gary Johnson wrote: Most of my development work is done on a Unix system (usually SunOS but sometimes Linux or HP-UX), but some requires that I use Windows XP. Source code is maintained under ClearCase on all these systems except Linux. I'm trying to get my Windows environment tuned up so that development is as easy for me using Windows as it already is using Unix. One thing I've done is installed Cygwin. This has been really nice, but I can't always use the Cygwin environment because of all the tools and applications that understand only Windows. So the environment I think I want is this: when I open gvim from a Windows tool or application, I get a Windows gvim that executes system(), :sh, :!, :r!, etc. in a Windows environment; but when I start vim or gvim from the Cygwin shell, I get the same Windows vim or gvim executable, but one which executes system(), etc., in the Cygwin environment, i.e., pretty much as it would in a real Unix environment. To that end, I have done a standard install of Cygwin, installed the standard vim for Windows from vim.sf.net, put C:\Program Files\Vim\vim70 in my Windows PATH, added export SHELL to my $HOME/.bash_profile, and added the following lines to the top of my _vimrc (C:\Program Files\Vim\_vimrc): if has(win32) $SHELL == /bin/bash executable(C:/cygwin/bin/bash) Running in Cygwin. set shell=C:/cygwin/bin/bash if executable('grep') set grepprg=grep\ -n\ $*\ /dev/null endif if exists(+shellslash) set shellslash endif else set diffexpr=MyDiff() function MyDiff() let opt = '-a --binary ' if diffopt =~ 'icase' | let opt = opt . '-i ' | endif if diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '' . arg1 . '' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '' . arg2 . '' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '' . arg3 . '' | endif let eq = '' if $VIMRUNTIME =~ ' ' if sh =~ '\cmd' let cmd = '' . $VIMRUNTIME . '\diff' let eq = '' else let cmd = substitute($VIMRUNTIME, ' ', ' ', '') . '\diff' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' ' . arg3 . eq endfunction endif where the outer else clause encloses vim's default MyDiff() for Windows installations. In addition, I have found it necessary to make some changes to some plugins (ctags.vim and ccase.vim) following this example in $VIMRUNTIME/ftplugin/perl.vim: if shellxquote != '' let perlpath = system('perl -e print join(q/,/,@INC)') else let perlpath = system(perl -e 'print join(q/,/,@INC)') endif Vim automatically sets 'shellxquote' to when 'shell' is set to the Cygwin shell. Without this, system() commands don't handle temporary files properly. With this, however, you have to use single-quotes (') instead of double-quotes () in system() commands as shown above. So my questions to anyone else using Vim and Cygwin on Windows XP are: Does what I'm doing make sense? Is there some way to fix the 'shellxquote' problem other than modifying every plugin I use as I've done above? Is there a better way of doing any of this? I suppose I could build a Cygwin-aware vim binary, but I have successfully avoided having to compile anything under Windows so far and would really like to avoid that headache. Regards, Gary Interfacing native-Windows programs with the Cygwin environment, or vice-versa, is a ticklish matter. Maybe not insoluble but it requires constant attention to all the differences. See for instance, how src/Make_cyg.mak (used to compile native-Windows Vim using Cygwin tools) uses the cygpath utility (see man cygpath) when generating if_perl.c from if_perl.xs, in order to pass to the native-Windows Perl interpreter a pathname that it can understand. And that is just the most obvious thing: disk paths. In Vim, you probably will need two separate vimrc files, and therefore either two separate $HOME directories (which is not Cygwin's normal usage), or else a bash wrapper script to invoke Windows Vim with a -u command-line option. Since you are already familiar with Unix-like tools, it just might be less of a headache to keep a Cygwin-aware Vim in the Cygwin /usr/bin aka /usr/local/bin directory (which is not part of the Windows %PATH% but comes early in the Cygwin $PATH), and also a native-Windows Vim in (for instance) C:\Program Files\vim\vim70. You can compile them both under Cygwin: the native-windows Vim using src/Make_cyg.mak and the Cygwin-aware Vim (or even gvim for Cygwin X11) using the top-level Makefile. I haven't (yet) built Vim for Cygwin but I have built both native-Windows Vim