aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2020-12-14 11:49:29 +0900
committerGitHub <noreply@github.com>2020-12-13 21:49:29 -0500
commit82100a6bdb42cec30060d6c991ab78fd2331fa31 (patch)
tree1087c3cb121783dce1c680b0bf2a2e034ab30eb8
parentd6115c996404e7ce6253c1ab131d661c2d873b9e (diff)
downloadrneovim-82100a6bdb42cec30060d6c991ab78fd2331fa31.tar.gz
rneovim-82100a6bdb42cec30060d6c991ab78fd2331fa31.tar.bz2
rneovim-82100a6bdb42cec30060d6c991ab78fd2331fa31.zip
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.
-rw-r--r--runtime/autoload/health/nvim.vim23
1 files changed, 20 insertions, 3 deletions
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