feat(env): remove VIM_VERSION_NODOT macro #34890

Problem:
- The VIM_VERSION_NODOT macro maintained support for legacy Vim
  version-specific runtime directories (e.g., "vim82") which I believe
  have never been relevant for Neovim

Solution:
- Remove it
- Rename `vim_version_dir()` to `vim_runtime_dir()`
This commit is contained in:
Phạm Bình An
2025-07-19 00:46:33 +07:00
committed by GitHub
parent 586e6d427a
commit f5829957f2
4 changed files with 12 additions and 20 deletions

View File

@@ -303,6 +303,8 @@ These existing features changed their behavior.
• 'spellfile' location defaults to `stdpath("data").."/site/spell/"` instead of
the first writable directory in 'runtimepath'.
• |vim.version.range()| doesn't exclude `to` if it is equal to `from`.
• |$VIM| and |$VIMRUNTIME| no longer check for Vim version-specific runtime
directory `vim{number}` (e.g. `vim82`).
• 'scrollback' maximum value increased from 100000 to 1000000
==============================================================================

View File

@@ -670,13 +670,11 @@ the main help file is normally "$VIMRUNTIME/doc/help.txt".
Nvim will try to get the value for $VIMRUNTIME in this order:
1. Environment variable $VIMRUNTIME, if it is set.
2. Directory path "$VIM/vim{version}", if it exists, where {version} is the
Vim version number without '-' or '.'. For example: "$VIM/vim82".
3. Directory path "$VIM/runtime", if it exists.
4. Value of $VIM environment variable. This is for backwards compatibility
2. Directory path "$VIM/runtime", if it exists.
3. Value of $VIM environment variable. This is for backwards compatibility
with older Vim versions.
5. If "../share/nvim/runtime" exists relative to |v:progpath|, it is used.
6. Path derived from the 'helpfile' option (if it doesn't contain '$') with
4. If "../share/nvim/runtime" exists relative to |v:progpath|, it is used.
5. Path derived from the 'helpfile' option (if it doesn't contain '$') with
"doc/help.txt" removed from the end.
After doing this once, Nvim sets the $VIMRUNTIME environment variable.

View File

@@ -781,20 +781,15 @@ size_t expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen,
return (size_t)(dst - dst_start);
}
/// Check if the directory "vimdir/<version>" or "vimdir/runtime" exists.
/// Check if the directory "vimdir/runtime" exists.
/// Return NULL if not, return its name in allocated memory otherwise.
/// @param vimdir directory to test
static char *vim_version_dir(const char *vimdir)
static char *vim_runtime_dir(const char *vimdir)
{
if (vimdir == NULL || *vimdir == NUL) {
return NULL;
}
char *p = concat_fnames(vimdir, VIM_VERSION_NODOT, true);
if (os_isdir(p)) {
return p;
}
xfree(p);
p = concat_fnames(vimdir, RUNTIME_DIRNAME, true);
char *p = concat_fnames(vimdir, RUNTIME_DIRNAME, true);
if (os_isdir(p)) {
return p;
}
@@ -946,7 +941,7 @@ char *vim_getenv(const char *name)
&& *default_vimruntime_dir == NUL) {
kos_env_path = os_getenv("VIM"); // kos_env_path was NULL.
if (kos_env_path != NULL) {
vim_path = vim_version_dir(kos_env_path);
vim_path = vim_runtime_dir(kos_env_path);
if (vim_path == NULL) {
vim_path = kos_env_path;
} else {
@@ -981,10 +976,9 @@ char *vim_getenv(const char *name)
vim_path_end = remove_tail(vim_path, vim_path_end, "doc");
}
// for $VIM, remove "runtime/" or "vim54/", if present
// for $VIM, remove "runtime/", if present
if (!vimruntime) {
vim_path_end = remove_tail(vim_path, vim_path_end, RUNTIME_DIRNAME);
vim_path_end = remove_tail(vim_path, vim_path_end, VIM_VERSION_NODOT);
}
// remove trailing path separator
@@ -1012,7 +1006,7 @@ char *vim_getenv(const char *name)
vim_path = xstrdup(default_vimruntime_dir);
} else if (*default_vim_dir != NUL) {
if (vimruntime
&& (vim_path = vim_version_dir(default_vim_dir)) == NULL) {
&& (vim_path = vim_runtime_dir(default_vim_dir)) == NULL) {
vim_path = xstrdup(default_vim_dir);
}
}

View File

@@ -24,8 +24,6 @@ extern char *version_cflags;
#define VIM_VERSION_MINOR_STR STR(VIM_VERSION_MINOR)
#define VIM_VERSION_100 (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR)
// used for the runtime directory name
#define VIM_VERSION_NODOT "vim" VIM_VERSION_MAJOR_STR VIM_VERSION_MINOR_STR
// swap file compatibility (max. length is 6 chars)
#define VIM_VERSION_SHORT VIM_VERSION_MAJOR_STR "." VIM_VERSION_MINOR_STR