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 23, 2022
1 parent 79f8ddc commit b12487f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Thumbs.db
tags

autoload/plug.vim
core/autoload/info.vim
core/autoload/spacevim/info.vim
core/doc/.spacevim_last_helptags_run
plugged/*
*.un~
Expand Down
2 changes: 1 addition & 1 deletion 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
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
8 changes: 6 additions & 2 deletions layers/+tools/fzf/packages.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ 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 !executable('fzf')
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 !executable('fzf')
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 b12487f

Please sign in to comment.