From 727eb9c0c5e70f38db7cf8de6bb2bfecd1c065c4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 12 Sep 2020 17:26:28 +1200 Subject: Set 'backupskip', and have g:undofileskip copy it --- vim/after/plugin/undofileskip.vim | 21 ++------------- vim/vimrc | 56 ++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 38 deletions(-) (limited to 'vim') diff --git a/vim/after/plugin/undofileskip.vim b/vim/after/plugin/undofileskip.vim index f062fe2f..e7116940 100644 --- a/vim/after/plugin/undofileskip.vim +++ b/vim/after/plugin/undofileskip.vim @@ -3,22 +3,5 @@ if !exists('g:undofileskip') finish endif -" Skip common temporary paths -call extend(g:undofileskip, [ - \ '/dev/shm/*', - \ '/usr/tmp/*', - \ '/var/tmp/*', - \]) - -" Skip Git patch edits -call extend(g:undofileskip, [ - \ '*.git/*_EDITMSG', - \ '*.git/ADD_EDIT.patch', - \ '*.git/rebase-merge/git-rebase-todo', - \]) - -" Skip `systemctl --user edit` buffers -call extend(g:undofileskip, [ - \ '*/.config/systemd/user/?*.?*.d/.#override.conf????????????????', - \ '*/.config/systemd/user/.#?*.?*????????????????', - \]) +" Just split and copy 'backupskip' +let g:undofileskip = option#Split(&backupskip) diff --git a/vim/vimrc b/vim/vimrc index 7d4c0508..598e8bec 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -2,7 +2,7 @@ " Tom Ryder (tejr)’s Literate Vimrc " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ " -" Last updated: Sat, 18 Jul 2020 15:09:37 UTC +" Last updated: Sat, 12 Sep 2020 05:21:43 UTC " " │ And I was lifted up in heart, and thought " │ Of all my late-shown prowess in the lists, @@ -246,31 +246,49 @@ endif " Files in certain directories on Unix-compatible filesystems should not be " backed up, for security reasons. This is particularly important if editing -" temporary files created by sudoedit(8). On Unix-like systems, we here add -" a few paths to the default value of 'backupskip' in order to prevent the -" creation of such undesired backup files. -" -" * /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] -" -" Prior to v8.1.1519, Vim didn’t check patterns added to 'backupskip' for -" uniqueness, so adding the same path repeatedly resulted in duplicate strings -" in the value. This was due to the absence of the P_NODUP flag for the -" option’s definition in src/option.c in the Vim source code. If we’re using -" a version older than v8.1.1519, we’ll need to explicitly reset 'backupskip' -" to its default value before adding patterns to it, so that reloading this -" file doesn’t stack up multiple copies of any added paths. -" -" +" temporary files created by sudoedit(8). We add a few path patterns to the +" default value of 'backupskip' here, in order to prevent the creation of such +" undesired backup files. " if has#('unix') + + " Prior to v8.1.1519, Vim didn’t check patterns added to 'backupskip' for + " uniqueness, so adding the same path repeatedly resulted in duplicate strings + " in the value. This was due to the absence of the P_NODUP flag for the + " option’s definition in src/option.c in the Vim source code. If we’re using + " a version older than v8.1.1519, we’ll need to explicitly reset 'backupskip' + " to its default value before adding patterns to it, so that reloading this + " file doesn’t stack up multiple copies of any added paths. + " + " + " if !has#('patch-8.1.1519') set backupskip& endif - set backupskip^=/dev/shm/*,/usr/tmp/*,/var/tmp/* + + " Typical temporary file locations + "" RAM disk, default path for password-store’s temporary files + set backupskip+=/dev/shm/* + "" Hard-coded paths for sudoedit + set backupskip+=/usr/tmp/*,/var/tmp/* + + " Per-repository temporary files for Git + "" Commit messages + set backupskip+=*.git/*_EDITMSG + "" Patch edits + set backupskip+=*.git/ADD_EDIT.patch + "" Interactive rebase manifests + set backupskip+=*.git/rebase-merge/git-rebase-todo + + " systemd user manager unit files + "" Full unit files + set backupskip+=*/systemd/user/.#?*.?*???????????????? + "" Per-unit overrides + set backupskip+=*/systemd/user/?*.?*.d/.#override.conf???????????????? + endif + " Keep swap files for file buffers in a dedicated directory, rather than the " default of writing them to the same directory as the buffer file. Add two " trailing slashes to the path to prompt Vim to use the full escaped path in -- cgit v1.2.3