diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-05 19:22:04 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-05 19:22:04 +1200 |
commit | d0b4999ad69e9252e61abb53bb17927068c4a7cf (patch) | |
tree | 821e7aacb9c711a6c1355508a5fa52c552aace6c | |
parent | Attempt to imitate 'backupskip' pats in undoskip (diff) | |
download | dotfiles-d0b4999ad69e9252e61abb53bb17927068c4a7cf.tar.gz dotfiles-d0b4999ad69e9252e61abb53bb17927068c4a7cf.zip |
Switch undoskip.vim to use globs
This increases the minimum version required to v7.4.668, but I think
that's OK now with v8.2 being rolled out.
-rw-r--r-- | vim/plugin/undoskip.vim | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/vim/plugin/undoskip.vim b/vim/plugin/undoskip.vim index 924c01f4..af66f480 100644 --- a/vim/plugin/undoskip.vim +++ b/vim/plugin/undoskip.vim @@ -4,23 +4,26 @@ " 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 default list of patterns to exclude; mirror documented 'backupskip' " behavior -if !exists('g:undoskip_patterns') - let g:undoskip_patterns = [] +if !exists('g:undoskip') + let g:undoskip = [] if has('mac') - call add(g:undoskip_patterns, '^/private/tmp/.') + call add(g:undoskip, '/private/tmp/*') elseif has('unix') - call add(g:undoskip_patterns, '^/tmp/.') + call add(g:undoskip, '/tmp/*') endif - call extend(g:undoskip_patterns, map( + call extend(g:undoskip, map( \ filter([$TMPDIR, $TMP, $TEMP], 'v:val !=# '''''), - \ '''\V\^''.escape(v:val, ''\'').''/\.''' + \ 'v:val.''/*''' \)) endif @@ -35,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 |