aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-05 22:06:46 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-05 22:06:46 +1200
commitd0e9d6b498a7a98951e6ad7717ea77d749e30f7c (patch)
treefb576ec38c7f0704700b5a6df28eeb0ed3e2ab33 /plugin
downloadvim-undofileskip-d0e9d6b498a7a98951e6ad7717ea77d749e30f7c.tar.gz
vim-undofileskip-d0e9d6b498a7a98951e6ad7717ea77d749e30f7c.zip
First version, spun out from tejr dotfiles v8.29.1v0.1.0
Diffstat (limited to 'plugin')
-rw-r--r--plugin/undoskip.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/plugin/undoskip.vim b/plugin/undoskip.vim
new file mode 100644
index 0000000..047d9e1
--- /dev/null
+++ b/plugin/undoskip.vim
@@ -0,0 +1,35 @@
+"
+" undoskip.vim: Don't save undo history for temporary or secure files.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('loaded_undoskip') || &compatible
+ finish
+endif
+if !has('persistent_undo') || !exists('*glob2regpat')
+ finish
+endif
+let loaded_undoskip = 1
+
+" Set default list of patterns to exclude; mirror documented 'backupskip'
+" behavior
+if !exists('g:undoskip')
+ let g:undoskip = []
+ if has('mac')
+ call add(g:undoskip, '/private/tmp/*')
+ elseif has('unix')
+ call add(g:undoskip, '/tmp/*')
+ endif
+ call extend(g:undoskip, map(
+ \ filter([$TMPDIR, $TMP, $TEMP], 'v:val !=# '''''),
+ \ 'v:val.''/*'''
+ \))
+endif
+
+" Check the path on every buffer rename, create, or read
+augroup undoskip
+ autocmd!
+ autocmd BufAdd,BufNewFile,BufRead *
+ \ let &l:undofile = undoskip#Check(expand('<amatch>'))
+augroup END