aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-02 13:16:15 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-02-04 11:07:49 +0100
commit224f99b85d311ebd31451db13b66e4a3c7e51938 (patch)
treede2bb4bc8f06e09ede603ae535697384133a4ed5 /src/nvim/main.c
parent7d58aba80c6d81a9af40f54e566c0cdcea2de3e3 (diff)
downloadrneovim-224f99b85d311ebd31451db13b66e4a3c7e51938.tar.gz
rneovim-224f99b85d311ebd31451db13b66e4a3c7e51938.tar.bz2
rneovim-224f99b85d311ebd31451db13b66e4a3c7e51938.zip
win: Append process dir to $PATH
This allows executables to be found by :!, system(), and executable() if they live next to ("sibling" to) nvim.exe. This is what gvim on Windows does, and also matches the behavior of Win32 SearchPath(). https://github.com/vim/vim/blob/c4a249a736d40ec54794827ef95804c225d0e38f/src/os_win32.c#L354-L370
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index c7a60d07c1..6194e5f948 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -238,9 +238,7 @@ int main(int argc, char **argv)
// Check if we have an interactive window.
check_and_set_isatty(&params);
- // Get the name with which Nvim was invoked, with and without path.
- set_vim_var_string(VV_PROGPATH, argv[0], -1);
- set_vim_var_string(VV_PROGNAME, (char *) path_tail((char_u *) argv[0]), -1);
+ init_path(argv[0]);
event_init();
/*
@@ -1194,9 +1192,27 @@ static void check_and_set_isatty(mparm_T *paramp)
paramp->err_isatty = os_isatty(fileno(stderr));
TIME_MSG("window checked");
}
-/*
- * Get filename from command line, given that there is one.
- */
+
+// Sets v:progname and v:progpath. Also modifies $PATH on Windows.
+static void init_path(char *exename)
+{
+ char exepath[MAXPATHL] = { 0 };
+ size_t exepathlen = MAXPATHL;
+ // Make v:progpath absolute.
+ if (os_exepath(exepath, &exepathlen) != 0) {
+ EMSG2(e_intern2, "init_path()");
+ }
+ set_vim_var_string(VV_PROGPATH, exepath, -1);
+ set_vim_var_string(VV_PROGNAME, (char *)path_tail((char_u *)exename), -1);
+
+#ifdef WIN32
+ // Append the process start directory to $PATH, so that ":!foo" finds tools
+ // shipped with Windows package. This also mimics SearchPath().
+ os_setenv_append_path(exepath);
+#endif
+}
+
+/// Get filename from command line, if any.
static char_u *get_fname(mparm_T *parmp, char_u *cwd)
{
#if !defined(UNIX)