aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
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)