aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/env.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-02-02 23:29:33 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2020-02-07 09:22:55 +0100
commitc5b812c9eab5397f4c898fe4b0a7a1f186fae82c (patch)
tree49f9f011a80764a77db070fd63546783ea3ce3a7 /src/nvim/os/env.c
parent7ce9a5c7da0fb5d6117cf9526c39e01faf7e908d (diff)
downloadrneovim-c5b812c9eab5397f4c898fe4b0a7a1f186fae82c.tar.gz
rneovim-c5b812c9eab5397f4c898fe4b0a7a1f186fae82c.tar.bz2
rneovim-c5b812c9eab5397f4c898fe4b0a7a1f186fae82c.zip
env: try find library dir (like /usr[/local]/lib/nvim) and add it to &rtp
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r--src/nvim/os/env.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index ec266796a8..082ad58223 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -847,6 +847,20 @@ const void *vim_env_iter_rev(const char delim,
}
}
+
+/// @param[out] exe_name should be at least MAXPATHL in size
+void vim_get_prefix_from_exepath(char *exe_name)
+{
+ // TODO(bfredl): param could have been written as "char exe_name[MAXPATHL]"
+ // but c_grammar.lua does not recognize it (yet).
+ xstrlcpy(exe_name, (char *)get_vim_var_str(VV_PROGPATH),
+ MAXPATHL * sizeof(*exe_name));
+ char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
+ *path_end = '\0'; // remove the trailing "nvim.exe"
+ path_end = (char *)path_tail((char_u *)exe_name);
+ *path_end = '\0'; // remove the trailing "bin/"
+}
+
/// Vim getenv() wrapper with special handling of $HOME, $VIM, $VIMRUNTIME,
/// allowing the user to override the Nvim runtime directory at runtime.
/// Result must be freed by the caller.
@@ -902,12 +916,7 @@ char *vim_getenv(const char *name)
char exe_name[MAXPATHL];
// Find runtime path relative to the nvim binary: ../share/nvim/runtime
if (vim_path == NULL) {
- xstrlcpy(exe_name, (char *)get_vim_var_str(VV_PROGPATH),
- sizeof(exe_name));
- char *path_end = (char *)path_tail_with_sep((char_u *)exe_name);
- *path_end = '\0'; // remove the trailing "nvim.exe"
- path_end = (char *)path_tail((char_u *)exe_name);
- *path_end = '\0'; // remove the trailing "bin/"
+ vim_get_prefix_from_exepath(exe_name);
if (append_path(
exe_name,
"share" _PATHSEPSTR "nvim" _PATHSEPSTR "runtime" _PATHSEPSTR,