Windows: vim_getenv(): Find runtime relative to nvim. #3303 (#5929)

In Windows we cannot rely on absolute install paths to point to the
location of the runtime. Vim uses the path of the current binary as
a possible location for the runtime folder. In Neovim the install
location places the runtime folder in ../share/nvim/runtime.

In Vim this logic is guarded by USE_EXE_NAME, which is defined for win32
and macOS.

TODO: We may need to incorporate similar logic for macOS:
0cdb72aa38/src/misc1.c (L4287-L4308)
This commit is contained in:
Justin M. Keyes
2017-01-11 06:00:55 +01:00
committed by GitHub
parent a08d2f54a0
commit 207ba359b0
2 changed files with 35 additions and 2 deletions

View File

@@ -192,6 +192,18 @@ int os_nodetype(const char *name)
return nodetype;
}
/// Gets the absolute path of the currently running executable.
///
/// @param[out] buffer Returns the path string.
/// @param[in] size Size of `buffer`.
///
/// @return `0` on success, or libuv error code on failure.
int os_exepath(char *buffer, size_t *size)
FUNC_ATTR_NONNULL_ALL
{
return uv_exepath(buffer, size);
}
/// Checks if the given path represents an executable file.
///
/// @param[in] name Name of the executable.