From 43f7c8f78a2afbcfcdf7b45cb39b5909ff46d12b Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 11 Sep 2022 21:11:40 +0800 Subject: [PATCH] fix(alternative): fix a.vim and a.lua --- autoload/SpaceVim/plugins/a.vim | 2 +- lua/spacevim/plugin/a.lua | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/SpaceVim/plugins/a.vim b/autoload/SpaceVim/plugins/a.vim index 5091d2790..98b751447 100644 --- a/autoload/SpaceVim/plugins/a.vim +++ b/autoload/SpaceVim/plugins/a.vim @@ -68,7 +68,7 @@ else " saving cache function! s:cache() abort - call writefile([s:JSON.json_encode(s:project_config)], s:FILE.unify_path(s:cache_path, ':p')) + silent call writefile([s:JSON.json_encode(s:project_config)], s:FILE.unify_path(s:cache_path, ':p')) endfunction function! s:load_cache() abort diff --git a/lua/spacevim/plugin/a.lua b/lua/spacevim/plugin/a.lua index 34cc0a025..f72681ddc 100644 --- a/lua/spacevim/plugin/a.lua +++ b/lua/spacevim/plugin/a.lua @@ -27,11 +27,11 @@ local project_config = {} local function cache() logger.debug('write cache into file:' .. cache_path) - local rst = fn.writefile({sp_json.json_encode(project_config)}, cache_path) - if rst == 0 then - logger.debug('cache succeeded!') - else + local ok, errors = pcall(fn.writefile, {sp_json.json_encode(project_config)}, cache_path) + if not ok then logger.debug('cache failed!') + else + logger.debug('cache succeeded!') end end