1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:20:05 +08:00

Fix data dir (#4409)

This commit is contained in:
Wang Shidong 2021-08-18 20:54:54 +08:00 committed by GitHub
parent b518b77e49
commit 1e4cb1f295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 24 additions and 23 deletions

View File

@ -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', ''],

View File

@ -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, ''), ''))

View File

@ -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//'

View File

@ -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

View File

@ -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'

View File

@ -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]

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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'])

View File

@ -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*

View File

@ -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 = {}