aboutsummaryrefslogtreecommitdiff
path: root/vim/vimrc
diff options
context:
space:
mode:
Diffstat (limited to 'vim/vimrc')
-rw-r--r--vim/vimrc122
1 files changed, 62 insertions, 60 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 40e744c1..d60d66fd 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -2,7 +2,7 @@
" Tom Ryder (tejr)’s Literate Vimrc
" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
"
-" Last updated: Sun, 03 May 2020 03:46:29 UTC
+" Last updated: Mon, 04 May 2020 00:51:58 UTC
"
" │ And I was lifted up in heart, and thought
" │ Of all my late-shown prowess in the lists,
@@ -18,89 +18,94 @@
" tradition of Donald Knuth’s “literate programming”:
" <http://www.literateprogramming.com/>
"
-" The dotfiles project that comprises it is maintained here:
+" The dotfiles project as part of which it is maintained is here:
" <https://sanctum.geek.nz/cgit/dotfiles.git>
"
-" This is a long file, and comments abound within. Should this be bothersome,
-" one could execute this command in Vim itself to strip out all lines either
-" blank or comprising solely comments:
+" This is a long file, and comments abound. Should this be bothersome, one
+" could execute this command in Vim itself, to strip out comment blocks and
+" blank lines:
"
" :g/\m^$\|^\s*"/d
"
-" This file should be saved as ‘vimrc’—no leading period—in the user runtime
-" directory. On Unix-like operating systems, hereinafter referred to as
-" “*nix”, that directory is ‘~/.vim’; on Windows, it’s ‘~/vimfiles’.
-" Fortunately, those are the only two kinds of operating systems that exist,
-" anywhere in the world.
+" This file requires Vim v7.0.0 or newer—including the +eval feature—and with
+" the 'compatible' option turned off, chiefly to allow line continuations in
+" Vim script. The vimrc stub at ~/.vimrc (Unix) or ~/_vimrc (Windows) should
+" check that these conditions are met before loading this file with ‘:runtime
+" vimrc’. It should be saved as ‘vimrc’—note no leading period—in the user
+" runtime directory. On GNU/Linux, Mac OS X, and BSD, that directory is
+" ‘~/.vim’. On Windows, it’s ‘~/vimfiles’.
"
-" It requires Vim v7.0.0 or newer, with the +eval feature, and the
-" 'compatible' option turned off, chiefly to allow line continuations. The
-" vimrc stub at ~/.vimrc (Unix) or ~/_vimrc (Windows) should check that these
-" conditions are met before loading this file with ‘:runtime vimrc’.
-"
-" All of this should survive a pass of the Vim script linter Vint with no
+" The whole file should survive a pass of the Vim script linter Vint with no
" errors, warnings, or style problems: <https://github.com/Kuniwak/vint>
"
-
" We’ll begin by making sure that we and Vim are speaking the same language.
-" Since it’s been the future for a few years now, this file has characters
-" outside the ASCII character set, which prompts Vint to suggest declaring the
-" file encoding with a :scriptencoding command. The :help for that command
-" specifies that this should be done after 'encoding' is set, so we’ll do that
-" here, too.
-"
-" On *nix, I define the primary locale environment variable $LANG, almost
-" always specifying a multi-byte locale. This informs Vim’s choice of
-" internal character encoding, but the default for the 'encoding' option in
-" the absence of a valid $LANG is ‘latin1’. Since this is almost never what
-" I want, we’ll manually choose the UTF-8 encoding for Unicode in the absence
-" of any other explicit specification.
-"
-if &encoding ==# 'latin1' && !exists('$LANG')
- set encoding=utf-8
+" Since it’s been the future for a few years now, this file indulges in
+" characters outside the ASCII character set. This prompts Vint to suggest
+" declaring the file encoding with a :scriptencoding command. The :help for
+" :scriptencoding specifies that this should be done after 'encoding' is set,
+" so we’ll do that here first.
+"
+" On POSIX-fearing operating systems, I define the primary locale environment
+" variable $LANG, almost always specifying a multi-byte locale. This informs
+" Vim’s choice of internal character encoding. The default for the 'encoding'
+" option in the absence of a valid $LANG setting is ‘latin1’. Since this is
+" almost never what I want, we’ll explicitly fall back to the UTF-8 encoding
+" for Unicode, in the absence of any other explicit specification. We need to
+" test that the +multi_byte feature is available before doing this, however,
+" since it was a non-default compile-time option in Vim v7.0.
+"
+if has#('multi_byte')
+ if &encoding ==# 'latin1' && !exists('$LANG')
+ set encoding=utf-8
+ endif
+ scriptencoding utf-8
endif
-scriptencoding utf-8
" With encoding handled, we’ll turn our attention to the value of the
" 'runtimepath' option, since any scripts loaded from the paths specified
-" therein control so much of the behavior of Vim. I’d like to do this as
+" therein control so much of the behavior of Vim. We build this path up as
" accurately as possible, even with Vim’s unusual behavior around escaping of
" these variables. One of the first things we’ll need to be able to do is
" split the value of 'runtimepath' into its constituent path parts.
"
-" Splitting the values of comma-separated options correctly is surprisingly
-" complicated. The list separator for such options is more accurately defined
-" as follows:
+" Correctly splitting the values of comma-separated Vim options is
+" surprisingly complicated. The delimiter for such options is not simply
+" any comma; it is more accurately defined as follows:
"
-" │ A comma not preceded by a backslash, and possibly followed by an arbitrary
-" │ number of spaces and commas.
+" │ Any comma not preceded by a backslash, followed by any number of spaces
+" │ and commas.
"
-" The pattern required for the split breaks down like this:
+" The pattern required for the split therefore breaks down like this:
"
-" \\ ← Literal backslash
-" \@<! ← Negative lookbehind assertion; means that whatever occurred
-" before this pattern, here a backslash, cannot precede what
-" follows, but anything that does precede it is not removed from
-" the data as part of the split delimiter
-" , ← Literal comma
+" \\ ← A literal backslash
+" \@<! ← A negative lookbehind assertion; this means that whatever
+" occurred before this pattern, here a backslash, cannot precede
+" what follows, but anything that does precede it is not removed
+" from the data as part of the split delimiter
+" , ← A literal comma
" [, ]* ← Any number of commas and spaces
"
" We don’t, however, have to deal with backslashes before other backslashes,
" nor before any other character. You can read the source code for the ad-hoc
" tokenizer in copy_option_part() in src/misc2.c in Vim’s source code, and
-" test it with some values of your own, if you want to understand why. Vim,
-" I love you, but you are really weird sometimes.
+" test it with some values of your own, if you want to understand why.
"
-" We do all this with an autoloaded function option#Split().
+" Vim, I love you, but you are really weird sometimes.
"
-" We define an environment variable for ~/.vim or ~/vimfiles, by retrieving
-" the first value from the 'runtimepath', correctly split.
+" We do all this with an autoloaded function option#Split(); see
+" vim/autoload/option.vim. Provided a 'runtimepath' is actually set, using
+" the list returned from that function, we define an environment variable
+" MYVIM—to complement MYVIMRC—for ~/.vim or ~/vimfiles, by retrieving the
+" first value from the 'runtimepath'.
"
if &runtimepath !=# ''
let $MYVIM = option#Split(&runtimepath)[0]
endif
-" We'll use the XDG directories as machine-local configuration and storage.
+" The next components of the runtime directory that we'll set up here will be
+" the XDG base directories, for machine-local configuration and storage for
+" files outside this repository.
+"
" <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables>
"
" Add all the configuration directories to 'runtimepath', including "after"
@@ -391,14 +396,11 @@ set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
" In much the same way, we add an expected path to a thesaurus, for completion
" with CTRL-X CTRL-T in insert mode, or with ‘t’ added to 'completeopt'. The
" thesaurus data isn’t installed as part of the default ‘install-vim’ target
-" in tejr’s dotfiles, but it can be retrieved from
-" <https://sanctum.geek.nz/ref/thesaurus.txt>.
-"
-" I got the thesaurus itself from the link in the :help for 'thesaurus' in
-" 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.
+" in tejr’s dotfiles, but a decent one can be retrieved from my website at
+" <https://sanctum.geek.nz/ref/thesaurus.txt>. I got this from the link in
+" the :help for 'thesaurus' in v8.1. It’s from WordNet and MyThes-1. I had
+" to remove the first two metadata lines from thesaurus.txt, as Vim appeared
+" to interpret them as part of the body data.
"
" Extra checks for appending the 'dictionary' and 'thesaurus' paths need to be
" made, because the P_NDNAME property is assigned to them, which enforces