From f17b1ed073f40ab7cc4c206421fd6ace3193eb39 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 6 Oct 2016 10:56:05 +1100 Subject: [PATCH] Migrate Vim configuration to XDG basedir spec All my config lives in $XDG_CONFIG_HOME/vim, and installed plugins go to $XDG_CACHE_HOME/vim, as does the viminfo file. --- {.vim => .config/vim}/ftplugin/crontab.vim | 0 {.vim => .config/vim}/ftplugin/html.vim | 0 .config/vim/vimrc | 42 +++++++++++++++++ .vimrc | 53 ++++------------------ 4 files changed, 50 insertions(+), 45 deletions(-) rename {.vim => .config/vim}/ftplugin/crontab.vim (100%) rename {.vim => .config/vim}/ftplugin/html.vim (100%) create mode 100644 .config/vim/vimrc diff --git a/.vim/ftplugin/crontab.vim b/.config/vim/ftplugin/crontab.vim similarity index 100% rename from .vim/ftplugin/crontab.vim rename to .config/vim/ftplugin/crontab.vim diff --git a/.vim/ftplugin/html.vim b/.config/vim/ftplugin/html.vim similarity index 100% rename from .vim/ftplugin/html.vim rename to .config/vim/ftplugin/html.vim diff --git a/.config/vim/vimrc b/.config/vim/vimrc new file mode 100644 index 0000000..2330f8a --- /dev/null +++ b/.config/vim/vimrc @@ -0,0 +1,42 @@ +if !filereadable($XDG_CACHE_HOME . '/vim/autoload/plug.vim') + silent !curl -fLo $XDG_CACHE_HOME/vim/autoload/plug.vim --create-dirs 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall +endif + +call plug#begin($XDG_CACHE_HOME . '/vim/bundle') +Plug 'tpope/vim-sensible' + +Plug 'ciaranm/inkpot' +Plug 'ervandew/supertab' +Plug 'tpope/vim-repeat' +Plug 'tpope/vim-sleuth' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-unimpaired' +Plug 'wincent/terminus' + +Plug 'sukima/xmledit' + +if has('macunix') + Plug 'itspriddle/vim-marked' +endif + +call plug#end() + +colorscheme inkpot +inoremap jj + +set hlsearch +set linebreak showbreak=↩ +set showcmd + +if exists('+relativenumber') + set relativenumber +else + set number +endif + +set tabstop=2 shiftwidth=2 + +if exists('+breakindent') + set breakindent breakindentopt=sbr +endif diff --git a/.vimrc b/.vimrc index 99306dc..56994f9 100644 --- a/.vimrc +++ b/.vimrc @@ -1,47 +1,10 @@ -if has('win32') - set runtimepath=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after - set viminfo+=n~/.viminfo -endif +for [var, value] in items({'XDG_CONFIG_HOME': '~/.config', 'XDG_CACHE_HOME': '~/.cache', 'XDG_DATA_HOME': '~/.local/share'}) + if (empty(eval('$' . var))) + exec 'let $' . var . ' = expand(value)' + endif +endfor -if empty(glob('~/.vim/autoload/plug.vim')) - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall -endif +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 -call plug#begin('~/.vim/bundle') -Plug 'tpope/vim-sensible' - -Plug 'ciaranm/inkpot' -Plug 'ervandew/supertab' -Plug 'tpope/vim-repeat' -Plug 'tpope/vim-sleuth' -Plug 'tpope/vim-surround' -Plug 'tpope/vim-unimpaired' -Plug 'wincent/terminus' - -Plug 'sukima/xmledit' - -if has('macunix') - Plug 'itspriddle/vim-marked' -endif - -call plug#end() - -colorscheme inkpot -inoremap jj - -set hlsearch -set linebreak showbreak=↩ -set showcmd - -if exists('+relativenumber') - set relativenumber -else - set number -endif - -set tabstop=2 shiftwidth=2 - -if exists('+breakindent') - set breakindent breakindentopt=sbr -endif +source $XDG_CONFIG_HOME/vim/vimrc