From ad496a77457e47c553014e221cc25a068e0d3415 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 22 Sep 2021 10:35:51 +1000 Subject: [PATCH] Support the XDG_STATE_HOME directory It's a better place to store most of the stuff Vim wants to store lying around on the filesystem than XDG_CACHE_HOME, it turns out? I'm still keeping installed packages primarily in XDG_CACHE_HOME, since if that directory is blown away then the same packages just get reinstalled automatically and nothing particularly important is lost, but the other stuff doesn't really belong in there. Undo files, viminfo, and so on are definitely a good example of "state data that should be persisted between (application) restarts, but that is not important or portable enough to the user that it should be stored in XDG_DATA_HOME", so XDG_STATE_HOME is a fine place for them. --- config/vim/init.vim | 8 ++++---- vimrc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/vim/init.vim b/config/vim/init.vim index 0a7cb39..cda541d 100644 --- a/config/vim/init.vim +++ b/config/vim/init.vim @@ -71,14 +71,14 @@ else endif for s:dir in ['backup', 'swap', 'undo'] - call s:ensure_dir($XDG_CACHE_HOME . '/vim/' . s:dir) + call s:ensure_dir($XDG_STATE_HOME . '/vim/' . s:dir) endfor -set backupdir=.,$XDG_CACHE_HOME/vim/backup -set directory=.,$XDG_CACHE_HOME/vim/swap +set backupdir=.,$XDG_STATE_HOME/vim/backup +set directory=.,$XDG_STATE_HOME/vim/swap if exists('+undofile') set undofile - set undodir=$XDG_CACHE_HOME/vim/undo + set undodir=$XDG_STATE_HOME/vim/undo endif let g:airline_powerline_fonts = 1 diff --git a/vimrc b/vimrc index fc6777b..fa8d3c2 100644 --- a/vimrc +++ b/vimrc @@ -1,11 +1,11 @@ -for [s:var, s:value] in items({'XDG_CONFIG_HOME': '~/.config', 'XDG_CACHE_HOME': '~/.cache', 'XDG_DATA_HOME': '~/.local/share'}) +for [s:var, s:value] in items({'XDG_CONFIG_HOME': '~/.config', 'XDG_CACHE_HOME': '~/.cache', 'XDG_DATA_HOME': '~/.local/share', 'XDG_STATE_HOME': '~/.local/state'}) if (empty(eval('$' . s:var))) exec 'let $' . s:var . ' = expand(s:value)' endif endfor set runtimepath=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$XDG_CONFIG_HOME/vim/after,$XDG_CACHE_HOME/vim/after -set viminfo+=n$XDG_CACHE_HOME/vim/viminfo +set viminfo+=n$XDG_STATE_HOME/vim/viminfo if exists('+packpath') set packpath^=$XDG_CONFIG_HOME/vim,$XDG_CACHE_HOME/vim endif