diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2020-04-30 15:51:21 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-02 23:39:23 +1200 |
commit | c4cabee3880258b23bf22a1ff9b2d5f94949cd11 (patch) | |
tree | 2871ae80665911634684d8184397521462a0ffbd /vim/vimrc | |
parent | Don't use tmux terminfo file for now (diff) | |
download | dotfiles-c4cabee3880258b23bf22a1ff9b2d5f94949cd11.tar.gz dotfiles-c4cabee3880258b23bf22a1ff9b2d5f94949cd11.zip |
Working on rewording vimrc
Diffstat (limited to 'vim/vimrc')
-rw-r--r-- | vim/vimrc | 109 |
1 files changed, 57 insertions, 52 deletions
@@ -2,7 +2,7 @@ " Tom Ryder (tejr)’s Literate Vimrc " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ " -" Last updated: Wed, 29 Apr 2020 02:53:22 UTC +" Last updated: Wed, 29 Apr 2020 23:52:08 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('+multibyte') + 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', and then put the |