aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-08 19:45:15 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-08 19:45:15 +1200
commit8b3064c99a4f778a6087ff35d588ae3521ec7c25 (patch)
treeaaac4ddd258d493d0859a3b528ea6800834af287
parentRename vimrc#Establish() to vimrc#Ensure() (diff)
downloaddotfiles-8b3064c99a4f778a6087ff35d588ae3521ec7c25.tar.gz
dotfiles-8b3064c99a4f778a6087ff35d588ae3521ec7c25.zip
Refactor 'backupskip' processing
-rw-r--r--vim/vimrc25
1 files changed, 21 insertions, 4 deletions
diff --git a/vim/vimrc b/vim/vimrc
index db83efe0..e638bbd4 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -31,10 +31,27 @@ call vimrc#Ensure(&backupdir)
" Add some *nix paths not to back up
if has('unix')
- set backupskip& " Reset to avoid duplicates (Vim bug?)
- set backupskip+=/dev/shm/* " Shared memory RAM disk
- set backupskip+=/usr/tmp/* " Hard-coded path for `sudo -e` 1/2
- set backupskip+=/var/tmp/* " Hard-coded path for `sudo -e` 2/2
+
+ " * /dev/shm: RAM disk, default path for password-store's temporary files
+ " * /usr/tmp: Hard-coded path for sudoedit(8) [1/2]
+ " * /var/tmp: Hard-coded path for sudoedit(8) [2/2]
+ "
+ let s:backupskip_patterns = [
+ \ '/dev/shm/*'
+ \,'/usr/tmp/*'
+ \,'/var/tmp/*'
+ \ ]
+
+ " Vim doesn't seem to check patterns added to 'backupskip' for uniqueness,
+ " so adding them repeatedly if this file is reloaded results in duplicates.
+ " This might be a bug in Vim. To work around this, we attempt to remove
+ " each pattern before we add it.
+ "
+ for s:pattern in reverse(s:backupskip_patterns)
+ execute 'set backupskip-='.vimrc#EscapeSetPart(s:pattern)
+ execute 'set backupskip^='.vimrc#EscapeSetPart(s:pattern)
+ endfor
+
endif
" Indent wrapped lines