From 1e4cb1f2952e4035205cc8223c3043ad4acd7932 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Wed, 18 Aug 2021 20:54:54 +0800 Subject: [PATCH] Fix data dir (#4409) --- autoload/SpaceVim.vim | 2 +- autoload/SpaceVim/custom.vim | 4 ++-- autoload/SpaceVim/default.vim | 4 ++-- autoload/SpaceVim/layers/colorscheme.vim | 6 +++--- autoload/SpaceVim/plugins.vim | 4 ++-- autoload/SpaceVim/plugins/flygrep.vim | 10 +++++----- autoload/SpaceVim/plugins/tabmanager.vim | 4 ++-- config/plugins/ctrlp.vim | 2 +- config/plugins/neocomplete.vim | 2 +- config/plugins/unite.vim | 2 +- config/plugins/vim-gutentags.vim | 2 +- doc/SpaceVim.txt | 2 +- lua/spacevim/plugin/a.lua | 3 ++- 13 files changed, 24 insertions(+), 23 deletions(-) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 5259d551f..ef2458709 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -257,7 +257,7 @@ endif "" " Set the cache directory of plugins. Default is `$data_dir/vimfiles`. " > -" let g:spacevim_plugin_bundle_dir = g:spacevim_data_dir.'/vimplugs' +" let g:spacevim_plugin_bundle_dir = g:spacevim_data_dir.'vimplugs' " < let g:spacevim_plugin_bundle_dir \ = g:spacevim_data_dir . join(['vimfiles', ''], diff --git a/autoload/SpaceVim/custom.vim b/autoload/SpaceVim/custom.vim index 50044347e..a7ad1c27e 100644 --- a/autoload/SpaceVim/custom.vim +++ b/autoload/SpaceVim/custom.vim @@ -177,7 +177,7 @@ function! SpaceVim#custom#write(force) abort endfunction function! s:path_to_fname(path) abort - return expand(g:spacevim_data_dir.'/SpaceVim/conf/') . substitute(a:path, '[\\/:;.]', '_', 'g') . '.json' + return expand(g:spacevim_data_dir.'SpaceVim/conf/') . substitute(a:path, '[\\/:;.]', '_', 'g') . '.json' endfunction function! SpaceVim#custom#load() abort @@ -233,7 +233,7 @@ function! s:load_glob_conf() abort if filereadable(global_dir . 'init.toml') let g:_spacevim_global_config_path = global_dir . 'init.toml' let local_conf = global_dir . 'init.toml' - let local_conf_cache = s:FILE.unify_path(expand(g:spacevim_data_dir.'/SpaceVim/conf/' . fnamemodify(resolve(local_conf), ':t:r') . '.json')) + let local_conf_cache = s:FILE.unify_path(expand(g:spacevim_data_dir . 'SpaceVim/conf/' . fnamemodify(resolve(local_conf), ':t:r') . '.json')) let &rtp = global_dir . ',' . &rtp . ',' . global_dir . 'after' if getftime(resolve(local_conf)) < getftime(resolve(local_conf_cache)) let conf = s:JSON.json_decode(join(readfile(local_conf_cache, ''), '')) diff --git a/autoload/SpaceVim/default.vim b/autoload/SpaceVim/default.vim index c831a2c5d..897280efe 100644 --- a/autoload/SpaceVim/default.vim +++ b/autoload/SpaceVim/default.vim @@ -78,9 +78,9 @@ function! SpaceVim#default#options() abort set undolevels=1000 " Neovim 0.5 changed the undofile format if has('nvim-0.5.0') - let g:data_dir = g:spacevim_data_dir.'/SpaceVim/' + let g:data_dir = g:spacevim_data_dir.'SpaceVim/' else - let g:data_dir = g:spacevim_data_dir.'/SpaceVim/old/' + let g:data_dir = g:spacevim_data_dir.'SpaceVim/old/' endif let g:backup_dir = g:data_dir . 'backup//' let g:swap_dir = g:data_dir . 'swap//' diff --git a/autoload/SpaceVim/layers/colorscheme.vim b/autoload/SpaceVim/layers/colorscheme.vim index c2821c377..055a68c27 100644 --- a/autoload/SpaceVim/layers/colorscheme.vim +++ b/autoload/SpaceVim/layers/colorscheme.vim @@ -91,8 +91,8 @@ function! SpaceVim#layers#colorscheme#config() abort " {"frequency" : "dalily", "last" : 000000, 'theme' : 'one'} " FIXME: when global config cache is updated, check the cache also should " be updated - if filereadable(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json')) - let conf = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json'), ''), '')) + if filereadable(expand(g:spacevim_data_dir.'SpaceVim/colorscheme_frequency.json')) + let conf = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'SpaceVim/colorscheme_frequency.json'), ''), '')) if s:random_frequency !=# '' && !empty(conf) let ctime = localtime() if index(s:random_candidates, get(conf, 'theme', '')) == -1 || @@ -124,7 +124,7 @@ function! s:update_conf() abort \ 'last' : localtime(), \ 'theme' : g:spacevim_colorscheme \ } - call writefile([s:JSON.json_encode(conf)], expand(g:spacevim_data_dir.'/SpaceVim/colorscheme_frequency.json')) + call writefile([s:JSON.json_encode(conf)], expand(g:spacevim_data_dir.'SpaceVim/colorscheme_frequency.json')) endfunction diff --git a/autoload/SpaceVim/plugins.vim b/autoload/SpaceVim/plugins.vim index 379e571c7..60a2e306e 100644 --- a/autoload/SpaceVim/plugins.vim +++ b/autoload/SpaceVim/plugins.vim @@ -124,12 +124,12 @@ function! s:install_manager() abort let &rtp .= ',' . g:_spacevim_root_dir . 'bundle/dein.vim/' elseif g:spacevim_plugin_manager ==# 'vim-plug' "auto install vim-plug - if filereadable(expand(g:spacevim_data_dir.'/vim-plug/autoload/plug.vim')) + if filereadable(expand(g:spacevim_data_dir.'vim-plug/autoload/plug.vim')) let g:_spacevim_vim_plug_installed = 1 else if executable('curl') exec '!curl -fLo ' - \ . g:spacevim_data_dir.'/vim-plug/autoload/plug.vim' + \ . g:spacevim_data_dir.'vim-plug/autoload/plug.vim' \ . ' --create-dirs ' \ . 'https://raw.githubusercontent.com/' \ . 'junegunn/vim-plug/master/plug.vim' diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index e3e1fc24b..fbc4b1bd7 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -46,8 +46,8 @@ let s:grep_timer_id = -1 let s:preview_timer_id = -1 let s:grepid = 0 function! s:read_histroy() abort - if filereadable(expand(g:spacevim_data_dir.'/SpaceVim/flygrep_history')) - let _his = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'/SpaceVim/flygrep_history'), ''), '')) + if filereadable(expand(g:spacevim_data_dir.'SpaceVim/flygrep_history')) + let _his = s:JSON.json_decode(join(readfile(expand(g:spacevim_data_dir.'SpaceVim/flygrep_history'), ''), '')) if type(_his) ==# type([]) return _his else @@ -62,10 +62,10 @@ function! s:update_history() abort call remove(s:grep_history, index(s:grep_history, s:grep_expr)) endif call add(s:grep_history, s:grep_expr) - if !isdirectory(expand(g:spacevim_data_dir.'/SpaceVim')) - call mkdir(expand(g:spacevim_data_dir.'/SpaceVim')) + if !isdirectory(expand(g:spacevim_data_dir.'SpaceVim')) + call mkdir(expand(g:spacevim_data_dir.'SpaceVim')) endif - call writefile([s:JSON.json_encode(s:grep_history)], expand(g:spacevim_data_dir.'/SpaceVim/flygrep_history')) + call writefile([s:JSON.json_encode(s:grep_history)], expand(g:spacevim_data_dir.'SpaceVim/flygrep_history')) endfunction let s:grep_history = s:read_histroy() let s:complete_input_history_num = [0,0] diff --git a/autoload/SpaceVim/plugins/tabmanager.vim b/autoload/SpaceVim/plugins/tabmanager.vim index 8bccf2e7a..ee3718447 100644 --- a/autoload/SpaceVim/plugins/tabmanager.vim +++ b/autoload/SpaceVim/plugins/tabmanager.vim @@ -228,7 +228,7 @@ function! s:copy_tab() abort let s:copy_tab_name = gettabvar(cursor_tab, '_spacevim_tab_name', '') exe 'tabnext ' . cursor_tab let save_sessionopts = &sessionoptions - let tabsession = g:spacevim_data_dir.'/SpaceVim/tabmanager_session.vim' + let tabsession = g:spacevim_data_dir.'SpaceVim/tabmanager_session.vim' let &sessionoptions = 'winsize' exe 'mksession! ' . tabsession exe 'tabnext ' . current_tab @@ -251,7 +251,7 @@ function! s:paste_tab() abort let current_tab = tabpagenr() let tabid = s:get_cursor_tabnr() silent! exe tabid . 'tabnew ' - silent! exe 'so '.g:spacevim_data_dir.'/SpaceVim/tabmanager_session.vim' + silent! exe 'so '.g:spacevim_data_dir.'SpaceVim/tabmanager_session.vim' call settabvar(tabpagenr(), \ 'spacevim_tabman_expandable', \ s:copy_tab_expand_status) diff --git a/config/plugins/ctrlp.vim b/config/plugins/ctrlp.vim index c68c02fa5..267a85918 100644 --- a/config/plugins/ctrlp.vim +++ b/config/plugins/ctrlp.vim @@ -18,7 +18,7 @@ let g:ctrlp_show_hidden = get(g:, 'ctrlp_show_hidden', 1) "for caching let g:ctrlp_use_caching = get(g:, 'ctrlp_use_caching', 500) let g:ctrlp_clear_cache_on_exit = get(g:, 'ctrlp_clear_cache_on_exit', 1) -let g:ctrlp_cache_dir = get(g:, 'ctrlp_cache_dir', get(g:, 'spacevim_data_dir', '~') . '/ctrlp') +let g:ctrlp_cache_dir = get(g:, 'ctrlp_cache_dir', get(g:, 'spacevim_data_dir', '~') . 'ctrlp') "let g:ctrlp_map = ',,' "let g:ctrlp_open_multiple_files = 'v' "if you have install ag, the g:ctrlp_custom_ignore will not work diff --git a/config/plugins/neocomplete.vim b/config/plugins/neocomplete.vim index 29a9493bd..c552c2d33 100644 --- a/config/plugins/neocomplete.vim +++ b/config/plugins/neocomplete.vim @@ -1,5 +1,5 @@ let g:neocomplete#data_directory= get(g:, 'neocomplete#data_directory', - \ g:spacevim_data_dir.'/neocomplete') + \ g:spacevim_data_dir.'neocomplete') let g:acp_enableAtStartup = get(g:, 'acp_enableAtStartup', 0) let g:neocomplete#enable_at_startup = \ get(g:, 'neocomplete#enable_at_startup', 1) diff --git a/config/plugins/unite.vim b/config/plugins/unite.vim index 30f52df11..324e7d733 100644 --- a/config/plugins/unite.vim +++ b/config/plugins/unite.vim @@ -37,7 +37,7 @@ let g:unite_source_file_rec_max_depth = get(g:, \ 'unite_source_file_rec_max_depth', 6) let g:unite_enable_ignore_case = get(g:, 'unite_enable_ignore_case', 1) let g:unite_enable_smart_case = get(g:, 'unite_enable_smart_case', 1) -let g:unite_data_directory = get(g:, 'unite_data_directory',g:spacevim_data_dir.'/unite') +let g:unite_data_directory = get(g:, 'unite_data_directory',g:spacevim_data_dir.'unite') "let g:unite_enable_start_insert=1 let g:unite_source_history_yank_enable = get(g:, \ 'unite_source_history_yank_enable', 1) diff --git a/config/plugins/vim-gutentags.vim b/config/plugins/vim-gutentags.vim index 47e80a605..0a745ed26 100644 --- a/config/plugins/vim-gutentags.vim +++ b/config/plugins/vim-gutentags.vim @@ -1,2 +1,2 @@ -let g:gutentags_cache_dir = get(g:, 'gutentags_cache_dir', expand(g:spacevim_data_dir.'/tags')) +let g:gutentags_cache_dir = get(g:, 'gutentags_cache_dir', expand(g:spacevim_data_dir.'tags')) let g:gutentags_modules = get(g:, 'gutentags_modules', ['ctags', 'gtags_cscope']) diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 78bc54497..079ab112b 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -871,7 +871,7 @@ set `~/.cache¸. *g:spacevim_plugin_bundle_dir* Set the cache directory of plugins. Default is `$data_dir/vimfiles`. > - let g:spacevim_plugin_bundle_dir = g:spacevim_data_dir.'/vimplugs' + let g:spacevim_plugin_bundle_dir = g:spacevim_data_dir.'vimplugs' < *g:spacevim_realtime_leader_guide* diff --git a/lua/spacevim/plugin/a.lua b/lua/spacevim/plugin/a.lua index 7742a7309..03e830860 100644 --- a/lua/spacevim/plugin/a.lua +++ b/lua/spacevim/plugin/a.lua @@ -3,13 +3,14 @@ local sp = require('spacevim') local cmp = require('spacevim.api').import('vim.compatible') local cmd = require('spacevim').cmd local sp_file = require('spacevim.api').import('file') +local sp_opt = require('spacevim.opt') local sp_json = require('spacevim.api').import('data.json') local logger = require('spacevim.logger').derive('a.vim') local alternate_conf = {} alternate_conf['_'] = '.project_alt.json' -local cache_path = sp_file.unify_path(sp.eval('g:spacevim_data_dir'), ':p') .. 'SpaceVim/a.json' +local cache_path = sp_file.unify_path(sp_opt.data_dir, ':p') .. 'SpaceVim/a.json' local project_config = {}