Skip to content

Commit

Permalink
XDG spec compliance, fzf now XDG path, mv info.vim
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-descartes2021 committed May 10, 2022
1 parent 637390b commit a5c967a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
19 changes: 13 additions & 6 deletions core/autoload/spacevim.vim
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 <nomodeline> User SpacevimAfterUserConfig
Expand Down
9 changes: 8 additions & 1 deletion core/autoload/spacevim/cache.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
27 changes: 26 additions & 1 deletion init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
" }

Expand Down
12 changes: 10 additions & 2 deletions layers/+tools/fzf/packages.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion layers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a5c967a

Please sign in to comment.