From 82100a6bdb42cec30060d6c991ab78fd2331fa31 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 14 Dec 2020 11:49:29 +0900 Subject: healthcheck: fix health check issue with shada file (#13291) - If the shada file is set with shada option n, use it. - If the shadafile is NONE, it does not check for file read/write access. - If the shada file does not exist, try to create it. --- runtime/autoload/health/nvim.vim | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index f18801ea69..8b734bbb6f 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -41,10 +41,27 @@ function! s:check_config() abort \ 'Check `:verbose set paste?` to see if a plugin or script set the option.', ]) endif - let shadafile = (empty(&shadafile) || &shadafile ==# 'NONE') ? stdpath('data').'/shada/main.shada' : &shadafile - if !empty(shadafile) && (!filereadable(shadafile) || !filewritable(shadafile)) + let writeable = v:true + let shadafile = substitute(matchstr( + \ split(&shada, ',')[-1], '^n.\+'), '^n', '', '') + let shadafile = empty(&shadafile) ? empty(shadafile) ? + \ stdpath('data').'/shada/main.shada' : expand(shadafile) + \ : &shadafile ==# 'NONE' ? '' : &shadafile + if !empty(shadafile) && empty(glob(shadafile)) + " Since this may be the first time neovim has been run, we will try to + " create a shada file + try + wshada + catch /.*/ + let writeable = v:false + endtry + endif + if !writeable || (!empty(shadafile) && + \ (!filereadable(shadafile) || !filewritable(shadafile))) let ok = v:false - call health#report_error('shada file is not '.(filereadable(shadafile) ? 'writeable' : 'readable').":\n".shadafile) + call health#report_error('shada file is not '. + \ ((!writeable || filereadable(shadafile)) ? + \ 'writeable' : 'readable').":\n".shadafile) endif if ok -- cgit