mirror of
https://github.com/neovim/neovim.git
synced 2024-12-22 12:15:06 -07:00
Windows: Define HOME environment variable
- Bring back Vim code for settings $HOME in Windows from $HOMEDRIVE$HOMEPATH - vim-patch:0
This commit is contained in:
parent
6d583f8587
commit
3abbdb2f41
@ -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
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user