aboutsummaryrefslogtreecommitdiff
path: root/plugin/undofileskip.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-06 21:29:59 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-06 21:29:59 +1200
commit95ee5fd2993e7b64660557ff81099bfd3e021cff (patch)
treeb467b63f2e2a53490efa4f5dbed541bed75dd9c9 /plugin/undofileskip.vim
parentMerge branch 'hotfix/v0.1.1' (diff)
parentBump VERSION (diff)
downloadvim-undofileskip-95ee5fd2993e7b64660557ff81099bfd3e021cff.tar.gz
vim-undofileskip-95ee5fd2993e7b64660557ff81099bfd3e021cff.zip
Merge branch 'release/v0.2.0'v0.2.0
* release/v0.2.0: Rename plugin
Diffstat (limited to 'plugin/undofileskip.vim')
-rw-r--r--plugin/undofileskip.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/plugin/undofileskip.vim b/plugin/undofileskip.vim
new file mode 100644
index 0000000..c6b3b1e
--- /dev/null
+++ b/plugin/undofileskip.vim
@@ -0,0 +1,35 @@
+"
+" undofileskip.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_undofileskip') || &compatible
+ finish
+endif
+if !has('persistent_undo') || !exists('*glob2regpat')
+ finish
+endif
+let loaded_undofileskip = 1
+
+" Set default list of patterns to exclude; mirror documented 'backupskip'
+" behavior
+if !exists('g:undofileskip')
+ let g:undofileskip = []
+ if has('mac')
+ call add(g:undofileskip, '/private/tmp/*')
+ elseif has('unix')
+ call add(g:undofileskip, '/tmp/*')
+ endif
+ call extend(g:undofileskip, map(
+ \ filter([$TMPDIR, $TMP, $TEMP], 'v:val !=# '''''),
+ \ 'v:val.''/*'''
+ \))
+endif
+
+" Check the path on every buffer rename, create, or read
+augroup undofileskip
+ autocmd!
+ autocmd BufAdd,BufNewFile,BufRead *
+ \ let &l:undofile = undofileskip#Check(expand('<amatch>'))
+augroup END