aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION4
-rw-r--r--vim/vimrc154
2 files changed, 91 insertions, 67 deletions
diff --git a/VERSION b/VERSION
index 9735aa91..9d8ecbdc 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v5.44.0
-Wed Jun 12 23:54:33 UTC 2019
+tejr dotfiles v5.45.0
+Thu Jun 13 02:13:50 UTC 2019
diff --git a/vim/vimrc b/vim/vimrc
index 629ab631..57a92a11 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -18,8 +18,8 @@
" This file should be saved as "vimrc" in the user runtime directory. On
" Unix-like operating systems, this is ~/.vim; on Windows, it's ~/vimfiles.
" It requires Vim 7.0 or newer with +eval, with 'nocompatible'. The vimrc
-" stub at ~/.vimrc on Unix or ~/_vimrc on Windows checks that these conditions
-" are met before loading this file.
+" stub at ~/.vimrc on Unix or ~/_vimrc on Windows should checks that these
+" conditions are met before loading this file with `:runtime vimrc`.
"
" > And I was lifted up in heart, and thought
" > Of all my late-shown prowess in the lists,
@@ -88,8 +88,8 @@ scriptencoding utf-8
" source code and test it with some values of your own if you want to
" understand why.
"
-" For the edge case of a blank &runtimepath, MYVIM will here be set to the
-" empty string, due to the way that split() works by default without its third
+" For the edge case of a blank 'runtimepath', MYVIM will be set to the empty
+" string, due to the way that split() works by default without its third
" parameter {keepempty} set to false.
"
" Vim, I love you, but you are really weird.
@@ -100,9 +100,9 @@ endif
" Having either imported or defined a value for the MYVIM environment
" variable, we now need to ensure it's not going to cause problems for the
-" rest of this file. If any of those conditions are met, throw an explanatory
-" error and stop reading this file. Most of the file doesn't depend on MYVIM,
-" but there's no point catering to these edge cases.
+" rest of this file. If any of those conditions are met, we'll throw an
+" explanatory error and stop reading this file. Most of the file doesn't
+" depend on MYVIM, but there's not much point accommodating these edge cases.
"
" Firstly, MYVIM can't be an empty string. We need a real path.
@@ -114,19 +114,20 @@ endif
" Secondly, if MYVIM's value 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 or :execute abstraction, but it's not really
-" worth the extra complexity for such a niche situation.
+" being specified, splitting our value into parts. This is normal :set
+" behaviour. It's possible to work around this with some careful escaping or
+" :execute abstraction, but it's not really worth the extra complexity for
+" such a niche situation.
"
if $MYVIM =~# ','
echoerr 'Illegal comma in user runtime path'
finish
endif
-" Thirdly, Vim v7 prior to v7.1.055 had a nasty bug with escaping with the
-" backslash character on the command line, and so on these older versions of
-" Vim, we'll need to forbid that character in the value of MYVIM in order to
-" be confident that we're stashing files in the correct path.
+" Thirdly, Vim v7 prior to v7.1.055 had a nasty bug with escaping with
+" multiple backslash characters on the command line, and so on these older
+" versions of Vim, we'll need to forbid that character in the value of MYVIM
+" in order to be confident that we're stashing files in the correct path.
"
" To reproduce this bug on these older versions, try this command:
"
@@ -135,6 +136,8 @@ endif
" It should rename the buffer as "foo bar aaz"; note the change in the first
" letter of the last word of the filename.
"
+" <https://github.com/vim/vim/releases/tag/v7.1.055>
+"
if $MYVIM =~# '\\'
\ && (v:version < 701 || v:version == 701 && !has('patch55'))
echoerr 'Illegal backslash in user runtime path on Vim < v7.1.055'
@@ -209,6 +212,8 @@ augroup vimrc
" invocations of :source of either vimrc file, and translate that into
" reloading the stub vimrc.
"
+ " <https://github.com/vim/vim/releases/tag/v7.0.187>
+ "
if exists('##SourceCmd')
autocmd SourceCmd $MYVIMRC,$MYVIM/vimrc
\ ReloadVimrc
@@ -223,17 +228,20 @@ augroup END
"
" We also need to check whether the directory 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 versions of Vim before v8.0.1708.
-" These versions throw errors if the directory already exists, even with 'p',
-" contrary to what someone familiar with `mkdir -p`'s behaviour in shell
-" script might expect.
-"
-" So, let's wrap all that in a script-local function, and then hide it behind
-" a user command, to keep the commands required to establishing a path is in
-" place nice and simple. We'll lock down all the directories that we create
-" with restrictive permissions, too. Who knows what secrets are in your file
-" buffers?
+" because until v8.0.1708, mkdir() raises an error if the directory to be
+" created already exists, even with a {path} of 'p', where the analogous
+" `mkdir` shell command does not do so with its -p option included.
+"
+" <https://github.com/vim/vim/releases/tag/v8.0.1708>
+"
+" So, let's wrap that logic in a script-local function s:Establish(), and then
+" hide it behind a user command :Establish. We'll lock down all the
+" directories that we create with restrictive permissions, too. Who knows
+" what secrets are in your file buffers?
+
+" We set the command's tab completion to provide directory names as
+" candidates, and specify that there must be only one argument, which we'll
+" provide as a quoted parameter to the function.
"
function! s:Establish(path) abort
let path = expand(a:path)
@@ -241,12 +249,6 @@ function! s:Establish(path) abort
call mkdir(path, 'p', 0700)
endif
endfunction
-
-" Now we define the :Establish command for user-level access to the
-" s:Establish() function. We set the tab completion to provide directory
-" names as candidates, and specify that there must be only one argument, which
-" we'll provide as a quoted parameter to the function.
-"
command! -bar -complete=dir -nargs=1 Establish
\ call s:Establish(<q-args>)
@@ -258,34 +260,36 @@ command! -bar -complete=dir -nargs=1 Establish
"
Establish $MYVIM
-" Our next application of the :Establish command is to configure the path for
-" the viminfo metadata file, putting it in a cache subdirectory of the user
-" runtime directory.
+" Our next application of our new :Establish command is to configure the path
+" for the viminfo metadata file, putting it in a cache subdirectory of the
+" user runtime directory set in MYVIM.
"
" Using this non-default location for viminfo has the nice benefit of
" preventing command and search history from getting clobbered when something
" runs Vim without using this vimrc, because such an instance will safely
" write its history to the default viminfo path instead. It also contributes
-" to our aim of having everything related to the Vim runtime process somewhere
-" within the MYVIM directory.
+" to our aim of having everything related to the Vim runtime process in one
+" dedicated directory tree.
"
" The normal method of specifying the path to the viminfo file, as applied
" here, is an addendum of the path to the 'viminfo' option with an "n" prefix.
" Vim v8.1.716 introduced a nicer way to set this with an option named
" 'viminfofile', which is too new for us to use just yet.
"
+" <https://github.com/vim/vim/releases/tag/v8.1.0716>
+"
Establish $MYVIM/cache
set viminfo+=n$MYVIM/cache/viminfo
-" Speaking of recorded data in viminfo files, the command and search history
-" count default limit of 50 is pretty restrictive. Because I don't think I'm
-" ever likely to be in a situation where remembering several thousand Vim
-" commands and search patterns is going to severely tax memory, let alone disk
-" space, I'd rather this limit were much higher; it's sometimes really handy
-" to dig up commands from many days ago.
+" Speaking of recorded data in viminfo files, the default Vim limit of a mere
+" 50 entries for command and search history is pretty mean. Because I don't
+" think I'm ever likely to be in a situation where remembering several
+" thousand Vim commands and search patterns is going to severely tax memory,
+" let alone disk space, I'd rather this limit were much higher. It's
+" sometimes really handy to dig up commands from many days ago.
"
-" The maximum value for the 'history' option is documented in :help as 10000,
-" so let's just use that, and see if anything breaks.
+" The maximum value for the 'history' option is documented in `:help
+" 'history'` as 10000, so let's just use that, and see if anything breaks.
"
set history=10000
@@ -300,9 +304,9 @@ set backup
" directory, to stop them popping up next to the file to which they
" correspond, and getting committed to version control.
"
-" If Vim is new enough (v8.1.251), we'll add two trailing slashes to the path
-" we're inserting, which prompts Vim to incorporate the full escaped path of
-" the relevant buffer in the backup filename, avoiding collisions.
+" If Vim is new enough, we'll add two trailing slashes to the path we're
+" inserting, which prompts Vim to incorporate the full escaped path of the
+" relevant buffer in the backup filename, avoiding collisions.
"
" As a historical note, other similar directory path list options supported
" this trailing slashes hint for a long time before 'backupdir' caught up to
@@ -310,10 +314,12 @@ set backup
" far back as v5.8.0 (2001), and 'undodir' appears to have supported it since
" its creation in v7.2.438. Even though the :help for 'backupdir' didn't say
" so, people assumed it would work the same way, when in fact Vim simply
-" ignored it until v8.1.251. I don't want to add the slashes to the option
+" ignored it until v8.1.0251. I don't want to add the slashes to the option
" value in older versions of Vim where they don't do anything, so we'll check
" the version ourselves to see if there's any point in including them.
"
+" <https://github.com/vim/vim/releases/tag/v8.1.0251>
+"
" It's all so awkward. Surely separate options named something like
" 'backupfullname', 'swapfilefullname' would have been clearer.
"
@@ -366,8 +372,8 @@ set directory^=$MYVIM/cache/swap//
" directory, so that the u/:undo and CTRL-R/:redo commands will work between
" Vim invocations.
"
-" Support for persistent undo file caches was not added until v7.2.438, so we
-" need to check for the feature's presence before we enable it.
+" Support for these persistent undo file caches was not released until v7.3.0,
+" so we need to check for the feature's presence before we enable it.
"
if has('persistent_undo')
@@ -409,7 +415,7 @@ endif
" `install-vim-thesaurus`.
"
" I got the thesaurus itself from the link in the :help for 'thesaurus' in
-" v8.1.1487. It's from WordNet and MyThes-1. I maintain a mirror on my own
+" v8.1. It's from WordNet and MyThes-1. I maintain a mirror on my own
" website that the Makefile recipe attempts to retrieve. I had to remove the
" first two metadata lines from thesaurus.txt, as Vim appeared to interpret
" them as part of the body data.
@@ -482,6 +488,8 @@ set shiftwidth=4 " Indent command like < and > use four-space indents
" Vim is new enough to support it (v7.3.693), apply a negative value to do
" this dynamically if 'shiftwidth' changes.
"
+" <https://github.com/vim/vim/releases/tag/v7.3.693>
+"
if v:version > 730 || v:version == 730 && has('patch693')
set softtabstop=-1
else
@@ -504,13 +512,16 @@ set backspace+=start " Text before the start of the current insertion
set linebreak
" Similarly, show that the screen line is a trailing part of a wrapped line by
-" prefixing it with an ellipsis. If we have a multi-byte encoding, use U+2026
-" HORIZONTAL ELLIPSIS to save a couple of columns, but otherwise three periods
-" will do just fine.
+" prefixing it with an ellipsis. If we have a multi-byte encoding, use
+" a proper ellipsis character to save a couple of columns, but otherwise three
+" periods will do just fine.
+"
+" … U+2026 HORIZONTAL ELLIPSIS
"
" Note that we test for the presence of a multi-byte encoding with a special
-" feature from `:help feature-list`, as recommended by `:help encoding`;
-" checking that `&encoding ==# 'utf-8'` is not quite the same thing.
+" feature from `:help feature-list`, as recommended by `:help encoding`.
+" Checking that `&encoding ==# 'utf-8'` is not quite the same thing, though
+" it's unlikely I'll ever use a different Unicode encoding by choice.
"
if has('multi_byte_encoding')
set showbreak=…
@@ -532,14 +543,15 @@ endif
" The 'breakindent' option wasn't added until v7.4.338, so we need to check it
" exists before we set it.
"
+" <https://github.com/vim/vim/releases/tag/v7.4.338>
+"
if exists('+breakindent')
set breakindent
endif
" Rather than rejecting operations like :write or :saveas when 'readonly' is
-" set, and other situations in which data might be lost or I'm acting against
-" an option, Vim should give me a prompt to allow me to confirm that I know
-" what I'm doing.
+" set or in other situations in which data might be lost, Vim should give me
+" a prompt to allow me to confirm that I know what I'm doing.
"
set confirm
@@ -606,6 +618,8 @@ set formatoptions+=1
" suppress errors for this sort of thing when I can reasonably avoid it, even
" if the tests are somewhat more verbose.
"
+" <https://github.com/vim/vim/releases/tag/v7.3.541>
+"
if v:version > 730 || v:version == 730 && has('patch541')
set formatoptions+=j
endif
@@ -644,7 +658,7 @@ set cpoptions+=J
" does. I wrote the patch that added it, after becoming envious of an
" analogous feature during an ill-fated foray into GNU Emacs usage.
"
-" <https://github.com/vim/vim/commit/c3c3158>
+" <https://github.com/vim/vim/releases/tag/v8.1.1523>
"
if has('patch-8.1.728')
set formatoptions+=p
@@ -872,19 +886,27 @@ set wildmode=list:longest,full
" giving patterns for the top 100 alphanumeric extensions for files from the
" running user's home directory:
"
-" $ find "$HOME" ! -type d -name '*.?*' -exec \
+" $ (LC_ALL=C find "$HOME" ! -type d -name '*.?*' -exec \
" sh -c 'for fn ; do
" ext=${fn##*.}
" case $ext in
-" *[![:alnum:]]*) continue ;;
-" ?*) printf "%s\n" "$ext" ;;
+" (*[![:alnum:]]*) continue ;;
+" (?*) printf "%s\n" "$ext" ;;
" esac
" done' _ {} + |
-" tr '[:upper:]' '[:lower:]' | sort | uniq -c |
-" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}'
+" tr '[[:upper:]]' '[[:lower:]]' | sort | uniq -c |
+" sort -k1,1nr | awk 'NR <= 100 {print "*." $2}')
"
" I turned out to have rather a lot of .html and .vim files.
"
+" If you're scoffing at that and thinking "I could write a much simpler one",
+" please do so, and send it to me at <tom@sanctum.geek.nz> to have yours put
+" in here instead, with appropriate credit. Don't forget to handle more than
+" ARG_MAX files, include filenames with newlines, and that the -z or -0 null
+" separator extensions are not standardised in POSIX.
+"
+" <https://mywiki.wooledge.org/UsingFind#Complex_actions>
+"
" It's tempting to put the list of patterns here into a separate file--or at
" least into a more readily editable intermediate list variable--rather than
" the minor maintenance hassle it presently constitutes in this compact form.
@@ -911,6 +933,8 @@ set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup
" The option wasn't added until v7.3.72, so we need to check it exists before
" we try to set it.
"
+" <https://github.com/vim/vim/releases/tag/v7.3.072>
+"
if exists('+wildignorecase')
set wildignorecase
endif