aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile16
-rw-r--r--VERSION4
-rw-r--r--vim/autoload/xdg.vim35
-rw-r--r--vim/vimrc59
-rw-r--r--zsh/zshrc2
-rw-r--r--zsh/zshrc.d/keep.zsh2
6 files changed, 76 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 4e435b69..8e537c84 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,6 @@
install-vim-indent \
install-vim-plugin \
install-vim-syntax \
- install-vim-thesaurus \
install-vint \
install-wget \
install-x \
@@ -589,19 +588,11 @@ install-vim-bundle: install-vim-config
'cp -p -- "$$1" $(VIMDIR)/"$${1#*/}"' _ {} \;
$(VIM) -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit
-install-vim-cache:
- mkdir -p -- \
- $(VIMDIR)/cache \
- $(VIMDIR)/cache/backup \
- $(VIMDIR)/cache/swap \
- $(VIMDIR)/cache/undo \
- $(VIMDIR)/cache/view
-
install-vim-compiler:
mkdir -p -- $(VIMDIR)/compiler
cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler
-install-vim-config: install-vim-autoload install-vim-cache
+install-vim-config: install-vim-autoload
cp -p -- vim/vimrc.stub $(HOME)/.vimrc
cp -p -- vim/vimrc $(VIMRC)
@@ -632,11 +623,6 @@ install-vim-syntax:
mkdir -p -- $(VIMDIR)/syntax
cp -p -- vim/syntax/*.vim $(VIMDIR)/syntax
-install-vim-thesaurus:
- mkdir -p -- $(VIMDIR)/ref
- curl 'https://sanctum.geek.nz/ref/thesaurus.txt' \
- > $(VIMDIR)/ref/thesaurus.txt
-
install-vint:
cp -p -- vint/vintrc.yaml $(HOME)/.vintrc.yaml
diff --git a/VERSION b/VERSION
index 8fdca683..ae41e268 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v8.19.0
-Wed, 22 Apr 2020 13:00:15 +0000
+tejr dotfiles v8.20.0
+Sat, 25 Apr 2020 07:34:11 +0000
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim
new file mode 100644
index 00000000..ab756f73
--- /dev/null
+++ b/vim/autoload/xdg.vim
@@ -0,0 +1,35 @@
+function! xdg#CacheDir(name) abort
+ let name = a:name
+ let home = exists('$XDG_CACHE_HOME')
+ \ ? $XDG_CACHE_HOME
+ \ : '~/.cache'
+ return join([home, name], '/')
+endfunction
+
+function! xdg#ConfigDirs(name) abort
+ let name = a:name
+ let home = exists('$XDG_CONFIG_HOME')
+ \ ? $XDG_CONFIG_HOME
+ \ : '~/.config'
+ let dirs = exists('$XDG_CONFIG_DIRS')
+ \ ? split($XDG_CONFIG_DIRS, ':')
+ \ : []
+ return map(
+ \ insert(dirs, home)
+ \,'join([v:val, name], "/")'
+ \)
+endfunction
+
+function! xdg#DataDirs(name) abort
+ let name = a:name
+ let home = exists('$XDG_DATA_HOME')
+ \ ? $XDG_DATA_HOME
+ \ : '~/.local/share'
+ let dirs = exists('$XDG_DATA_DIRS')
+ \ ? split($XDG_DATA_DIRS, ':')
+ \ : []
+ return map(
+ \ insert(dirs, home)
+ \,'join([v:val, name], "/")'
+ \)
+endfunction
diff --git a/vim/vimrc b/vim/vimrc
index adbc9f05..27a79a6f 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -93,17 +93,28 @@ scriptencoding utf-8
"
" We do all this with an autoloaded function option#Split().
"
-" If an environment variable MYVIM exists, and it isn’t blank, apply its value
-" as the first value of 'runtimepath', after escaping it appropriately.
-" Otherwise, do it the other way around: the first path in the 'runtimepath'
-" list becomes MYVIM.
-"
-if exists('$MYVIM') && $MYVIM !=# ''
- execute 'set runtimepath^='.option#Escape(option#item#Escape($MYVIM, 1))
-elseif &runtimepath !=# ''
+" We define an environment variable for ~/.vim or ~/vimfiles, by retrieving
+" the first value from the 'runtimepath', correctly split.
+"
+if &runtimepath !=# ''
let $MYVIM = option#Split(&runtimepath)[0]
endif
+" We'll use the XDG directories as machine-local configuration and storage.
+" <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables>
+"
+"" Config
+for s:configdir in reverse(xdg#ConfigDirs('vim'))
+ execute 'set runtimepath^='
+ \.option#Escape(option#item#Escape(s:configdir))
+endfor
+"" Cache; put this first so that e.g. spellfiles get created in it
+let s:cachedir = xdg#CacheDir('vim')
+execute 'set runtimepath^='
+ \.option#Escape(option#item#Escape(s:cachedir))
+"" Data
+let s:datadir = xdg#DataDirs('vim')[0]
+
" We need a command to reliably establish a full path, whether or not the
" directories already exist. We create a wrapper for the autoloaded function
" path#Create() with similar calling conventions to mkdir(), but with the ‘p’
@@ -133,8 +144,8 @@ command! -bang -bar -complete=dir -nargs=1 CreatePath
"
" <https://github.com/vim/vim/releases/tag/v8.1.0716>
"
-execute 'set viminfo+='.option#Escape('n'.$MYVIM.'/viminfo')
-call path#Create($MYVIM)
+execute 'set viminfo+='.option#Escape('n'.s:cachedir.'/viminfo')
+call path#Create(s:cachedir)
" Speaking of recorded data in viminfo files, the default Vim limit of a mere
" 50 entries for command and search history is pretty stingy. Because I don’t
@@ -180,9 +191,9 @@ set history=10000
"
set backup
execute 'set backupdir^='.option#Escape(option#item#Escape(
- \ $MYVIM.'/backup'.(has#('patch-8.1.251') ? '//' : ''),
+ \ s:cachedir.'/backup'.(has#('patch-8.1.251') ? '//' : ''),
\))
-call path#Create($MYVIM.'/backup')
+call path#Create(s:cachedir.'/backup')
" Files in certain directories on Unix-compatible filesystems should not be
" backed up, for security reasons. This is particularly important if editing
@@ -218,9 +229,10 @@ endif
" option has supported that hint for much longer than 'backupdir' has. We
" apply path#Create() to attempt to create the path, if needed.
"
+let s:swap = s:cachedir.'/swap'
execute 'set directory^='
- \.option#Escape(option#item#Escape($MYVIM.'/swap//'))
-call path#Create($MYVIM.'/swap')
+ \.option#Escape(option#item#Escape(s:swap.'//'))
+call path#Create(s:swap)
" Keep tracked undo history for files permanently, in a dedicated cache
" directory, so that the u/:undo and CTRL-R/:redo commands will work between
@@ -237,9 +249,10 @@ call path#Create($MYVIM.'/swap')
"
if has#('persistent_undo')
set undofile
+ let s:undodir = s:cachedir.'/undo'
execute 'set undodir^='
- \.option#Escape(option#item#Escape($MYVIM.'/undo//'))
- call path#Create($MYVIM.'/undo')
+ \.option#Escape(option#item#Escape(s:undodir.'//'))
+ call path#Create(s:undodir)
endif
" Set up a directory for files generated by :mkview. To date, I think I have
@@ -248,9 +261,10 @@ endif
" ('backupdir', 'directory', 'spell', 'undodir')
"
if has#('mksession')
+ let s:viewdir = s:cachedir.'/view'
execute 'set viewdir='
- \.option#Escape(option#item#Escape($MYVIM.'/view'))
- call path#Create($MYVIM.'/view')
+ \.option#Escape(option#item#Escape(s:viewdir))
+ call path#Create(s:viewdir)
endif
" Now that we have a bit more confidence in our runtime environment, set up
@@ -346,8 +360,8 @@ set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
" In much the same way, we add an expected path to a thesaurus, for completion
" with CTRL-X CTRL-T in insert mode, or with ‘t’ added to 'completeopt'. The
" thesaurus data isn’t installed as part of the default ‘install-vim’ target
-" in tejr’s dotfiles, but it can be retrieved and installed with
-" ‘install-vim-thesaurus’.
+" in tejr’s dotfiles, but it can be retrieved from
+" <https://sanctum.geek.nz/ref/thesaurus.txt>.
"
" I got the thesaurus itself from the link in the :help for 'thesaurus' in
" v8.1. It’s from WordNet and MyThes-1. I maintain a mirror on my own
@@ -365,12 +379,11 @@ set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
" around this one with 'isfname'; the blacklist is hard-coded.
"
set dictionary^=/usr/share/dict/words
-let s:ref = $MYVIM.'/ref'
try
execute 'set dictionary^='
- \.option#Escape(option#item#Escape(s:ref.'/dictionary.txt'))
+ \.option#Escape(option#item#Escape(s:datadir.'/dictionary.txt'))
execute 'set thesaurus^='
- \.option#Escape(option#item#Escape(s:ref.'/thesaurus.txt'))
+ \.option#Escape(option#item#Escape(s:datadir.'/thesaurus.txt'))
catch /^Vim\%((\a\+)\)\=:E474:/
endtry
diff --git a/zsh/zshrc b/zsh/zshrc
index 0aac527e..6d3239eb 100644
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -18,7 +18,7 @@ HISTFILE=$HOME/.zsh_history
SAVEHIST=$((1 << 12))
# Load Zsh-specific startup files
-for zsh in "$HOME"/.zshrc.d/*.zsh ; do
+for zsh in "$HOME"/.zshrc.d/*.zsh(N) ; do
[[ -e $zsh ]] || continue
source "$zsh"
done
diff --git a/zsh/zshrc.d/keep.zsh b/zsh/zshrc.d/keep.zsh
index ddcb96e2..8a2b9449 100644
--- a/zsh/zshrc.d/keep.zsh
+++ b/zsh/zshrc.d/keep.zsh
@@ -141,7 +141,7 @@ EOF
}
# Load any existing scripts in zshkeep
-for zshkeep in "${XDG_DATA_HOME:-"$HOME"/.local/share}"/zshkeep/*.zsh ; do
+for zshkeep in "${XDG_DATA_HOME:-"$HOME"/.local/share}"/zshkeep/*.zsh(N) ; do
[[ -e $zshkeep ]] || continue
source "$zshkeep"
done