Skip to content

Commit 1d3893a

Browse files
XDG spec compliance, fzf now XDG path, mv info.vim
1 parent 36f61f8 commit 1d3893a

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Thumbs.db
1616
tags
1717

1818
autoload/plug.vim
19-
core/autoload/info.vim
20-
core/autoload/spacevim/info.vim
2119
core/doc/.spacevim_last_helptags_run
2220
plugged/*
2321
*.un~

core/autoload/spacevim.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scriptencoding utf-8
22

3-
let g:spacevim.info = g:spacevim.base. '/core/autoload/spacevim/info.vim'
3+
let g:spacevim.info = $XDG_CACHE_HOME.'/spacevim/info.vim'
44
let g:spacevim.layers_base = '/layers'
55
let g:spacevim.private_base = '/private'
66
let g:spacevim.nvim = has('nvim') && exists('*jobwait') && !g:spacevim.os.windows

core/autoload/spacevim/cache.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ function! s:init()
3939
let l:private_path = filter(l:private_dir, 'isdirectory(v:val)')
4040

4141
let s:cache = g:spacevim.info
42+
if !isdirectory(fnamemodify(s:cache,':h'))
43+
call mkdir(fnamemodify(s:cache,':h'),'p',0o700)
44+
endif
4245
call writefile([printf("let g:spacevim.topics = %s", g:spacevim.topics)], s:cache)
4346
call writefile([printf("let g:spacevim.manifest = %s", g:spacevim.manifest)], s:cache, "a")
4447
if len(l:private_path)
@@ -85,7 +88,11 @@ vim.command("let g:spacevim.manifest = %s" % spacevim_manifest)
8588
if len(private):
8689
vim.command("let g:spacevim.private = %s" % private)
8790

88-
f = open(vim.eval('g:spacevim.info'), 'w')
91+
spacevim_info = vim.eval('g:spacevim.info')
92+
spacevim_info_path = os.path.dirname(spacevim_info)
93+
if not os.path.isdir(spacevim_info_path):
94+
os.makedirs(spacevim_info_path, 0o700, True)
95+
f = open(spacevim_info, 'w')
8996
f.write("let g:spacevim.topics = %s\n" % spacevim_topics)
9097
f.write("let g:spacevim.manifest = %s\n" % spacevim_manifest)
9198
if len(private):

init.vim

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,36 @@ let g:spacevim.os.linux = has('unix') && !has('macunix') && !has('win32unix')
2727
let g:spacevim.os.windows = has('win32')
2828
" }
2929

30-
" Windows Compatible {
30+
" Windows Compatible, and XDG compliance {
3131
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
3232
" across (heterogeneous) systems easier.
3333
if g:spacevim.os.windows
3434
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
35+
let $XDG_CACHE_HOME=$LOCALAPPDATA
36+
let $XDG_CONFIG_HOME=$LOCALAPPDATA
37+
let $XDG_DATA_HOME=$LOCALAPPDATA
38+
let $XDG_RUNTIME_DIR=(exists($TMP) ? $TMP : $TEMP)
39+
let $TMPDIR=$XDG_RUNTIME_DIR.'/.spacevim'
40+
else
41+
if !exists($XDG_CACHE_HOME)
42+
let $XDG_CACHE_HOME=$HOME.'/.cache'
43+
endif
44+
if !exists($XDG_CONFIG_HOME)
45+
let $XDG_CONFIG_HOME=$HOME.'/.config'
46+
endif
47+
if !exists($XDG_DATA_HOME)
48+
let $XDG_DATA_HOME=$HOME.'/.local/share'
49+
endif
50+
if !exists($TMPDIR)
51+
let $TMPDIR='/tmp'
52+
endif
53+
if !exists($XDG_RUNTIME_DIR)
54+
let $XDG_RUNTIME_DIR=$TMPDIR
55+
endif
56+
let $TMPDIR=$XDG_RUNTIME_DIR.'/.spacevim-'.$USER
57+
endif
58+
if !isdirectory($TMPDIR)
59+
call mkdir($TMPDIR,'p',0o700)
3560
endif
3661
" }
3762

layers/+tools/fzf/packages.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ elseif g:spacevim.gui && !has('terminal')
55
MP 'Yggdroot/LeaderF'
66
else
77
if g:spacevim.speed_up_via_timer
8-
MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': [] }
8+
if !executable('fzf')
9+
MP 'junegunn/fzf', { 'do': './install --all --xdg', 'on': [] }
10+
endif
911
MP 'junegunn/fzf.vim', { 'on': [] }
1012
call timer_start(700, 'spacevim#defer#fzf')
1113
else
12-
MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
14+
if !executable('fzf')
15+
MP 'junegunn/fzf', { 'do': './install --all --xdg' }
16+
endif
1317
MP 'junegunn/fzf.vim'
1418
endif
1519
endif

layers/layers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
import time
1414
import ast
1515

16-
info_path = os.path.expanduser('~/.space-vim/core/autoload/spacevim/info.vim')
16+
if os.name == 'nt':
17+
xdg_cache_home = os.getenv('XDG_CACHE_HOME', os.path.expandvars('$LOCALAPPDATA'))
18+
else:
19+
xdg_cache_home = os.getenv('XDG_CACHE_HOME', os.path.expandvars('$HOME/.cache'))
20+
info_path = os.path.join(xdg_cache_home, 'spacevim', 'info.vim')
1721

1822
topics = dict()
1923
layers = dict()

0 commit comments

Comments
 (0)