aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-12-09 09:52:48 -0500
committerJustin M. Keyes <justinkz@gmail.com>2015-12-09 09:52:48 -0500
commitf40c8c4c23a36147ea39463bea421c5943eea937 (patch)
tree4a15c6b8f91ae09779706ca15c8e7a654bfebf97 /src
parent6d583f85875499fbe05b549a1c0ac57b9ededd3d (diff)
parent3abbdb2f414be25a018c91a506ed4d5ecef5a08f (diff)
downloadrneovim-f40c8c4c23a36147ea39463bea421c5943eea937.tar.gz
rneovim-f40c8c4c23a36147ea39463bea421c5943eea937.tar.bz2
rneovim-f40c8c4c23a36147ea39463bea421c5943eea937.zip
Merge pull request #3805 from sethjackson/windows-home
Windows: Define HOME environment variable
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/env.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index bf6db97fcf..0e052ced55 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -141,6 +141,27 @@ void init_homedir(void)
char_u *var = (char_u *)os_getenv("HOME");
+#ifdef WIN32
+ // Typically, $HOME is not defined on Windows, unless the user has
+ // specifically defined it for Vim's sake. However, on Windows NT
+ // platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for
+ // each user. Try constructing $HOME from these.
+ if (var == NULL) {
+ const char *homedrive = os_getenv("HOMEDRIVE");
+ const char *homepath = os_getenv("HOMEPATH");
+ if (homepath == NULL) {
+ homepath = "\\";
+ }
+ if (homedrive != NULL && strlen(homedrive) + strlen(homepath) < MAXPATHL) {
+ snprintf((char *)NameBuff, MAXPATHL, "%s%s", homedrive, homepath);
+ if (NameBuff[0] != NUL) {
+ var = NameBuff;
+ vim_setenv("HOME", (char *)NameBuff);
+ }
+ }
+ }
+#endif
+
if (var != NULL) {
#ifdef UNIX
/*