Last active
January 17, 2022 23:16
-
-
Save kaleb/3885679 to your computer and use it in GitHub Desktop.
VIM XDG Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" XDG Environment For VIM | |
" ======================= | |
" | |
" References | |
" ---------- | |
" | |
" - http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables | |
" - http://tlvince.com/vim-respect-xdg | |
" | |
if empty($XDG_CACHE_HOME) | |
let $XDG_CACHE_HOME = '~/.cache' | |
endif | |
if empty($XDG_CONFIG_HOME) | |
let $XDG_CONFIG_HOME = '~/.config' | |
endif | |
if !isdirectory($XDG_CACHE_HOME . "/vim/swap") | |
call mkdir($XDG_CACHE_HOME . "/vim/swap", "p") | |
endif | |
set directory=$XDG_CACHE_HOME/vim/swap//,/var/tmp//,/tmp// | |
if !isdirectory($XDG_CACHE_HOME . "/vim/backup") | |
call mkdir($XDG_CACHE_HOME . "/vim/backup", "p") | |
endif | |
set backupdir=$XDG_CACHE_HOME/vim/backup//,/var/tmp//,/tmp// | |
" Double slash does not actually work for backupdir, here's a fix | |
au BufWritePre * let &backupext='@'.substitute(substitute(substitute(expand('%:p:h'), '/', '%', 'g'), '\', '%', 'g'), ':', '', 'g') | |
" see :help persistent-undo | |
if !isdirectory($XDG_CACHE_HOME . "/vim/undo") | |
call mkdir($XDG_CACHE_HOME . "/vim/undo", "p") | |
endif | |
set undodir=$XDG_CACHE_HOME/vim/undo//,/var/tmp//,/tmp// | |
set undofile | |
set viminfo+=n$XDG_CACHE_HOME/vim/viminfo | |
set runtimepath-=~/.vim | |
set runtimepath^=$XDG_CONFIG_HOME/vim | |
set runtimepath-=~/.vim/after | |
set runtimepath+=$XDG_CONFIG_HOME/vim/after | |
source $XDG_CONFIG_HOME/vim/vimrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dkasak I actually did end up doing something similar. I should update this gist. https://github.com/kaleb/vim-files/blob/master/xdg.vim