Vim opens fine in Terminal.app...
If I create a link:
sudo ln -s /Applications/MacVim/MacVim.app/Contents/MacOS/Vim vim
I get:
[robert]$ vim2
2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate Colors.plist.
2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate
SystemColors.plist.
E254: Cannot allocate color Red
E254: Cannot allocate color White
E254: Cannot allocate color Blue
E254: Cannot allocate color Red
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Brown
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color Yellow
E254: Cannot allocate color Red
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color DarkCyan
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color Red
E254: Cannot allocate color Yellow
E254: Cannot allocate color Black
E254: Cannot allocate color LightGrey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color LightGrey
E254: Cannot allocate color LightBlue
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Blue
E254: Cannot allocate color LightCyan
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Grey90
E254: Cannot allocate color Grey90
E254: Cannot allocate color Cyan
Error detected while processing /Users/robert/.vimrc:
line 12:
E484: Can't open file /usr/local/bin/vim/runtime/syntax/syntax.vim
Press ENTER or type command to continue
and then Vim opens up...
The E484 error is correct because that path is bogus.
Robert
As a workaround, doing `alias vim='/Applications/MacVim/MacVim.App/
Contents/MacOS/Vim` should work.
Nico
I have noticed this myself. The problem is that NSBundle fails to
find files in the app bundle when you create a symlink. My guess is
that it looks at argv[0] and uses the path assuming it points inside
the bundle, which obviously isn't the case when you symlink.
I don't really know how to fix this actually...does anybody else know
a fail-safe way to get the app bundle inside a Cocoa app? To be
clear: [NSBundle mainBundle] seems to fail when you symlink directly
to the binary inside Contents/MacOS.
/Björn
I do the Vim.app the same way and it works with symlinks.
Robert
That does work. Thanks for that.
Robert
Yeah. It is a more typical Vim installation that stores its runtime files outside
the bundle, IIRC, and thus plays nicer with Unix tricks like symlinking. MacVim is
more Mac-like and needs a bit more TLC with things like this.
Ben.
Send instant messages to your online friends http://au.messenger.yahoo.com
I *thought* it stored its runtime files in the Vim.app as well?
Robert
It does, but unlike MacVim it does not rely on NSBundle for getting
the path to the runtime files.
/Björn
Here's what carbon vim does in its gui_mch_prepare():
#ifdef USE_EXE_NAME
# ifndef USE_FIND_BUNDLE_PATH
HGetVol(volName, &applVRefNum, &applDirID);
/* TN2015: mention a possible bad VRefNum */
FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir);
# else
/* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
* of TN2015
* This technic remove the ../Contents/MacOS/etc part
*/
(void)GetCurrentProcess(&psn);
/* if (err != noErr) return err; */
(void)GetProcessBundleLocation(&psn, &applFSRef);
/* if (err != noErr) return err; */
(void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL,
NULL, &applDir, NULL);
/* This technic return NIL when we disallow_gui */
# endif
exe_name = FullPathFromFSSpec_save(applDir);
#endif
The mentioned technical note looks interesting too. Perhaps this works
better than [NSBundle mainBundle]?
Nico
Then again, all other applications I tried don't support this either.
IIUC, at least some parts of Cocoa rely on [NSBundle mainBundle] (to
find Info.plist for example), so I guess it's not really possible to
fix this.
But we could at least display a dialog along the lines of "Some error
occurred. This happens if you symlink directly to the binary which
cocoa doesn't support. Create an alias or a shell script instead." if
[NSBundle mainBundle] returns nil.
Nico
Agreed.
/Björn