diff --git a/.gitignore b/.gitignore index d9988fa6..c199f257 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,7 @@ Thumbs.db tags autoload/plug.vim -core/autoload/info.vim -core/autoload/spacevim/info.vim +core/doc/.spacevim_lastprocessed plugged/* *.un~ private/* diff --git a/core/autoload/spacevim.vim b/core/autoload/spacevim.vim index 6a906433..3bac6c13 100644 --- a/core/autoload/spacevim.vim +++ b/core/autoload/spacevim.vim @@ -1,6 +1,6 @@ scriptencoding utf-8 -let g:spacevim.info = g:spacevim.base. '/core/autoload/spacevim/info.vim' +let g:spacevim.info = $XDG_CACHE_HOME.'/spacevim/info.vim' let g:spacevim.layers_base = '/layers' let g:spacevim.private_base = '/private' let g:spacevim.nvim = has('nvim') && exists('*jobwait') && !g:spacevim.os.windows @@ -145,11 +145,18 @@ function! spacevim#end() abort call s:config() if exists('*UserConfig') | call UserConfig() | endif - try - execute 'helptags' g:spacevim.base . '/core/doc' - catch - echom v:exception - endtry + let s:hlptag_file = g:spacevim.base . '/core/doc/spacevim.txt' + let s:hlptag_lastprocessed_file = g:spacevim.base . '/core/doc/.spacevim_lastprocessed' + let s:hlptag_lastprocessed_time = filereadable(s:hlptag_lastprocessed_file) ? readfile(s:hlptag_lastprocessed_file) : [] + if (len(s:hlptag_lastprocessed_time) != 1) || (s:hlptag_lastprocessed_time[0] != getftime(s:hlptag_file)) + try + execute 'helptags' g:spacevim.base . '/core/doc' + let s:new_lastprocessed = getftime(s:hlptag_file) + call writefile([s:new_lastprocessed], s:hlptag_lastprocessed_file) + catch + echom v:exception + endtry + endif call s:check_missing_plugins() silent doautocmd User SpacevimAfterUserConfig diff --git a/core/autoload/spacevim/cache.vim b/core/autoload/spacevim/cache.vim index ed1af387..aa8657a7 100644 --- a/core/autoload/spacevim/cache.vim +++ b/core/autoload/spacevim/cache.vim @@ -39,6 +39,9 @@ function! s:init() let l:private_path = filter(l:private_dir, 'isdirectory(v:val)') let s:cache = g:spacevim.info + if !isdirectory(fnamemodify(s:cache,':h')) + call mkdir(fnamemodify(s:cache,':h'),'p',0o700) + endif call writefile([printf("let g:spacevim.topics = %s", g:spacevim.topics)], s:cache) call writefile([printf("let g:spacevim.manifest = %s", g:spacevim.manifest)], s:cache, "a") if len(l:private_path) @@ -85,7 +88,11 @@ vim.command("let g:spacevim.manifest = %s" % spacevim_manifest) if len(private): vim.command("let g:spacevim.private = %s" % private) -f = open(vim.eval('g:spacevim.info'), 'w') +spacevim_info = vim.eval('g:spacevim.info') +spacevim_info_path = os.path.dirname(spacevim_info) +if not os.path.isdir(spacevim_info_path): + os.makedirs(spacevim_info_path, 0o700, True) +f = open(spacevim_info, 'w') f.write("let g:spacevim.topics = %s\n" % spacevim_topics) f.write("let g:spacevim.manifest = %s\n" % spacevim_manifest) if len(private): diff --git a/init.vim b/init.vim index 91f1f7cc..e237db3f 100644 --- a/init.vim +++ b/init.vim @@ -27,11 +27,36 @@ let g:spacevim.os.linux = has('unix') && !has('macunix') && !has('win32unix') let g:spacevim.os.windows = has('win32') " } -" Windows Compatible { +" Windows Compatible, and XDG compliance { " On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization " across (heterogeneous) systems easier. if g:spacevim.os.windows set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after + let $XDG_CACHE_HOME=$LOCALAPPDATA + let $XDG_CONFIG_HOME=$LOCALAPPDATA + let $XDG_DATA_HOME=$LOCALAPPDATA + let $XDG_RUNTIME_DIR=(exists($TMP) ? $TMP : $TEMP) + let $TMPDIR=$XDG_RUNTIME_DIR.'/.spacevim' +else + if !exists($XDG_CACHE_HOME) + let $XDG_CACHE_HOME=$HOME.'/.cache' + endif + if !exists($XDG_CONFIG_HOME) + let $XDG_CONFIG_HOME=$HOME.'/.config' + endif + if !exists($XDG_DATA_HOME) + let $XDG_DATA_HOME=$HOME.'/.local/share' + endif + if !exists($TMPDIR) + let $TMPDIR='/tmp' + endif + if !exists($XDG_RUNTIME_DIR) + let $XDG_RUNTIME_DIR=$TMPDIR + endif + let $TMPDIR=$XDG_RUNTIME_DIR.'/.spacevim-'.$USER +endif +if !isdirectory($TMPDIR) + call mkdir($TMPDIR,'p',0o700) endif " } diff --git a/layers/+tools/fzf/packages.vim b/layers/+tools/fzf/packages.vim index 361cf001..da1dfbc0 100644 --- a/layers/+tools/fzf/packages.vim +++ b/layers/+tools/fzf/packages.vim @@ -5,11 +5,19 @@ elseif g:spacevim.gui && !has('terminal') MP 'Yggdroot/LeaderF' else if g:spacevim.speed_up_via_timer - MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': [] } + if isdirectory('~/.fzf') + MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': [] } + else + MP 'junegunn/fzf', { 'do': './install --all --xdg', 'on': [] } + endif MP 'junegunn/fzf.vim', { 'on': [] } call timer_start(700, 'spacevim#defer#fzf') else - MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + if isdirectory('~/.fzf') + MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + else + MP 'junegunn/fzf', { 'do': './install --all --xdg' } + endif MP 'junegunn/fzf.vim' endif endif diff --git a/layers/layers.py b/layers/layers.py index 5c912413..4b1c8610 100755 --- a/layers/layers.py +++ b/layers/layers.py @@ -13,7 +13,11 @@ import time import ast -info_path = os.path.expanduser('~/.space-vim/core/autoload/spacevim/info.vim') +if os.name == 'nt': + xdg_cache_home = os.getenv('XDG_CACHE_HOME', os.path.expandvars('$LOCALAPPDATA')) +else: + xdg_cache_home = os.getenv('XDG_CACHE_HOME', os.path.expandvars('$HOME/.cache')) +info_path = os.path.join(xdg_cache_home, 'spacevim', 'info.vim') topics = dict() layers = dict()