From 8a496e0598ee96e665a6bf8b3780021d1c788c11 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 00:43:45 +1200 Subject: Add some more literate comments --- vim/vimrc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 81a0add5..09b52c54 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -538,14 +538,24 @@ set showmatch matchtime=3 " set nomodeline -" Treat numbers with a leading zero as decimal, not octal +" The only octal numbers I can think of that I ever even encounter are Unix +" permissions masks, and I'd never use CTRL-A or CTRL-X to increment them. +" Numbers with leading zeroes are far more likely to be decimals. +" set nrformats-=octal -" Disable command line display of file position if a system vimrc or Neovim -" has switched it on +" I like to leave the last line of the screen blank unless something is +" actually happening in it, so I have grown to like the Vim default of +" 'noruler'. System vimrc files tend to turn this back on, though, and Neovim +" has it on by default, so we will often need to put it back to normal. +" set noruler -" Make sessions usable +" Sessions are great, but they don't play together well with plugins and +" filetype plugins. Restoring the same settings from both reloaded plugins +" and from the session causes screeds of errors. Adjusting session behaviour +" to stop it trying to restore quite so much makes them useable. +" set sessionoptions-=localoptions " No buffer options or mappings set sessionoptions-=options " No global options or mappings -- cgit v1.2.3 From 90ef5e75badf38ed03b569cc738b2338b2d43cec Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 00:43:53 +1200 Subject: Restore 'shortmess' defaults It's actually kind of nice seeing the version number and splash screen once in a while. I almost always invoke Vim with filenames, anyway. --- vim/vimrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 09b52c54..0dc75762 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -559,9 +559,6 @@ set noruler set sessionoptions-=localoptions " No buffer options or mappings set sessionoptions-=options " No global options or mappings -" Don't show startup splash screen (I donated) -set shortmess+=I - " Prefix wrapped rows with three dots set showbreak=... -- cgit v1.2.3 From aeb5e56dc4c70df9ef8efc5944ac1faf70c3f7a8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:18:08 +1200 Subject: Split an awkwardly long :set line --- vim/vimrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 0dc75762..921acbed 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -29,7 +29,8 @@ " This doesn't raise an error if the paths aren't present, so we don't need to " check if they're already there. " -set runtimepath-=/var/lib/vim/addons runtimepath-=/var/lib/vim/addons/after +set runtimepath-=/var/lib/vim/addons +set runtimepath-=/var/lib/vim/addons/after " With 'runtimepath' cleaned up, the next thing we'll do is set an environment " variable MYVIM for the user runtime directory, if such a variable does not -- cgit v1.2.3 From 9e4fac3d6b77efb49dc4404eb3aa2416a05745d9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:18:28 +1200 Subject: Adjust layout of 'runtimepath' split code The split pattern variable wasn't getting set if the environment variable was set. --- vim/vimrc | 59 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 921acbed..35e838be 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,6 +32,32 @@ set runtimepath-=/var/lib/vim/addons set runtimepath-=/var/lib/vim/addons/after +" Splitting the values of a comma-separated option like 'runtimepath' +" correctly, which we'll need to do a few times throughout this file, is a bit +" more complicated than it seems. The list separator is more accurately +" defined as a comma that is not preceded by a backslash, and which is +" followed by any number of spaces and/or further commas. +" +" The pattern required for the split breaks down like this: +" +" \\ Literal backslash +" \@ Date: Sun, 9 Jun 2019 01:19:39 +1200 Subject: Adjust comma comment --- vim/vimrc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 35e838be..0b359398 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -80,15 +80,16 @@ endif " The path named in the MYVIM environment variable can't contain a comma " anywhere, because its use in comma-separated option values will confuse Vim -" into thinking more than one directory is being specified for the option -" value, per normal :set semantics. If there's a comma, we raise an error and -" end the script. +" into thinking more than one directory is being specified, per normal :set +" semantics. " " It's possible to work around this with some careful escaping, either at :set " time with an :execute abstraction or with a separate environment variable " for that particular context, but it's not really worth the extra complexity " for such a niche situation. " +" So, if there's a comma, we just raise an error and end the script. +" if stridx($MYVIM, ',') != -1 echoerr '$MYVIM contains a comma, refusing to proceed' finish -- cgit v1.2.3 From e858f2b6872a4f0807f1576a0e7347f91a2b9e53 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:20:36 +1200 Subject: Refactor cache directory creation and 'viminfo' --- vim/vimrc | 66 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 0b359398..cce19369 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -95,13 +95,44 @@ if stridx($MYVIM, ',') != -1 finish endif -" If we have a directory creation function, and the cache directory doesn't -" already exist, create it. This will be where backup, swap, undo, and -" viminfo files are stored, each in their own directories. +" We're going to be creating a few directories, and the code to do so in +" a compatible way is surprisingly verbose, because we need to check the +" mkdir() function is actually available, and also whether the directory +" concerned already exists, even if we specify the special 'p' value for its +" optional {path} argument. +" +" This is because the meaning of mkdir(..., 'p') is not the same as `mkdir -p` +" in shell script, or at least, it isn't in older versions of Vim. Even with +" the magic 'p' sauce, these older versions throw errors if the directory +" already exists, despite what someone familiar with `mkdir -p`'s behaviour in +" shell script might expect. +" +" So, let's wrap all that nonsense in a script-local function. We'll make all +" the directories we create have restrictive permissions, too, with a {prot} +" argument of 0700. +" +function! s:Mkdir(path) abort + if exists('*mkdir') && !isdirectory(a:path) + call mkdir(a:path, 'p', 0700) + endif +endfunction + +" Keep the viminfo file in a cache subdirectory of $MYVIM, creating that +" subdirectory if necessary. " -if exists('*mkdir') && !isdirectory($MYVIM.'/cache') - call mkdir($MYVIM.'/cache', 'p', 0700) -endif +" Using this location for viminfo has the nice benefit of preventing history +" from getting clobbered when something runs Vim without using this vimrc, +" because it writes its history to the default viminfo path instead. It also +" means that everything Vim-related in the user's home directory should be +" encapsulated in the one ~/.vim or ~/vimfiles directory. +" +" The normal method of specifying the path to the viminfo file used here is an +" addendum to the 'viminfo' option, which works OK. Vim v8.1.716 introduced +" a nicer way to set it with a 'viminfofile' option, but there's no particular +" reason to use it until it's in a few more stable versions. +" +call s:Mkdir($MYVIM.'/cache') +set viminfo+=n$MYVIM/cache/viminfo " Create a 'vimrc' automatic command hook group, if it already exists, and " clear away any automatic command hooks already defined within it if it does, @@ -255,10 +286,7 @@ if has('patch-8.1.251') else set backupdir^=$MYVIM/cache/backup endif -let s:backupdir = split(&backupdir, s:option_split_pattern)[0] -if exists('*mkdir') && !isdirectory(s:backupdir) - call mkdir(s:backupdir, '', 0700) -endif +call s:Mkdir(split(&backupdir, s:option_split_pattern)[0]) " Files in certain directories on Unix-compatible filesystems should not be " backed up for reasons of privacy, or an intentional ephemerality, or both. @@ -340,10 +368,7 @@ set dictionary^=/usr/share/dict/words " needed, too. " set directory^=$MYVIM/cache/swap// -let s:directory = split(&directory, s:option_split_pattern)[0] -if exists('*mkdir') && !isdirectory(s:directory) - call mkdir(s:directory, '', 0700) -endif +call s:Mkdir(split(&directory, s:option_split_pattern)[0]) " On Unix, I keep LANG defined in my environment, and it's almost always set " to a multibyte (UTF-8) locale. This informs Vim's choice of internal @@ -590,18 +615,7 @@ endif if has('persistent_undo') " v7.2.438 set undofile set undodir^=$MYVIM/cache/undo// - let s:undodir = split(&undodir, s:option_split_pattern)[0] - if exists('*mkdir') && !isdirectory(s:undodir) - call mkdir(s:undodir, '', 0700) - endif -endif - -" Keep the viminfo file in the home Vim directory, mostly to stop history -" getting clobbered when something runs Vim without using this vimrc -if exists('+viminfofile') " Use new option method if we can (v8.1.716) - set viminfofile=$MYVIM/cache/viminfo -else " Resort to clunkier method with 'viminfo' option flag - set viminfo+=n$MYVIM/cache/viminfo + call s:Mkdir(split(&undodir, s:option_split_pattern)[0]) endif " Let me move beyond buffer text in visual block mode -- cgit v1.2.3 From 97c1f87efeca3398538c68468a3be9eb8d52044d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:21:36 +1200 Subject: Revert "Restore 'shortmess' defaults" This reverts commit 90ef5e75badf38ed03b569cc738b2338b2d43cec. --- vim/vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index cce19369..d9755ed5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -587,6 +587,9 @@ set noruler set sessionoptions-=localoptions " No buffer options or mappings set sessionoptions-=options " No global options or mappings +" Don't show startup splash screen (I donated) +set shortmess+=I + " Prefix wrapped rows with three dots set showbreak=... -- cgit v1.2.3 From dd5f07460db73537bc5086e853109713d0f82aff Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:26:28 +1200 Subject: Rearrange a paragraph --- vim/vimrc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index d9755ed5..67d70a7e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -78,10 +78,9 @@ if !exists('$MYVIM') && &runtimepath !=# '' let $MYVIM = split(&runtimepath, s:option_split_pattern)[0] endif -" The path named in the MYVIM environment variable can't contain a comma -" anywhere, because its use in comma-separated option values will confuse Vim -" into thinking more than one directory is being specified, per normal :set -" semantics. +" If the path specified in the MYVIM environment variable contains a comma, +" its use in comma-separated option values will confuse Vim into thinking more +" than one directory is being specified, per normal :set semantics. " " It's possible to work around this with some careful escaping, either at :set " time with an :execute abstraction or with a separate environment variable -- cgit v1.2.3 From 293bdc0f07fc8cbebf4dc9749b96343340edac26 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:28:49 +1200 Subject: Identify patch number of fixed feature --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 67d70a7e..96a7c593 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -101,8 +101,8 @@ endif " optional {path} argument. " " This is because the meaning of mkdir(..., 'p') is not the same as `mkdir -p` -" in shell script, or at least, it isn't in older versions of Vim. Even with -" the magic 'p' sauce, these older versions throw errors if the directory +" in shell script, or at least, it isn't in versions of Vim before v8.0.1708. +" Even with the magic 'p' sauce, these versions throw errors if the directory " already exists, despite what someone familiar with `mkdir -p`'s behaviour in " shell script might expect. " -- cgit v1.2.3 From 6c794aabdaa5829742fc55df8a65b642d9bb11f2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:36:19 +1200 Subject: Block MYVIM with pipes in its name --- vim/vimrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 96a7c593..a96503b4 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -89,8 +89,11 @@ endif " " So, if there's a comma, we just raise an error and end the script. " -if stridx($MYVIM, ',') != -1 - echoerr '$MYVIM contains a comma, refusing to proceed' +" Similarly, the 'thesaurus' option, and possibly others, won't accept a path +" with a pipe in its name, so don't allow that, either. +" +if $MYVIM =~# '[,|]' + echoerr 'Illegal characters in $MYVIM path' finish endif -- cgit v1.2.3 From 7f56a2ba7bd635016cc09b94d729bfa3be7b1e0c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:38:38 +1200 Subject: Break a paragraph --- vim/vimrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index a96503b4..1d436cd5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -576,8 +576,10 @@ set nrformats-=octal " I like to leave the last line of the screen blank unless something is " actually happening in it, so I have grown to like the Vim default of -" 'noruler'. System vimrc files tend to turn this back on, though, and Neovim -" has it on by default, so we will often need to put it back to normal. +" 'noruler'. +" +" System vimrc files tend to turn this back on, though, and Neovim has it on +" by default, so we will often need to put it back to normal. " set noruler -- cgit v1.2.3 From 91dc576147107333dae5963f3c506791a6ac26ef Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 9 Jun 2019 01:38:47 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 88b0abad..b016b659 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v5.23.0 -Sat Jun 8 12:20:01 UTC 2019 +tejr dotfiles v5.24.0 +Sat Jun 8 13:38:47 UTC 2019 -- cgit v1.2.3