From 76f08e5853daec6b6ad6e0361072dd6460e43258 Mon Sep 17 00:00:00 2001 From: JessThrysoee Date: Wed, 30 Mar 2011 01:11:32 +0200 Subject: [PATCH] Honor VIM and VIMRUNTIME environment variables --- src/MacVim/gui_macvim.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index b4cef7f915..904dc7aa6d 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -56,10 +56,17 @@ macvim_early_init() // Set environment variables $VIM and $VIMRUNTIME NSString *path = [[bundle resourcePath] stringByAppendingPathComponent:@"vim"]; - vim_setenv((char_u*)"VIM", (char_u*)[path UTF8String]); - path = [path stringByAppendingPathComponent:@"runtime"]; - vim_setenv((char_u*)"VIMRUNTIME", (char_u*)[path UTF8String]); + char_u *p = mch_getenv((char_u *)"VIM"); + if (p == NULL || *p == NUL) { + vim_setenv((char_u*)"VIM", (char_u*)[path UTF8String]); + } + + p = mch_getenv((char_u *)"VIMRUNTIME"); + if (p == NULL || *p == NUL) { + path = [path stringByAppendingPathComponent:@"runtime"]; + vim_setenv((char_u*)"VIMRUNTIME", (char_u*)[path UTF8String]); + } } #if 0 // NOTE: setlocale(LC_ALL, "") seems to work after a restart so this is