aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-08 13:55:18 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-08 13:55:18 +1300
commit8ddb8ba683cee22f930dd48d85a117ce07be5cac (patch)
tree47bbb9e862b227d758ebb9643ab23f649c463d8c
parentMerge branch 'hotfix/v0.11.1' (diff)
parentUpdate dotfiles(7) manual from README.md (diff)
downloaddotfiles-0.12.0.tar.gz (sig)
dotfiles-0.12.0.zip
Merge branch 'release/v0.12.0'v0.12.0
* release/v0.12.0: Update dotfiles(7) manual from README.md Bump version to 0.12.0 Use "nunmap" not "unmap" for b:undo_* var Remove null command from b:undo_* variables Use consistent/thorough ftplugin/indent unloading Add clustering for POSIX shell syntax groups Add `kill` as shStatement Add `break`, `continue`, `return` as shStatement Override commands and variables for syntax/sh.vim Disable unwanted shell error syntax for any shell Break a long conditional in vim/ftdetect/sh.vim Rename b:check and b:lint with sh_ prefix Remove overkill defined-and-false check of sh vars Clear b:check/lint in ftdetect/sh.vim b:undo Move ftplugin/sh.vim b:undo def to end of file Use correct undo variable name in ftplugin/sh.vim Remove superfluous augroups around ftdetect defs Use sh.vim local vars not global POSIX hacks Spell-checked and corrected README.md
-rw-r--r--README.md72
-rw-r--r--VERSION4
-rw-r--r--man/man7/dotfiles.7df61
-rw-r--r--vim/after/syntax/sh.vim113
-rw-r--r--vim/ftdetect/csv.vim9
-rw-r--r--vim/ftdetect/muttrc.vim9
-rw-r--r--vim/ftdetect/sh.vim34
-rw-r--r--vim/ftdetect/tsv.vim9
-rw-r--r--vim/ftdetect/xdefaults.vim9
-rw-r--r--vim/ftplugin/html.vim6
-rw-r--r--vim/ftplugin/mail.vim2
-rw-r--r--vim/ftplugin/markdown.vim6
-rw-r--r--vim/ftplugin/perl.vim6
-rw-r--r--vim/ftplugin/sh.vim65
-rw-r--r--vim/ftplugin/text.vim6
-rw-r--r--vim/ftplugin/vim.vim4
-rw-r--r--vim/indent/csv.vim2
-rw-r--r--vim/indent/tsv.vim2
-rw-r--r--vim/indent/vim.vim10
19 files changed, 259 insertions, 170 deletions
diff --git a/README.md b/README.md
index bc84d378..f145eb72 100644
--- a/README.md
+++ b/README.md
@@ -48,10 +48,10 @@ installed.
* `install-vim`
The `install-login-shell` looks at your `SHELL` environment variable and tries
-to figure out which shell’s configuration files to install, falling back on
+to figure out which shell's configuration files to install, falling back on
`install-sh`.
-The remaining dotfiles can be installed with the other `install-*` targets. Try
+The remaining files can be installed with the other `install-*` targets. Try
`awk -f bin/mftl.awk Makefile` in the project's root directory to see a list.
Tools
@@ -85,7 +85,7 @@ Configuration is included for:
client
* [Perl::Critic](http://perlcritic.com/) -- static source code analysis
engine for Perl
-* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl indenter and
+* [Perl::Tidy](http://perltidy.sourceforge.net/) -- Perl source code
reformatter
* [Readline](https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) -- GNU
library for user input used by Bash, MySQL, and others
@@ -167,8 +167,9 @@ based on context to include these elements in this order:
You can set `PROMPT_COLOR`, `PROMPT_PREFIX`, and `PROMPT_SUFFIX` too, which all
do about what you'd expect.
-If you start up Bash, Ksh, or Zsh and it detects that it's not normally your
-`$SHELL`, the prompt will display an appropriate prefix.
+If you start up Bash, Korn shell, or Z shell, and it detects that it's normally
+your `$SHELL` is one of the other two, the prompt will display an appropriate
+prefix.
This is all managed within the `prompt` function. There's some mildly hacky
logic on `tput` codes included such that it should work correctly for most
@@ -270,10 +271,11 @@ These are experimental; they are mostly used to tinker with MirBSD `mksh`, AT&T
`ksh93`, and OpenBSD `pdksh`. All shells in this family default to a yellow
prompt if detected.
-#### Zsh
+#### Z shell
-These are experimental; I do not like Zsh much at the moment. The files started
-as a joke (`exec bash`). `zsh` shells default to having a prompt coloured cyan.
+These are experimental; I do not like Z shell much at the moment. The files
+started as a joke (`exec bash`). `zsh` shells default to having a prompt
+colored cyan.
### GnuPG
@@ -289,7 +291,7 @@ My mail is kept in individual Maildirs under `~/Mail`, with `inbox` being where
most unfiltered mail is sent. I use
[Getmail](http://pyropus.ca/software/getmail/),
[maildrop](https://www.courier-mta.org/maildrop/), and
-[MSMTP](http://msmtp.sourceforge.net/); the configurations for these are not
+[msmtp](http://msmtp.sourceforge.net/); the configurations for these are not
included here. I sign whenever I have some indication that the recipient might
be using a PGP implementation, and I encrypt whenever I have a public key
available for them. The GnuPG and S/MIME interfacing is done with
@@ -322,7 +324,7 @@ make ಠ\_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box.
### tmux
These are just generally vi-friendly settings, not much out of the ordinary.
-Note that the configuration presently uses a hard-coded 256-color colorscheme,
+Note that the configuration presently uses a hard-coded 256-color color scheme,
and uses non-login shells, with an attempt to control the environment to stop
shells thinking they have access to an X display.
@@ -334,14 +336,14 @@ combination to detach.
### Vim
The majority of the Vim configuration is just setting options, with a few
-mappings. I try not to deviate too much from the Vim defaults behaviour in
-terms of interactive behavior and keybindings.
+mappings. I try not to deviate too much from the Vim defaults behavior in terms
+of interactive behavior and keybindings.
-The configuration is broken into subfiles in `~/.vim/config/*.vim`, included by
-`~/.vimrc` using
+The configuration is broken into smaller files in `~/.vim/config/*.vim`,
+included by `~/.vimrc` using
[`:runtime`](http://vimdoc.sourceforge.net/htmldoc/repeat.html#:runtime). It's
extensively commented, mostly because I was reading through it one day and
-realised I'd forgotten what half of it did.
+realized I'd forgotten what half of it did.
#### Plugins
@@ -350,14 +352,13 @@ structures like functions, I like to implement it as a plugin in
`~/.vim/plugin` and/or `~/.vim/autoload`. There's documentation for each of
those in `~/.vim/doc`.
-I also define a few custom per-filetype rules for stuff I often edit in
+I also define a few rules specific to file types I often edit in
`~/.vim/ftplugin`, including some local mappings for checking, linting, and
tidying.
-Any/all of the general or filetype plugins may eventually be spun off into
-their own repositories in the future, but for the moment they live here.
-Contact me if you find one of them useful and you'd like to see it in its own
-distribution.
+Any/all of the plugins may eventually be spun off into their own repositories
+in the future, but for the moment they live here. Contact me if you find one of
+them useful and you'd like to see it in its own distribution.
Third-party plugins are in submodules in `~/.vim/bundle`, loaded using Tim
Pope's [pathogen.vim](https://github.com/tpope/vim-pathogen).
@@ -417,12 +418,12 @@ Installed by the `install-bin` target:
* `supp(1df)` converts lowercase to uppercase.
* `tl(1df)` tags input lines with a prefix or suffix, basically a
`sed(1)` shortcut.
- * `tlcs(1df)` executes a command and uses `tl(1df)` to tag stdout and
- stderr lines, and color them if you want.
+ * `tlcs(1df)` executes a command and uses `tl(1df)` to tag standard
+ output and standard error lines, and color them if you want.
* `unf(1df)` joins lines with leading spaces to the previous line.
Intended for unfolding HTTP headers, but it should work for most RFC
822 formats.
-* Six simple aggregators for numbers:
+* Six simple aggregate scripts for numbers:
* `max(1df)` prints the maximum.
* `mean(1df)` prints the mean.
* `med(1df)` prints the median.
@@ -457,9 +458,9 @@ Installed by the `install-bin` target:
* `pvi(1df)` runs `pvi(1df)` with `$VISUAL` or `vi(1)`.
* `ap(1df)` reads arguments for a given command from the standard input,
prompting if appropriate.
-* `apf(1df)` prepends arguments to a command with ones read from a file,
+* `apf(1df)` inserts arguments to a command with ones read from a file,
intended as a framework for shell wrappers or functions.
-* `ax(1df)` evaluates an awk expression given on the command line; this is
+* `ax(1df)` evaluates an AWK expression given on the command line; this is
intended as a quick way to test how Awk would interpret a given expression.
* `bcq(1df)` runs `bc(1)`, quieting it down if need be.
* `bel(1df)` prints a terminal bell character.
@@ -492,28 +493,27 @@ Installed by the `install-bin` target:
`find(1)` conditions.
* `fnl(1df)` runs a command and saves its output and error into temporary
files, printing their paths and line counts.
-* `fnp(1df)` prints the given files to stdout, each with a plaintext heading
- with the filename in it.
+* `fnp(1df)` prints the given files to standard output, each with a plain
+ text heading with the filename in it.
* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the
script `getmails` in the `getmail` suite, but runs the requests in parallel
and does up to three silent retries using `try(1df)`.
* `grec(1df)` is a more logically-named `grep -c`.
* `gred(1df)` is a more logically-named `grep -v`.
* `gwp(1df)` searches for alphanumeric words in a similar way to `grep(1)`.
-* `han(1df)` provides a `keywordprg` for Vim's Bash script filetype that will
- look for `help` topics. You could use it from the shell too.
+* `han(1df)` provides a `keywordprg` for Vim's Bash script file type that
+ will look for `help` topics. You could use it from the shell too.
* `igex(1df)` wraps around a command to allow you to ignore error conditions
that don't actually worry you, exiting with 0 anyway.
-* `ix(1df)` posts its input to the ix.io pastebin.
+* `ix(1df)` posts its input to the `ix.io` pastebin.
* `jfp(1df)` prints its input, excluding any shebang on the first line only.
* `loc(1df)` is a quick-search wrapped around `find(1)`.
* `maybe(1df)` is like `true(1)` or `false(1)`; given a probability of
success,
it exits with success or failure. Good for quick tests.
* `mex(1df)` makes given filenames in `$PATH` executable.
-* `mi5(1df)` pre-processes a crude but less painful macro expansion file
- format into `m4` input.
-* `mftl(1df)` finds usable-looking targets in Makefiles.
+* `mi5(1df)` is a crude preprocessor for `m4`.
+* `mftl(1df)` finds usable-looking targets in makefiles.
* `mkcp(1df)` creates a directory and copies preceding arguments into it.
* `mkmv(1df)` creates a directory and moves preceding arguments into it.
* `motd(1df)` shows the system MOTD.
@@ -571,8 +571,8 @@ There's some silly stuff in `install-games`:
* `aaf(6df)` gets a random [ASCII Art Farts](http://www.asciiartfarts.com/)
comic.
* `acq(6df)` allows you to interrogate AC, the interplanetary computer.
-* `aesth(6df)` converts English letters to their fullwidth CJK analogues, for
- AESTHETIC PURPOSES.
+* `aesth(6df)` converts English letters to their full width CJK analogues,
+ for AESTHETIC PURPOSES.
* `squ(6df)` makes a reduced Latin square out of each line of input.
* `kvlt(6df)` translates input to emulate a style of typing unique to black
metal communities on the internet.
@@ -582,7 +582,7 @@ There's some silly stuff in `install-games`:
* `strik(6df)` outputs s̶t̶r̶i̶k̶e̶d̶ ̶o̶u̶t̶ struck out text.
* `rot13(6df)` rotates the Latin letters in its input.
* `xyzzy(6df)` teleports to a marked location on the filesystem.
-* `zs(6df)` prepends "z" case-appropriately to every occurrence of "s" in the
+* `zs(6df)` prefixes "z" case-appropriately to every occurrence of "s" in the
text on its standard input.
Manuals
diff --git a/VERSION b/VERSION
index cd2f965d..12d72a28 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v0.11.1
-Tue Nov 7 01:52:09 UTC 2017
+tejr dotfiles v0.12.0
+Wed Nov 8 00:54:30 UTC 2017
diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df
index fbb1da64..0b8ab981 100644
--- a/man/man7/dotfiles.7df
+++ b/man/man7/dotfiles.7df
@@ -72,8 +72,8 @@ The \f[C]install\-login\-shell\f[] looks at your \f[C]SHELL\f[]
environment variable and tries to figure out which shell's configuration
files to install, falling back on \f[C]install\-sh\f[].
.PP
-The remaining dotfiles can be installed with the other
-\f[C]install\-*\f[] targets.
+The remaining files can be installed with the other \f[C]install\-*\f[]
+targets.
Try \f[C]awk\ \-f\ bin/mftl.awk\ Makefile\f[] in the project's root
directory to see a list.
.SS Tools
@@ -130,7 +130,7 @@ PostgreSQL client
Perl::Critic (http://perlcritic.com/) \[en] static source code analysis
engine for Perl
.IP \[bu] 2
-Perl::Tidy (http://perltidy.sourceforge.net/) \[en] Perl indenter and
+Perl::Tidy (http://perltidy.sourceforge.net/) \[en] Perl source code
reformatter
.IP \[bu] 2
Readline (https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html)
@@ -240,8 +240,9 @@ The exit status of the last command, if non\-zero.
You can set \f[C]PROMPT_COLOR\f[], \f[C]PROMPT_PREFIX\f[], and
\f[C]PROMPT_SUFFIX\f[] too, which all do about what you'd expect.
.PP
-If you start up Bash, Ksh, or Zsh and it detects that it's not normally
-your \f[C]$SHELL\f[], the prompt will display an appropriate prefix.
+If you start up Bash, Korn shell, or Z shell, and it detects that it's
+normally your \f[C]$SHELL\f[] is one of the other two, the prompt will
+display an appropriate prefix.
.PP
This is all managed within the \f[C]prompt\f[] function.
There's some mildly hacky logic on \f[C]tput\f[] codes included such
@@ -403,11 +404,11 @@ Otherwise, they're all loaded on startup.
These are experimental; they are mostly used to tinker with MirBSD
\f[C]mksh\f[], AT&T \f[C]ksh93\f[], and OpenBSD \f[C]pdksh\f[].
All shells in this family default to a yellow prompt if detected.
-.SS Zsh
+.SS Z shell
.PP
-These are experimental; I do not like Zsh much at the moment.
+These are experimental; I do not like Z shell much at the moment.
The files started as a joke (\f[C]exec\ bash\f[]).
-\f[C]zsh\f[] shells default to having a prompt coloured cyan.
+\f[C]zsh\f[] shells default to having a prompt colored cyan.
.SS GnuPG
.PP
The configuration for GnuPG is intended to follow RiseUp's OpenPGP best
@@ -422,7 +423,7 @@ My mail is kept in individual Maildirs under \f[C]~/Mail\f[], with
\f[C]inbox\f[] being where most unfiltered mail is sent.
I use Getmail (http://pyropus.ca/software/getmail/),
maildrop (https://www.courier-mta.org/maildrop/), and
-MSMTP (http://msmtp.sourceforge.net/); the configurations for these are
+msmtp (http://msmtp.sourceforge.net/); the configurations for these are
not included here.
I sign whenever I have some indication that the recipient might be using
a PGP implementation, and I encrypt whenever I have a public key
@@ -461,7 +462,7 @@ The Lohit Kannada font bit is purely to make ಠ_ಠ work correctly.
These are just generally vi\-friendly settings, not much out of the
ordinary.
Note that the configuration presently uses a hard\-coded 256\-color
-colorscheme, and uses non\-login shells, with an attempt to control the
+color scheme, and uses non\-login shells, with an attempt to control the
environment to stop shells thinking they have access to an X display.
.PP
The shell scripts in \f[C]bin\f[] include \f[C]tm(1df)\f[], a shortcut
@@ -473,14 +474,14 @@ binds the same key combination to detach.
.PP
The majority of the Vim configuration is just setting options, with a
few mappings.
-I try not to deviate too much from the Vim defaults behaviour in terms
-of interactive behavior and keybindings.
+I try not to deviate too much from the Vim defaults behavior in terms of
+interactive behavior and keybindings.
.PP
-The configuration is broken into subfiles in
+The configuration is broken into smaller files in
\f[C]~/.vim/config/*.vim\f[], included by \f[C]~/.vimrc\f[] using
\f[C]:runtime\f[] (http://vimdoc.sourceforge.net/htmldoc/repeat.html#:runtime).
It's extensively commented, mostly because I was reading through it one
-day and realised I'd forgotten what half of it did.
+day and realized I'd forgotten what half of it did.
.SS Plugins
.PP
If the logic for doing something involves more than a few lines or any
@@ -488,13 +489,12 @@ structures like functions, I like to implement it as a plugin in
\f[C]~/.vim/plugin\f[] and/or \f[C]~/.vim/autoload\f[].
There's documentation for each of those in \f[C]~/.vim/doc\f[].
.PP
-I also define a few custom per\-filetype rules for stuff I often edit in
+I also define a few rules specific to file types I often edit in
\f[C]~/.vim/ftplugin\f[], including some local mappings for checking,
linting, and tidying.
.PP
-Any/all of the general or filetype plugins may eventually be spun off
-into their own repositories in the future, but for the moment they live
-here.
+Any/all of the plugins may eventually be spun off into their own
+repositories in the future, but for the moment they live here.
Contact me if you find one of them useful and you'd like to see it in
its own distribution.
.PP
@@ -604,14 +604,14 @@ Seven stream formatting scripts:
\f[C]sed(1)\f[] shortcut.
.IP \[bu] 2
\f[C]tlcs(1df)\f[] executes a command and uses \f[C]tl(1df)\f[] to tag
-stdout and stderr lines, and color them if you want.
+standard output and standard error lines, and color them if you want.
.IP \[bu] 2
\f[C]unf(1df)\f[] joins lines with leading spaces to the previous line.
Intended for unfolding HTTP headers, but it should work for most RFC 822
formats.
.RE
.IP \[bu] 2
-Six simple aggregators for numbers:
+Six simple aggregate scripts for numbers:
.RS 2
.IP \[bu] 2
\f[C]max(1df)\f[] prints the maximum.
@@ -691,10 +691,10 @@ along a pipeline.
\f[C]ap(1df)\f[] reads arguments for a given command from the standard
input, prompting if appropriate.
.IP \[bu] 2
-\f[C]apf(1df)\f[] prepends arguments to a command with ones read from a
+\f[C]apf(1df)\f[] inserts arguments to a command with ones read from a
file, intended as a framework for shell wrappers or functions.
.IP \[bu] 2
-\f[C]ax(1df)\f[] evaluates an awk expression given on the command line;
+\f[C]ax(1df)\f[] evaluates an AWK expression given on the command line;
this is intended as a quick way to test how Awk would interpret a given
expression.
.IP \[bu] 2
@@ -754,8 +754,8 @@ given \f[C]find(1)\f[] conditions.
\f[C]fnl(1df)\f[] runs a command and saves its output and error into
temporary files, printing their paths and line counts.
.IP \[bu] 2
-\f[C]fnp(1df)\f[] prints the given files to stdout, each with a
-plaintext heading with the filename in it.
+\f[C]fnp(1df)\f[] prints the given files to standard output, each with a
+plain text heading with the filename in it.
.IP \[bu] 2
\f[C]gms(1df)\f[] runs a set of \f[C]getmailrc\f[] files; does much the
same thing as the script \f[C]getmails\f[] in the \f[C]getmail\f[]
@@ -770,13 +770,13 @@ retries using \f[C]try(1df)\f[].
\f[C]grep(1)\f[].
.IP \[bu] 2
\f[C]han(1df)\f[] provides a \f[C]keywordprg\f[] for Vim's Bash script
-filetype that will look for \f[C]help\f[] topics.
+file type that will look for \f[C]help\f[] topics.
You could use it from the shell too.
.IP \[bu] 2
\f[C]igex(1df)\f[] wraps around a command to allow you to ignore error
conditions that don't actually worry you, exiting with 0 anyway.
.IP \[bu] 2
-\f[C]ix(1df)\f[] posts its input to the ix.io pastebin.
+\f[C]ix(1df)\f[] posts its input to the \f[C]ix.io\f[] pastebin.
.IP \[bu] 2
\f[C]jfp(1df)\f[] prints its input, excluding any shebang on the first
line only.
@@ -789,10 +789,9 @@ Good for quick tests.
.IP \[bu] 2
\f[C]mex(1df)\f[] makes given filenames in \f[C]$PATH\f[] executable.
.IP \[bu] 2
-\f[C]mi5(1df)\f[] pre\-processes a crude but less painful macro
-expansion file format into \f[C]m4\f[] input.
+\f[C]mi5(1df)\f[] is a crude preprocessor for \f[C]m4\f[].
.IP \[bu] 2
-\f[C]mftl(1df)\f[] finds usable\-looking targets in Makefiles.
+\f[C]mftl(1df)\f[] finds usable\-looking targets in makefiles.
.IP \[bu] 2
\f[C]mkcp(1df)\f[] creates a directory and copies preceding arguments
into it.
@@ -899,7 +898,7 @@ Farts (http://www.asciiartfarts.com/) comic.
\f[C]acq(6df)\f[] allows you to interrogate AC, the interplanetary
computer.
.IP \[bu] 2
-\f[C]aesth(6df)\f[] converts English letters to their fullwidth CJK
+\f[C]aesth(6df)\f[] converts English letters to their full width CJK
analogues, for AESTHETIC PURPOSES.
.IP \[bu] 2
\f[C]squ(6df)\f[] makes a reduced Latin square out of each line of
@@ -922,7 +921,7 @@ algorithm.
.IP \[bu] 2
\f[C]xyzzy(6df)\f[] teleports to a marked location on the filesystem.
.IP \[bu] 2
-\f[C]zs(6df)\f[] prepends \[lq]z\[rq] case\-appropriately to every
+\f[C]zs(6df)\f[] prefixes \[lq]z\[rq] case\-appropriately to every
occurrence of \[lq]s\[rq] in the text on its standard input.
.SS Manuals
.PP
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim
index d07f4cff..ba209e99 100644
--- a/vim/after/syntax/sh.vim
+++ b/vim/after/syntax/sh.vim
@@ -1,23 +1,104 @@
-" If g:is_posix is set, g:is_kornshell is probably set too, a strange decision
-" by sh.vim. No matter; we can tease out whether this is actually a Korn shell
-" script using our own b:is_ksh flag set at the end of ~/.vim/ftdetect/sh.vim,
-" and if it isn't, we'll throw away the highlighting groups for ksh.
-if exists('g:is_kornshell') && !exists('b:is_ksh')
- syntax clear kshSpecialVariables
- syntax clear kshStatement
+" If we know we have another shell type, clear away the others completely, now
+" that core syntax/sh.vim is done prodding /bin/sh to determine the system
+" shell type (which I don't care about).
+if exists('b:is_bash')
+ unlet! b:is_sh b:is_posix b:is_kornshell
+elseif exists('b:is_kornshell')
+ unlet! b:is_sh b:is_posix
+elseif exists('b:is_posix')
+ unlet! b:is_sh
endif
-" Some corrections for highlighting if we have any of POSIX, Bash, or Ksh
-if exists('g:is_posix') || exists('b:is_bash') || exists('b:is_ksh')
+" The syntax highlighter seems to flag '/baz' in '"${foo:-"$bar"/baz}"' as an
+" error, which it isn't, at least in POSIX sh, Bash, and Ksh.
+syntax clear shDerefWordError
+
+" The syntax highlighter doesn't match parens for subshells for 'if' tests
+" correctly if they're on separate lines. This happens enough that it's
+" probably not worth keeping the error.
+syntax clear shParenError
+
+" Highlighting corrections specific to POSIX mode
+if exists('b:is_posix')
- " The syntax highlighter seems to flag '/baz' in '"${foo:-"$bar"/baz}"' as an
- " error, and I'm pretty sure it's not, at least in POSIX sh, Bash, and Ksh.
- syntax clear shDerefWordError
+ " Highlight some commands that are both defined by POSIX and builtin
+ " commands in dash, as a rough but useable proxy for 'shell builtins'. This
+ " list was mostly wrested from `man 1 dash`. Also include control structure
+ " keywords like `break`, `continue`, and `return`.
+ syntax clear shStatement
+ syntax cluster shCommandSubList add=shStatement
+ syntax cluster shCaseList add=shStatement
+ syntax keyword shStatement
+ \ alias
+ \ bg
+ \ break
+ \ cd
+ \ command
+ \ continue
+ \ echo
+ \ eval
+ \ exec
+ \ exit
+ \ export
+ \ fc
+ \ fg
+ \ getopts
+ \ hash
+ \ kill
+ \ printf
+ \ pwd
+ \ read
+ \ readonly
+ \ return
+ \ set
+ \ shift
+ \ test
+ \ times
+ \ trap
+ \ true
+ \ type
+ \ ulimit
+ \ umask
+ \ unalias
+ \ unset
+ \ wait
- " The syntax highlighter doesn't match parens for subshells for 'if' tests
- " correctly if they're on separate lines. This happens enough that it's
- " probably not worth keeping the error.
- syntax clear shParenError
+ " Core syntax/sh.vim puts IFS and other variables that affect shell function
+ " in another color, but a subset of them actually apply to POSIX shell too
+ " (and plain Bourne). These are selected by searching the POSIX manpages. I
+ " added NLSPATH too, which wasn't in the original.
+ syntax clear shShellVariables
+ syntax cluster shCommandSubList add=shShellVariables
+ syntax keyword shShellVariables
+ \ CDPATH
+ \ ENV
+ \ FCEDIT
+ \ HISTFILE
+ \ HISTSIZE
+ \ HISTTIMEFORMAT
+ \ HOME
+ \ IFS
+ \ LANG
+ \ LC_ALL
+ \ LC_COLLATE
+ \ LC_CTYPE
+ \ LC_MESSAGES
+ \ LC_NUMERIC
+ \ LINENO
+ \ MAIL
+ \ MAILCHECK
+ \ MAILPATH
+ \ NLSPATH
+ \ OLDPWD
+ \ OPTARG
+ \ OPTERR
+ \ OPTIND
+ \ PATH
+ \ PS1
+ \ PS2
+ \ PS3
+ \ PS4
+ \ PWD
endif
diff --git a/vim/ftdetect/csv.vim b/vim/ftdetect/csv.vim
index e5a38e10..a234c093 100644
--- a/vim/ftdetect/csv.vim
+++ b/vim/ftdetect/csv.vim
@@ -1,7 +1,4 @@
" Add automatic commands to detect CSV files
-augroup dotfiles_ftdetect_csv
- autocmd!
- autocmd BufNewFile,BufRead
- \ *.csv
- \ setfiletype csv
-augroup END
+autocmd BufNewFile,BufRead
+ \ *.csv
+ \ setfiletype csv
diff --git a/vim/ftdetect/muttrc.vim b/vim/ftdetect/muttrc.vim
index 0f625f2b..55eeea93 100644
--- a/vim/ftdetect/muttrc.vim
+++ b/vim/ftdetect/muttrc.vim
@@ -1,7 +1,4 @@
" Add automatic commands to detect .muttrc files
-augroup dotfiles_ftdetect_muttrc
- autocmd!
- autocmd BufNewFile,BufRead
- \ **/.dotfiles/mutt/muttrc.d/*.rc,**/.muttrc.d/*.rc
- \ setfiletype muttrc
-augroup END
+autocmd BufNewFile,BufRead
+ \ **/.dotfiles/mutt/muttrc.d/*.rc,**/.muttrc.d/*.rc
+ \ setfiletype muttrc
diff --git a/vim/ftdetect/sh.vim b/vim/ftdetect/sh.vim
index f00a5659..880f08e9 100644
--- a/vim/ftdetect/sh.vim
+++ b/vim/ftdetect/sh.vim
@@ -1,23 +1,19 @@
" Add automatic commands to choose shell flavours based on filename pattern
-augroup dotfiles_ftdetect_sh
- autocmd!
- " Names/paths of things that are Bash shell script
- autocmd BufNewFile,BufRead
- \ **/.dotfiles/bash/**,bash-fc-*
- \ let b:is_bash = 1
- \ | setfiletype sh
+" Names/paths of things that are Bash shell script
+autocmd BufNewFile,BufRead
+ \ **/.dotfiles/bash/**,bash-fc-*
+ \ let b:is_bash = 1
+ \ | setfiletype sh
- " Names/paths of things that are Korn shell script
- autocmd BufNewFile,BufRead
- \ **/.dotfiles/ksh/**,.kshrc,*.ksh
- \ let b:is_kornshell = 1
- \ | setfiletype sh
+" Names/paths of things that are Korn shell script
+autocmd BufNewFile,BufRead
+ \ **/.dotfiles/ksh/**,.kshrc,*.ksh
+ \ let b:is_kornshell = 1
+ \ | setfiletype sh
- " Names/paths of things that are POSIX shell script
- autocmd BufNewFile,BufRead
- \ **/.dotfiles/sh/**,.shinit,.shrc,.xinitrc,/etc/default/*
- \ let b:is_posix = 1
- \ | setfiletype sh
-
-augroup END
+" Names/paths of things that are POSIX shell script
+autocmd BufNewFile,BufRead
+ \ **/.dotfiles/sh/**,.shinit,.shrc,.xinitrc,/etc/default/*
+ \ let b:is_posix = 1
+ \ | setfiletype sh
diff --git a/vim/ftdetect/tsv.vim b/vim/ftdetect/tsv.vim
index 673721f5..a345ac65 100644
--- a/vim/ftdetect/tsv.vim
+++ b/vim/ftdetect/tsv.vim
@@ -1,7 +1,4 @@
" Add automatic commands to detect TSV files
-augroup dotfiles_ftdetect_tsv
- autocmd!
- autocmd BufNewFile,BufRead
- \ *.tsv
- \ setfiletype tsv
-augroup END
+autocmd BufNewFile,BufRead
+ \ *.tsv
+ \ setfiletype tsv
diff --git a/vim/ftdetect/xdefaults.vim b/vim/ftdetect/xdefaults.vim
index 1529e5c9..f45a22a7 100644
--- a/vim/ftdetect/xdefaults.vim
+++ b/vim/ftdetect/xdefaults.vim
@@ -1,7 +1,4 @@
" Add automatic commands to find Xresources subfiles
-augroup dotfiles_ftdetect_xdefaults
- autocmd!
- autocmd BufNewFile,BufRead
- \ **/.Xresources.d/*
- \ setfiletype xdefaults
-augroup END
+autocmd BufNewFile,BufRead
+ \ **/.Xresources.d/*
+ \ setfiletype xdefaults
diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim
index 3db5dcca..d2c6a3e3 100644
--- a/vim/ftplugin/html.vim
+++ b/vim/ftplugin/html.vim
@@ -28,3 +28,9 @@ endfunction
nnoremap <buffer> <silent>
\ <LocalLeader>r
\ :<C-U>call <SID>UrlLink()<CR>
+
+" Unload this filetype plugin
+let b:undo_user_ftplugin
+ \ = 'silent! nunmap <LocalLeader>c'
+ \ . '|silent! nunmap <LocalLeader>t'
+ \ . '|silent! nunmap <LocalLeader>r'
diff --git a/vim/ftplugin/mail.vim b/vim/ftplugin/mail.vim
index d4840bfd..697ce499 100644
--- a/vim/ftplugin/mail.vim
+++ b/vim/ftplugin/mail.vim
@@ -1,4 +1,6 @@
" Use trailing whitespace to denote continued paragraph
setlocal formatoptions+=w
+
+" Unload this filetype plugin
let b:undo_user_ftplugin
\ = 'setlocal formatoptions<'
diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim
index ab27c2f7..f26fb156 100644
--- a/vim/ftplugin/markdown.vim
+++ b/vim/ftplugin/markdown.vim
@@ -1,6 +1,8 @@
" Spellcheck documents by default
if has('syntax')
setlocal spell
- let b:undo_user_ftplugin
- \ = 'setlocal spell<'
endif
+
+" Unload this filetype plugin
+let b:undo_user_ftplugin
+ \ = 'silent! setlocal spell<'
diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim
index 07cf9a1f..c18653d2 100644
--- a/vim/ftplugin/perl.vim
+++ b/vim/ftplugin/perl.vim
@@ -12,3 +12,9 @@ nnoremap <buffer> <silent>
nnoremap <buffer> <silent>
\ <LocalLeader>t
\ :<C-U>%!perltidy<CR>
+
+" Unload this filetype plugin
+let l:undo_user_ftplugin
+ \ = 'silent! nunmap <LocalLeader>c'
+ \ . '|silent! nunmap <LocalLeader>l'
+ \ . '|silent! nunmap <LocalLeader>t'
diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim
index 21d494e3..60e8b6c4 100644
--- a/vim/ftplugin/sh.vim
+++ b/vim/ftplugin/sh.vim
@@ -1,52 +1,53 @@
-" Default to POSIX shell, as I never write Bourne, and if I write Bash or Ksh
-" it'll be denoted with either a shebang or an appropriate extension.
-let g:is_posix = 1
-
-"
-" Setting g:is_posix above also prompts Vim's core syntax/sh.vim script to
-" set g:is_kornshell and thereby b:is_kornshell to the same value as g:is_posix.
"
-" That's very confusing, so before it happens we'll copy b:is_kornshell's
-" value as determined by filetype.vim and ~/.vim/ftdetect/sh.vim into a custom
-" variable b:is_ksh, before its meaning gets confused.
+" If we have a #!/bin/sh shebang and filetype.vim determined we were neither
+" POSIX nor Bash nor Korn shell, we'll guess POSIX, just because it's far more
+" likely that's what I want to write than plain Bourne shell.
"
-" b:is_ksh as a name is more inline with b:is_bash and b:is_sh, anyway, so
-" we'll just treat b:is_kornshell like it's both misnamed and broken.
+" You're supposed to be able to do this by setting g:is_posix, but if that's
+" set, the syntax file ends up setting g:is_kornshell for you too, for reasons
+" I don't really understand. This method works though, and is cleaner than
+" the other workaround I had been trying.
"
-" We can then switch on our custom variable in ~/.vim/after/syntax/sh.vim to
-" apply settings that actually *are* unique to Korn shell and its derivatives.
-"
-if exists('b:is_kornshell')
- let b:is_ksh = b:is_kornshell
+if exists('b:is_sh')
+ unlet b:is_sh
+ if !exists('b:is_bash') && !exists('b:is_kornshell')
+ let b:is_posix = 1
+ endif
endif
" Use han(1df) as a man(1) wrapper for Bash files if available
-if exists('b:is_bash') && executable('han')
+if exists('b:is_bash')
+ \ && executable('han')
setlocal keywordprg=han
- let b:undo_user_indent
- \ = 'setlocal keywordprg<'
endif
" Map checker based on shell family
-if exists('b:is_bash') && b:is_bash
- let b:check = 'write !bash -n'
-elseif exists('b:is_ksh') && b:is_ksh
- let b:check = 'write !ksh -n'
+if exists('b:is_bash')
+ let b:sh_check = 'write !bash -n'
+elseif exists('b:is_kornshell')
+ let b:sh_check = 'write !ksh -n'
else
- let b:check = 'write !sh -n'
+ let b:sh_check = 'write !sh -n'
endif
nnoremap <buffer> <silent>
\ <LocalLeader>c
- \ :<C-U>execute b:check<CR>
+ \ :<C-U>execute b:sh_check<CR>
" Map linter based on shell family
-if exists('b:is_bash') && b:is_bash
- let b:lint = 'write !shellcheck -s bash -'
-elseif exists('b:is_ksh') && b:is_ksh
- let b:lint = 'write !shellcheck -s ksh -'
+if exists('b:is_bash')
+ let b:sh_lint = 'write !shellcheck -s bash -'
+elseif exists('b:is_kornshell')
+ let b:sh_lint = 'write !shellcheck -s ksh -'
else
- let b:lint = 'write !shellcheck -s sh -'
+ let b:sh_lint = 'write !shellcheck -s sh -'
endif
nnoremap <buffer> <silent>
\ <LocalLeader>l
- \ :<C-U>execute b:lint<CR>
+ \ :<C-U>execute b:sh_lint<CR>
+
+" Unload this filetype plugin
+let b:undo_user_ftplugin
+ \ = 'setlocal keywordprg<'
+ \ . '|unlet! b:sh_check b:sh_lint'
+ \ . '|silent! nunmap <LocalLeader>c'
+ \ . '|silent! nunmap <LocalLeader>l'
diff --git a/vim/ftplugin/text.vim b/vim/ftplugin/text.vim
index ab27c2f7..f26fb156 100644
--- a/vim/ftplugin/text.vim
+++ b/vim/ftplugin/text.vim
@@ -1,6 +1,8 @@
" Spellcheck documents by default
if has('syntax')
setlocal spell
- let b:undo_user_ftplugin
- \ = 'setlocal spell<'
endif
+
+" Unload this filetype plugin
+let b:undo_user_ftplugin
+ \ = 'silent! setlocal spell<'
diff --git a/vim/ftplugin/vim.vim b/vim/ftplugin/vim.vim
index d4e55ace..e8113134 100644
--- a/vim/ftplugin/vim.vim
+++ b/vim/ftplugin/vim.vim
@@ -4,3 +4,7 @@
nnoremap <buffer> <silent>
\ <LocalLeader>l
\ :<C-U>write !vint -s /dev/stdin<CR>
+
+" Unload this filetype plugin
+let b:undo_user_ftplugin
+ \ = 'silent! nunmap <LocalLeader>l'
diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim
index 682bc3a8..ae2b6f6c 100644
--- a/vim/indent/csv.vim
+++ b/vim/indent/csv.vim
@@ -1,5 +1,7 @@
" Manual indenting and literal tabs for CSVs
setlocal noautoindent
setlocal noexpandtab
+
+" Unload this indent plugin
let b:undo_user_indent
\ = 'setlocal autoindent< expandtab<'
diff --git a/vim/indent/tsv.vim b/vim/indent/tsv.vim
index 951b3e60..759602ed 100644
--- a/vim/indent/tsv.vim
+++ b/vim/indent/tsv.vim
@@ -1,5 +1,7 @@
" Manual indenting and literal tabs for TSVs
setlocal noautoindent
setlocal noexpandtab
+
+" Unload this indent plugin
let b:undo_user_indent
\ = 'setlocal autoindent< expandtab<'
diff --git a/vim/indent/vim.vim b/vim/indent/vim.vim
index 047a353d..138b9205 100644
--- a/vim/indent/vim.vim
+++ b/vim/indent/vim.vim
@@ -3,9 +3,7 @@ setlocal shiftwidth=2
setlocal softtabstop=2
setlocal tabstop=2
-" Ancient Vim can't use the '<' suffix syntax for resetting local integer
-" options
-if v:version > 700
- let b:undo_user_indent
- \ = 'setlocal shiftwidth< softtabstop< tabstop<'
-endif
+" Unload this indent plugin; suppress errors because ancient Vim can't use the
+" '<' suffix syntax for resetting local integer
+let b:undo_user_indent
+ \ = 'silent! setlocal shiftwidth< softtabstop< tabstop<'