diff options
Diffstat (limited to 'vim/plugin/undoskip.vim')
-rw-r--r-- | vim/plugin/undoskip.vim | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/vim/plugin/undoskip.vim b/vim/plugin/undoskip.vim index ffbabf86..af66f480 100644 --- a/vim/plugin/undoskip.vim +++ b/vim/plugin/undoskip.vim @@ -4,13 +4,28 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_undoskip') || &compatible || !has('persistent_undo') +if exists('loaded_undoskip') || &compatible + finish +endif +if !has('persistent_undo') || !exists('*glob2regpat') finish endif let loaded_undoskip = 1 -" Set the paths to test; can be changed by the user -let g:undoskip_patterns = ['^/dev/shm/.', '^/tmp/.', '^/var/tmp/.'] +" 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 " Internal function returns a local value for 'undofile' function s:CheckUndoSkip() abort @@ -23,8 +38,8 @@ function s:CheckUndoSkip() abort " Get the path from the buffer name; if that path matches any of the " patterns, don't save undo data let path = bufname('%') - for pattern in g:undoskip_patterns - if path =~# pattern + for glob in g:undoskip + if path =~# glob2regpat(glob) return 0 endif endfor |