Vim and NeoVim set VIM and VIMRUNTIME environment variables on startup. For example, NeoVim set VIMRUNTIME to /usr/share/nvim/runtime. If start :terminal on NeoVim and type vim, it cause errors since Vim use VIMRUNTIME that set by NeoVim.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
For example, Vim also can fix this easily.
diff --git a/src/os_unix.c b/src/os_unix.c index 1edc7e66b..9e64e6a77 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4231,6 +4231,8 @@ set_child_environment( setenv("COLUMNS", (char *)envbuf, 1); sprintf((char *)envbuf, "%d", t_colors); setenv("COLORS", (char *)envbuf, 1); + if (didset_vim) unsetenv("VIM"); + if (didset_vimruntime) unsetenv("VIMRUNTIME"); # ifdef FEAT_TERMINAL if (is_terminal) { @@ -4258,6 +4260,8 @@ set_child_environment( putenv(envbuf_Columns); vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", t_colors); putenv(envbuf_Colors); + if (didset_vim) putenv("VIM="); + if (didset_vimruntime) putenv("VIMRUNTIME="); # ifdef FEAT_TERMINAL if (is_terminal) {
This will have to be fixed in Neovim. E.g. by using $NVIMRUNTIME.
This isn't just an Vim/Neovim issue. $VIM/$VIMRUNTIME are internal details to the running vim process, which shouldn't be exposed to child processes.
The same issue can occur if trying to run a different Vim version from within :terminal, since it will pick up $VIMRUNTIME from the parent Vim.
@mattn wrote:
For example, Vim also can fix this easily.
So it would be better to save the old values of VIMRUNTIME and VIM and restore them before starting a terminal.
Your suggested fix still has side effects. If user has set VIMRUNTIME before running vim, then I would expect VIMRUNTIME to set in the terminal.
Did you try this patch? This works without side effects.
Vim passes all enironment variables to child processes, including those which were set inside Vim after it started.
When I run a child process, e.g. by :! or :shell, I expect it to have access to $VIM and $VIMRUNTIME the way they were set in Vim, just like I expect it to have access to any environment variable set in my vimrc for use within Vim.
@mattn wrote:
Did you try this patch? This works without side effects.
You're right, I now see it checks didset_vim & didset_vimruntime.
That said, if I do env | grep VIM I find 0 variable in my shell
and I type it in a vim terminal, I see:
—
why no one asked why you'll use neovim and vim both which embed one to another... :-)
same like your patch, looks it can un-set / re-set by bash cmd too, if really needed embed one to another...
or their env name perhaps should not same as bram said.. so far no use neovim yet.. 🤣