The health of
$VIM variable is checked with the following logic1:
" If $VIM is empty we don't care. Else make sure it is valid.
if !empty($VIM) && !filereadable($VIM.'/runtime/doc/nvim.txt')
let ok = v:false
call health#report_error('$VIM is invalid: '.$VIM)
You must not have
$HOME/.config/vim/runtime/doc/nvim.txt, or if you have it, you must not have read-permission for that file (the latter case is highly unlikely). That's the reason for the error you're facing.
- ERROR: $VIM is invalid: $HOME/.config/vim
The logic above tells us that
$VIM is expected to point to the directory where vim's system files reside. As for the reason behind, a look at the nvim source code reveals that the environment variable
$VIM is accessed only twice in the who codebase.
- To set system vimrc file2
- When checking for
$VIMRUNTIME and finding it nil3.
$VIM is also handled when you do
:echo $VIM, but that comes later in the execution time, and by then both
$VIMRUNTIME and most if not all variables have been set already.)
So, if we've got our own vimrc file (which means vim won't need the system vimrc) and we've set
$VIMRUNTIME properly (pointing to where vim's system runtime files exist), then the value of
$VIM should invite no complication. We can simply ignore the error put out by
BUT if we've not set
$VIMRUNTIME and have set
$VIM to an arbitrary location, then the value of
$VIMRUNTIME will be set wrongly at startup. See the stacktrace at the startup on a breakpoint at
#0 vim_getenv (name=0x7ff6f47638b9 <__func__.2+969> "VIMRUNTIME") at E:/projects/neovim/master/src/nvim/os/env.c:901
#1 0x00007ff6f44d62da in runtimepath_default (clean_arg=false) at E:/projects/neovim/master/src/nvim/runtime.c:1511
#2 0x00007ff6f446720f in set_init_1 (clean_arg=false) at E:/projects/neovim/master/src/nvim/option.c:316
#3 0x00007ff6f43ea95e in early_init (paramp=0x850f1ff530) at E:/projects/neovim/master/src/nvim/main.c:201
#4 0x00007ff6f43eab4d in wmain (argc=1, argv_w=0x22b48aa44b0) at E:/projects/neovim/master/src/nvim/main.c:257
#5 0x00007ff6f42513da in __tmainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:326
#6 0x00007ff6f4251506 in mainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:206
It's this case that will cause problems such as vim not finding syntax file ($VIMRUNTIME/syntax/syntax.vim), etc. Otherwise, we can use
$VIM as our own personal environment variable.
:let NOTVIM = "$HOME/vimfiles"