aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim')
-rw-r--r--vim/after/ftplugin/gitcommit.vim16
-rw-r--r--vim/after/ftplugin/html.vim2
-rw-r--r--vim/after/ftplugin/mail.vim16
-rw-r--r--vim/after/ftplugin/python.vim35
-rw-r--r--vim/after/ftplugin/vim.vim6
-rw-r--r--vim/after/indent/vim.vim6
-rw-r--r--vim/after/indent/yaml.vim2
-rw-r--r--vim/after/plugin/2html.vim11
-rw-r--r--vim/after/plugin/insert_cancel.vim4
-rw-r--r--vim/after/plugin/matchparen.vim4
-rw-r--r--vim/after/plugin/spellfile_local.vim13
-rw-r--r--vim/after/plugin/undofileskip.vim7
-rw-r--r--vim/after/syntax/bindzone.vim4
-rw-r--r--vim/after/syntax/mail.vim3
-rw-r--r--vim/after/syntax/resolv.vim6
-rw-r--r--vim/after/syntax/sh.vim12
-rw-r--r--vim/after/syntax/vim.vim2
-rw-r--r--vim/autoload/argument.vim8
-rw-r--r--vim/autoload/diff.vim2
-rw-r--r--vim/autoload/filetype/repeat.vim2
-rw-r--r--vim/autoload/fortune.vim59
-rw-r--r--vim/autoload/has.vim34
-rw-r--r--vim/autoload/html/timestamp.vim4
-rw-r--r--vim/autoload/indent.vim20
-rw-r--r--vim/autoload/mail.vim4
-rw-r--r--vim/autoload/mail/header/field.vim2
-rw-r--r--vim/autoload/option.vim8
-rw-r--r--vim/autoload/patch.vim35
-rw-r--r--vim/autoload/path.vim14
-rw-r--r--vim/autoload/plugin.vim7
-rw-r--r--vim/autoload/put_date.vim24
-rw-r--r--vim/autoload/quote.vim4
-rw-r--r--vim/autoload/xdg.vim67
m---------vim/bundle/copy_linebreak0
m---------vim/bundle/cursorline_current0
m---------vim/bundle/detect_indent0
m---------vim/bundle/html_spelllang0
m---------vim/bundle/paste_insert0
m---------vim/bundle/put_date0
m---------vim/bundle/redact_pass0
m---------vim/bundle/spellfile_local0
m---------vim/bundle/squeeze_repeat_blanks0
m---------vim/bundle/strip_trailing_whitespace0
m---------vim/bundle/undofileskip0
-rw-r--r--vim/compiler/pyflakes.vim9
-rw-r--r--vim/compiler/pylint.vim9
-rw-r--r--vim/filetype.vim200
-rw-r--r--vim/ftplugin/csv.vim2
-rw-r--r--vim/ftplugin/mail.vim15
-rw-r--r--vim/ftplugin/markdown.vim2
-rw-r--r--vim/ftplugin/textarea.vim12
-rw-r--r--vim/plugin/2html.vim1
-rw-r--r--vim/plugin/fortune.vim4
-rw-r--r--vim/plugin/matchit.vim2
-rw-r--r--vim/plugin/put_date.vim6
-rw-r--r--vim/scripts.vim10
-rw-r--r--vim/syntax/jinja2.vim2
-rw-r--r--vim/vimrc1147
-rw-r--r--vim/vimrc.stub22
59 files changed, 1072 insertions, 814 deletions
diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim
index 4a1c3814..093dc5f5 100644
--- a/vim/after/ftplugin/gitcommit.vim
+++ b/vim/after/ftplugin/gitcommit.vim
@@ -4,13 +4,15 @@ setlocal formatoptions+=coqr
let b:undo_ftplugin .= '|setlocal comments< formatoptions<'
" Choose the color column depending on non-comment line count
-augroup gitcommit_cursorcolumn
- autocmd CursorMoved,CursorMovedI <buffer>
- \ let &l:colorcolumn = gitcommit#CursorColumn()
-augroup END
-let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn'''
- \ . '|augroup! gitcommit_cursorcolumn'
- \ . '|setlocal colorcolumn<'
+if exists('&colorcolumn')
+ augroup gitcommit_cursorcolumn
+ autocmd CursorMoved,CursorMovedI <buffer>
+ \ let &l:colorcolumn = gitcommit#CursorColumn()
+ augroup END
+ let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn'''
+ \ . '|augroup! gitcommit_cursorcolumn'
+ \ . '|setlocal colorcolumn<'
+endif
" Stop here if the user doesn't want ftplugin mappings
if exists('no_plugin_maps') || exists('no_gitcommit_maps')
diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim
index 7e2ba439..21a84a42 100644
--- a/vim/after/ftplugin/html.vim
+++ b/vim/after/ftplugin/html.vim
@@ -4,7 +4,7 @@ if &filetype !=# 'html'
finish
endif
-" Spellcheck documents we're actually editing (not just viewing)
+" Check the spelling of documents we're actually editing (not just viewing)
if &modifiable && !&readonly
setlocal spell
let b:undo_ftplugin .= '|setlocal spell<'
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 738f17ec..4c07bac3 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -1,3 +1,13 @@
+" Restore global value for no_mail_maps that we set in
+" ~/.vim/ftplugin/mail.vim to work around the bad maps set in
+" $VIMRUNTIME/ftplugin/mail.vim
+"
+if exists('b:no_mail_maps')
+ let no_mail_maps = b:no_mail_maps
+elseif exists('no_mail_maps')
+ unlet no_mail_maps
+endif
+
" Don't append spaces after quote chars, for strict compliance with
" format=flowed
let b:quote_space = 0
@@ -8,7 +18,7 @@ command -bar -buffer SuggestStart
let b:undo_ftplugin .= '|delcommand SuggestStart'
SuggestStart
-" Normalise quoting
+" Normalize quoting
command -bar -buffer -range=% StrictQuote
\ call mail#StrictQuote(<q-line1>, <q-line2>)
let b:undo_ftplugin .= '|delcommand StrictQuote'
@@ -66,9 +76,9 @@ let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q'
\ . '|xunmap <buffer> <LocalLeader>Q'
" Mappings for enforcing strict quoting
-nnoremap <LocalLeader>s
+nnoremap <buffer> <LocalLeader>s
\ :StrictQuote<CR>
-xnoremap <LocalLeader>s
+xnoremap <buffer> <LocalLeader>s
\ :StrictQuote<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>s'
\ . '|xunmap <buffer> <LocalLeader>s'
diff --git a/vim/after/ftplugin/python.vim b/vim/after/ftplugin/python.vim
new file mode 100644
index 00000000..2ca1ae89
--- /dev/null
+++ b/vim/after/ftplugin/python.vim
@@ -0,0 +1,35 @@
+" The Python runtime files didn't define b:undo_ftplugin until Vim v8.1.1048;
+" if it's not set yet, set it here (to something innoccuous) so that the
+" appending :let commands in the rest of this file don't break.
+"
+if !exists('b:undo_ftplugin')
+ let b:undo_ftplugin = 'setlocal tabstop<'
+endif
+
+" Use pyflakes for syntax checking and autopep8 for tidying
+compiler pyflakes
+if executable('autopep8')
+ setlocal equalprg=autopep8\ -aaa\ --\ -
+ let b:undo_ftplugin .= '|setlocal equalprg<'
+endif
+
+" Stop here if the user doesn't want ftplugin mappings
+if exists('no_plugin_maps') || exists('no_python_maps')
+ finish
+endif
+
+" Mappings to choose compiler
+nnoremap <buffer> <LocalLeader>c
+ \ :<C-U>compiler pyflakes<CR>
+nnoremap <buffer> <LocalLeader>l
+ \ :<C-U>compiler pylint<CR>
+let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>c'
+ \ . '|nunmap <buffer> <LocalLeader>l'
+
+" Mappings to choose 'equalprg'
+nnoremap <buffer> <LocalLeader>t
+ \ :<C-U>setlocal equalprg=autopep8\ -aaa\ --\ -<CR>
+nnoremap <buffer> <LocalLeader>i
+ \ :<C-U>setlocal equalprg<<CR>
+let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>t'
+ \ . '|nunmap <buffer> <LocalLeader>i'
diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim
index 01f971b9..112523da 100644
--- a/vim/after/ftplugin/vim.vim
+++ b/vim/after/ftplugin/vim.vim
@@ -26,9 +26,9 @@ let &l:include = '\<source\>\|\<runtime!\=\>'
" Search runtime paths for included scripts
let &l:path = &runtimepath . ',' . &path
-" Adjust the match words for the matchit plugin; the default filetype plugin
-" matches e.g. an opening "function" with the first "return" within, which I
-" don't like
+" Adjust the match words for the matchit.vim plugin; the default filetype
+" plugin matches e.g. an opening "function" with the first "return" within,
+" which I don't like
if exists('loaded_matchit')
let b:match_words = '\<fu\%[nction]\>:\<endf\%[unction]\>,'
\ . '\<\(wh\%[ile]\|for\)\>:\<end\(w\%[hile]\|fo\%[r]\)\>,'
diff --git a/vim/after/indent/vim.vim b/vim/after/indent/vim.vim
index da34eb75..4300e125 100644
--- a/vim/after/indent/vim.vim
+++ b/vim/after/indent/vim.vim
@@ -1,9 +1,9 @@
-" Use two (not four!) spaces for indentation, per convention
-call indent#Spaces(2)
-
" Remove inapplicable defaults from 'indentkeys'; we should only need to undo
" this if the stock plugin didn't already arrange that (before v7.3.539)
setlocal indentkeys-=0#,0{,0},0),:
if !exists('b:undo_indent')
let b:undo_indent = 'setlocal indentkeys<'
endif
+
+" Use two (not four!) spaces for indentation, per convention
+call indent#Spaces(2)
diff --git a/vim/after/indent/yaml.vim b/vim/after/indent/yaml.vim
new file mode 100644
index 00000000..d0478631
--- /dev/null
+++ b/vim/after/indent/yaml.vim
@@ -0,0 +1,2 @@
+" Use two (not four!) spaces for indentation, per convention
+call indent#Spaces(2)
diff --git a/vim/after/plugin/2html.vim b/vim/after/plugin/2html.vim
new file mode 100644
index 00000000..dd65486d
--- /dev/null
+++ b/vim/after/plugin/2html.vim
@@ -0,0 +1,11 @@
+" Don't make these settings if the base plugin didn't load
+if !exists('g:loaded_2html_plugin')
+ finish
+endif
+
+" Set preferred fonts for the HTML rendering
+let g:html_font = [
+ \ 'DejaVu Sans Mono',
+ \ 'Ubuntu Mono',
+ \ 'Consolas',
+ \]
diff --git a/vim/after/plugin/insert_cancel.vim b/vim/after/plugin/insert_cancel.vim
new file mode 100644
index 00000000..a8abe6ed
--- /dev/null
+++ b/vim/after/plugin/insert_cancel.vim
@@ -0,0 +1,4 @@
+" Set mapping for insert_cancel.vim
+if exists('loaded_insert_cancel')
+ imap <C-C> <Plug>(InsertCancel)
+endif
diff --git a/vim/after/plugin/matchparen.vim b/vim/after/plugin/matchparen.vim
new file mode 100644
index 00000000..b2be8f61
--- /dev/null
+++ b/vim/after/plugin/matchparen.vim
@@ -0,0 +1,4 @@
+" If matchparen.vim didn't load, use 'showmatch' instead
+if !exists('loaded_matchparen')
+ set showmatch matchtime=3
+endif
diff --git a/vim/after/plugin/spellfile_local.vim b/vim/after/plugin/spellfile_local.vim
new file mode 100644
index 00000000..7d805660
--- /dev/null
+++ b/vim/after/plugin/spellfile_local.vim
@@ -0,0 +1,13 @@
+" Don't make these settings if the base plugin didn't load
+if !exists('g:loaded_spellfile_local')
+ finish
+endif
+
+" Use XDG dirs for 'spellfile' if XDG_DATA_HOME is useable
+if xdg#DataHome() !=# ''
+ let g:spellfile_local_dirs = [ xdg#DataHome() ]
+ call extend(
+ \ g:spellfile_local_dirs,
+ \ xdg#DataDirs(),
+ \)
+endif
diff --git a/vim/after/plugin/undofileskip.vim b/vim/after/plugin/undofileskip.vim
new file mode 100644
index 00000000..e7116940
--- /dev/null
+++ b/vim/after/plugin/undofileskip.vim
@@ -0,0 +1,7 @@
+" If undofileskip.vim loaded, add a few applicable paths to its list
+if !exists('g:undofileskip')
+ finish
+endif
+
+" Just split and copy 'backupskip'
+let g:undofileskip = option#Split(&backupskip)
diff --git a/vim/after/syntax/bindzone.vim b/vim/after/syntax/bindzone.vim
index 29d5f4b8..f95aff8f 100644
--- a/vim/after/syntax/bindzone.vim
+++ b/vim/after/syntax/bindzone.vim
@@ -1,5 +1,5 @@
-" Highlight TLSA and SSHFP records correctly
+" Highlight some newer/weirder records correctly
" <https://github.com/vim/vim/issues/220>
syn keyword zoneRRType
- \ contained TLSA SSHFP
+ \ contained CAA SSHFP TLSA
\ nextgroup=zoneRData skipwhite
diff --git a/vim/after/syntax/mail.vim b/vim/after/syntax/mail.vim
new file mode 100644
index 00000000..77c76f00
--- /dev/null
+++ b/vim/after/syntax/mail.vim
@@ -0,0 +1,3 @@
+" Don't spellcheck code in mail messages
+syntax region mailCode start='`' end='`' keepend contains=@NoSpell
+syntax region mailCodeBlock start=' \{4\}' end='$' contains=@NoSpell
diff --git a/vim/after/syntax/resolv.vim b/vim/after/syntax/resolv.vim
new file mode 100644
index 00000000..4c8ec165
--- /dev/null
+++ b/vim/after/syntax/resolv.vim
@@ -0,0 +1,6 @@
+" Over-simple but good-enough `nameserver` rule fix including IPv6
+" Version 1.4 of the syntax file has a more accurate fix
+if !has('patch-8.2.0380')
+ syntax clear resolvIPNameserver
+ syntax match resolvIPNameserver contained /[0-9.a-fA-F:]\+/
+endif
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim
index af7670d5..d7cf040d 100644
--- a/vim/after/syntax/sh.vim
+++ b/vim/after/syntax/sh.vim
@@ -16,11 +16,11 @@ elseif exists('b:is_posix')
endif
" 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.
+" error, which it isn't, at least in POSIX sh, Bash, and Korn shell.
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
+" The syntax highlighter doesn't match parentheses 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
@@ -33,7 +33,7 @@ syntax clear shTestError
if exists('b:is_posix')
" Highlight some commands that are both defined by POSIX and builtin
- " commands in dash, as a rough but useable proxy for 'shell builtins'. This
+ " commands in dash, as a rough but usable 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
@@ -76,8 +76,8 @@ if exists('b:is_posix')
" 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.
+ " (and plain Bourne). These are selected by searching the POSIX man pages.
+ " I added NLSPATH too, which wasn't in the original.
syntax clear shShellVariables
syntax cluster shCommandSubList add=shShellVariables
syntax keyword shShellVariables
diff --git a/vim/after/syntax/vim.vim b/vim/after/syntax/vim.vim
index 438ce596..bd7d8274 100644
--- a/vim/after/syntax/vim.vim
+++ b/vim/after/syntax/vim.vim
@@ -4,7 +4,7 @@ syntax clear vimCommentString
syntax clear vimCommentTitle
" Highlight :CompilerSet commands like :set/:setlocal, but only in compiler
-" scripts in recognisable paths
+" scripts in recognizable paths
if expand('%:p:h:t') ==# 'compiler'
\ && expand('%:e') ==# 'vim'
syntax keyword vimCommand contained
diff --git a/vim/autoload/argument.vim b/vim/autoload/argument.vim
deleted file mode 100644
index 85d75eb1..00000000
--- a/vim/autoload/argument.vim
+++ /dev/null
@@ -1,8 +0,0 @@
-" Escape a single argument for use on an Ex command line; essentially
-" a backport of fnameescape() for versions before v7.1.299
-"
-function! argument#Escape(argument) abort
- return exists('*fnameescape')
- \ ? fnameescape(a:argument)
- \ : escape(a:argument, "\n\r\t".' *?[{`$\%#''"|!<')
-endfunction
diff --git a/vim/autoload/diff.vim b/vim/autoload/diff.vim
index 29389b95..6e87b62a 100644
--- a/vim/autoload/diff.vim
+++ b/vim/autoload/diff.vim
@@ -1,7 +1,7 @@
" Move between diff block headers
function! diff#MoveBlock(count, up, visual) abort
- " Reselect visual selection
+ " Re-select visual selection
if a:visual
normal! gv
endif
diff --git a/vim/autoload/filetype/repeat.vim b/vim/autoload/filetype/repeat.vim
index f681932b..899bbcc4 100644
--- a/vim/autoload/filetype/repeat.vim
+++ b/vim/autoload/filetype/repeat.vim
@@ -53,7 +53,7 @@ function! filetype#repeat#Sudo() abort
elseif fn =~# '/[^/]\+\.\w\{8}$'
let fn = expand('<afile>:r')
- " Unrecognised pattern; return, don't repeat
+ " Unrecognized pattern; return, don't repeat
else
return
endif
diff --git a/vim/autoload/fortune.vim b/vim/autoload/fortune.vim
deleted file mode 100644
index da6e2fa3..00000000
--- a/vim/autoload/fortune.vim
+++ /dev/null
@@ -1,59 +0,0 @@
-" Declare paths to check for fortune files
-let s:paths = [
- \ $HOME.'/.fortunes',
- \ $HOME.'/.local/share/games/fortunes',
- \]
-
-" List of executables for which we need to check
-let s:executables = [
- \ 'fortune',
- \ 'timeout',
- \]
-
-" Entry point for plugin
-function! fortune#() abort
-
- " Check we have all of the executables we need
- for executable in s:executables
- if !executable(executable)
- echoerr 'Missing executable "'.executable.'"'
- endif
- endfor
-
- " Maximum length of fortunes is the width of the screen minus 1; characters
- " wider than one column will break this
- "
- let limit = &columns - 1
-
- " Some implementations of fortune(6) thrash the disk if they can't meet the
- " length limit, so we need to rap this invocation in a timeout(1) call
- let command = [
- \ 'timeout',
- \ '0.3s',
- \ 'fortune',
- \ '-s',
- \ '-n',
- \ limit,
- \]
-
- " Find a path for custom fortunes and add it on to the command if found
- for path in s:paths
- if isdirectory(path)
- call add(command, path)
- break
- endif
- endfor
-
- " Run the command and condense any control or space character groups into
- " just one space
- let fortune = substitute(
- \ system(join(command)),
- \ '[[:cntrl:][:space:]]\+',
- \ ' ',
- \ 'g',
- \)
-
- " Show the fortune message!
- echomsg fortune
-
-endfunction
diff --git a/vim/autoload/has.vim b/vim/autoload/has.vim
deleted file mode 100644
index 162e4929..00000000
--- a/vim/autoload/has.vim
+++ /dev/null
@@ -1,34 +0,0 @@
-" Wrapper to backport the nicer has() syntax for simultaneous version and
-" patch level checking that was introduced in v7.4.236 and fixed in v7.4.237.
-"
-" * <https://github.com/vim/vim/releases/tag/v7.4.236>
-" * <https://github.com/vim/vim/releases/tag/v7.4.237>
-"
-function! has#(feature) abort
-
- " If we're new enough, we can just run the native has()
- if has('patch-7.4.237')
- return has(a:feature)
- endif
-
- " Otherwise, we have to break down the pattern and do manual version and
- " patch level checks; if it doesn't match the patch syntax, just return what
- " the native has() does
- "
- let feature = a:feature
- let pattern = '^patch-\(\d\+\)\.\(\d\+\)\.\(\d\+\)$'
- let matchlist = matchlist(feature, pattern)
- if empty(matchlist)
- return has(a:feature)
- endif
- let [major, minor, patch] = matchlist[1:3]
-
- " The v:version variable looks like e.g. 801 for v8.1
- let l:version = major * 100 + minor
-
- " Compare the version numbers, and then the patch level if they're the same
- return v:version != l:version
- \ ? v:version > l:version
- \ : has('patch-'.patch)
-
-endfunction
diff --git a/vim/autoload/html/timestamp.vim b/vim/autoload/html/timestamp.vim
index 9de19aa0..8f250710 100644
--- a/vim/autoload/html/timestamp.vim
+++ b/vim/autoload/html/timestamp.vim
@@ -34,7 +34,7 @@ function! s:Timestamp(time) abort
endfunction
" Define timestamp prefix string
-let s:prefix = '<strong>Last updated:</strong> '
+let s:prefix = 'Last updated: '
" Define pattern to match date timestamps; no ZALGO, please
let s:pattern = '\m\C'
@@ -69,6 +69,6 @@ function! html#timestamp#Update() abort
" Apply the updated timestamp
let line = getline(lnum)
let line = substitute(line, s:pattern, update, '')
- call setline(lnum, line)
+ keepjumps call setline(lnum, line)
endfunction
diff --git a/vim/autoload/indent.vim b/vim/autoload/indent.vim
index d597653f..19a9f03d 100644
--- a/vim/autoload/indent.vim
+++ b/vim/autoload/indent.vim
@@ -10,7 +10,7 @@ function! indent#Spaces(...) abort
" If we have the patch that supports it, set 'softtabstop' to dynamically
" mirror the value of 'shiftwidth'; failing that, just copy it
- let &l:softtabstop = has#('patch-7.3.693')
+ let &l:softtabstop = patch#('7.3.693')
\ ? -1
\ : &l:shiftwidth
@@ -19,27 +19,17 @@ endfunction
" Set the current buffer to tab indent
function! indent#Tabs() abort
- setlocal noexpandtab
- setlocal shiftwidth< softtabstop<
+ setlocal noexpandtab shiftwidth< softtabstop<
call indent#Undo()
endfunction
" Add commands to b:undo_indent to clean up buffer-local indentation changes
" on a change of filetype
function! indent#Undo() abort
-
- " Check and set a flag so that we only do this once per buffer
- if exists('b:undo_indent_type_set')
- return
- endif
- let b:undo_indent_type_set = 1
-
- " Either set or append relevant commands to b:undo_indent
- let l:undo = 'setlocal expandtab< shiftwidth< softtabstop< tabstop<'
+ let undo = 'setlocal expandtab< shiftwidth< softtabstop<'
if exists('b:undo_indent')
- let b:undo_indent .= '|'.l:undo
+ let b:undo_indent .= '|'.undo
else
- let b:undo_indent = l:undo
+ let b:undo_indent = undo
endif
-
endfunction
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
index cd585af4..6d4874ca 100644
--- a/vim/autoload/mail.vim
+++ b/vim/autoload/mail.vim
@@ -1,7 +1,7 @@
" Move through quoted paragraphs like normal-mode `{` and `}`
function! mail#NewBlank(count, up, visual) abort
- " Reselect visual selection
+ " Re-select visual selection
if a:visual
normal! gv
endif
@@ -61,7 +61,7 @@ function! mail#StrictQuote(start, end) abort
continue
endif
- " Normalise the quote with no spaces
+ " Normalize the quote with no spaces
let quote = substitute(quote, '[^>]', '', 'g')
" Re-set the line
diff --git a/vim/autoload/mail/header/field.vim b/vim/autoload/mail/header/field.vim
index e27d13c0..db38c09f 100644
--- a/vim/autoload/mail/header/field.vim
+++ b/vim/autoload/mail/header/field.vim
@@ -9,7 +9,7 @@ function! mail#header#field#Add(header, name, body) abort
endfunction
" Set a field in a header, replacing the first one with the same name (if
-" any), and and removing any others
+" any), and removing any others
"
function! mail#header#field#Set(header, name, body) abort
let fields = []
diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim
index 5ff44ced..49fbf1a4 100644
--- a/vim/autoload/option.vim
+++ b/vim/autoload/option.vim
@@ -7,5 +7,11 @@ function! option#Split(expr, ...) abort
endif
let keepempty = a:0 ? a:1 : 0
let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
- return map(parts, 'substitute(v:val, ''\\,'', '','', ''g'')')
+ return map(copy(parts), 'substitute(v:val, ''\\,'', '','', ''g'')')
+endfunction
+
+" Escape the right-hand side of a :set option value
+"
+function! option#Escape(expr) abort
+ return escape(a:expr, ' |"\')
endfunction
diff --git a/vim/autoload/patch.vim b/vim/autoload/patch.vim
new file mode 100644
index 00000000..3a17ccda
--- /dev/null
+++ b/vim/autoload/patch.vim
@@ -0,0 +1,35 @@
+" Wrapper to emulate the nicer has() syntax for simultaneous version and patch
+" level checking that was introduced in v7.4.236 and fixed in v7.4.237.
+"
+" * <https://github.com/vim/vim/releases/tag/v7.4.236>
+" * <https://github.com/vim/vim/releases/tag/v7.4.237>
+"
+function! patch#(version) abort
+
+ " If the Vim running is new enough for its has() function to support
+ " checking patch levels with version prefixes, we can just add a "patch-"
+ " prefix to the query, and pass it on to has().
+ "
+ if has('patch-7.4.237')
+ return has('patch-'.a:version)
+ endif
+
+ " Failing that, we need to do our own version number and patch number
+ " comparisons; split the queried version on dots.
+ "
+ let [major, minor, patch] = split(a:version, '\.')
+
+ " The internal variable v:version describing the running Vim looks like
+ " e.g. 801 for v8.1; reproduce that logic for the queried version.
+ "
+ let l:version = major * 100 + minor
+
+ " If the running version number is the same as the required one, return
+ " whether we have the specific patch requested; otherwise, return whether
+ " the running version number is greater than the required one.
+ "
+ return v:version == l:version
+ \ ? has('patch-'.patch)
+ \ : v:version > l:version
+
+endfunction
diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim
deleted file mode 100644
index e230cab2..00000000
--- a/vim/autoload/path.vim
+++ /dev/null
@@ -1,14 +0,0 @@
-" Create all the directories needed for a path, with optional flag for
-" owner-only permissions
-function! path#Create(name, ...) abort
- if a:0 > 2
- echoerr 'Too many arguments'
- endif
- if isdirectory(a:name)
- return 1
- endif
- let name = a:name
- let path = 'p'
- let prot = a:0 == 1 && a:1 ? 0700 : 0755
- return mkdir(name, path, prot)
-endfunction
diff --git a/vim/autoload/plugin.vim b/vim/autoload/plugin.vim
deleted file mode 100644
index 629a4367..00000000
--- a/vim/autoload/plugin.vim
+++ /dev/null
@@ -1,7 +0,0 @@
-" Check whether plugins are enabled and a specific named plugin (excluding
-" extension .vim) is available somewhere within 'runtimepath'
-"
-function! plugin#Ready(name) abort
- return &loadplugins
- \ && globpath(&runtimepath, 'plugin/'.a:name.'.vim') !=# ''
-endfunction
diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim
deleted file mode 100644
index b0b0b548..00000000
--- a/vim/autoload/put_date.vim
+++ /dev/null
@@ -1,24 +0,0 @@
-" RFC2822 format string for strftime()
-let s:rfc_2822 = '%a, %d %b %Y %T %z'
-
-" Write a date to the buffer, UTC or local, in the specified format,
-" defaulting to RFC2822; formats are provided without the leading % signs
-" before each letter, like PHP date()
-"
-function! put_date#(line, utc, format) abort
- let line = a:line
- let utc = a:utc
- let format = strlen(a:format)
- \ ? substitute(a:format, '\a', '%&', 'g')
- \ : s:rfc_2822
- if utc
- if exists('$TZ')
- let tz = $TZ
- endif
- let $TZ = 'UTC'
- endif
- execute line.'put =strftime(format)'
- if exists('tz')
- let $TZ = tz
- endif
-endfunction
diff --git a/vim/autoload/quote.vim b/vim/autoload/quote.vim
index 690ba2db..7574ed71 100644
--- a/vim/autoload/quote.vim
+++ b/vim/autoload/quote.vim
@@ -24,8 +24,8 @@ function! quote#QuoteOpfunc(type) abort
continue
endif
- " If configured to do so, add a a space after the quote character, but
- " only if this line isn't already quoted
+ " If configured to do so, add a space after the quote character, but only
+ " if this line isn't already quoted
let new = char
if space && cur[0] != char
let new .= ' '
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim
new file mode 100644
index 00000000..cb7adcf5
--- /dev/null
+++ b/vim/autoload/xdg.vim
@@ -0,0 +1,67 @@
+" <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables>
+let s:defaults = {
+ \ 'XDG_CACHE_HOME': $HOME.'/.cache',
+ \ 'XDG_CONFIG_HOME': $HOME.'/.config',
+ \ 'XDG_CONFIG_DIRS': '/etc/xdg',
+ \ 'XDG_DATA_HOME': $HOME.'/.local/share',
+ \ 'XDG_DATA_DIRS': '/usr/local/share:/usr/share',
+ \ 'XDG_STATE_HOME': $HOME.'/.local/state',
+ \}
+
+function! s:Get(name) abort
+ let name = a:name
+ if !has_key(s:defaults, name)
+ throw 'Illegal XDG basedirs env var name'
+ endif
+ let value = s:defaults[name]
+ if exists('$'.a:name)
+ execute 'let value = $'.a:name
+ endif
+ return value
+endfunction
+
+function! s:Absolute(path) abort
+ return a:path =~# '^/'
+ \ || a:path =~# '^\~/'
+ \ || a:path ==# '~'
+endfunction
+
+function! s:Home(name) abort
+ let home = s:Get(a:name)
+ if !s:Absolute(home)
+ return ''
+ endif
+ return home.'/vim'
+endfunction
+
+function! s:Dirs(name) abort
+ let dirs = split(s:Get(a:name), ':')
+ return map(
+ \ filter(copy(dirs), 's:Absolute(v:val)')
+ \,'v:val.''/vim'''
+ \)
+endfunction
+
+function! xdg#CacheHome() abort
+ return has('unix') ? s:Home('XDG_CACHE_HOME') : ''
+endfunction
+
+function! xdg#ConfigHome() abort
+ return has('unix') ? s:Home('XDG_CONFIG_HOME') : ''
+endfunction
+
+function! xdg#DataHome() abort
+ return has('unix') ? s:Home('XDG_DATA_HOME') : ''
+endfunction
+
+function! xdg#StateHome() abort
+ return has('unix') ? s:Home('XDG_STATE_HOME') : ''
+endfunction
+
+function! xdg#ConfigDirs() abort
+ return has('unix') ? s:Dirs('XDG_CONFIG_DIRS') : []
+endfunction
+
+function! xdg#DataDirs() abort
+ return has('unix') ? s:Dirs('XDG_DATA_DIRS') : []
+endfunction
diff --git a/vim/bundle/copy_linebreak b/vim/bundle/copy_linebreak
-Subproject 6692eef760ccfc2e1b888d1d604e3e1a156fcbc
+Subproject a0004c18da5f524f62e2da6e19be1a51ce282f3
diff --git a/vim/bundle/cursorline_current b/vim/bundle/cursorline_current
-Subproject 4ab61f5dfa9a2868c529c75a50219dac6619080
+Subproject d1b8db2fe6b06bd556c777c7bd9d4632f12a3a1
diff --git a/vim/bundle/detect_indent b/vim/bundle/detect_indent
new file mode 160000
+Subproject 96f46cae148517e4b8e8a5bbe13b623ddde6b70
diff --git a/vim/bundle/html_spelllang b/vim/bundle/html_spelllang
new file mode 160000
+Subproject 161e47f00cd5a1bdcef61097b7ba100ffd69a48
diff --git a/vim/bundle/paste_insert b/vim/bundle/paste_insert
-Subproject 0365dd11c050f885050cd6dd22405c81aba5f46
+Subproject 1ffcb96611315dd068b734d5aae7ff07fa2b3a2
diff --git a/vim/bundle/put_date b/vim/bundle/put_date
new file mode 160000
+Subproject fa0b0289b80fadbe9af87ca2faa3b5da4512d3f
diff --git a/vim/bundle/redact_pass b/vim/bundle/redact_pass
-Subproject 337e7498e2b483e79c9abb33a2feb670655b23d
+Subproject 403a44dc32533e631384dfcca40d520b9088b0d
diff --git a/vim/bundle/spellfile_local b/vim/bundle/spellfile_local
-Subproject 16dbdc90b39c1ebf43ca1881a493edc816d2d9f
+Subproject 6199ee785c6fb964292ec6e82c5b8a0f79e2606
diff --git a/vim/bundle/squeeze_repeat_blanks b/vim/bundle/squeeze_repeat_blanks
-Subproject 8c849183f8723086e6b61a0644292bdb1ad99c1
+Subproject 27dd1b5858b4839b34249c106d2b3963a3da416
diff --git a/vim/bundle/strip_trailing_whitespace b/vim/bundle/strip_trailing_whitespace
-Subproject 90e60095bcfcfeb60bea60ba7f51bbfac3bf469
+Subproject 03782cdaf9db6329665316e1dc2d1b8270714a3
diff --git a/vim/bundle/undofileskip b/vim/bundle/undofileskip
new file mode 160000
+Subproject 1d0a5cf3aa1bf1f360862819d229d756958df32
diff --git a/vim/compiler/pyflakes.vim b/vim/compiler/pyflakes.vim
new file mode 100644
index 00000000..727fbd76
--- /dev/null
+++ b/vim/compiler/pyflakes.vim
@@ -0,0 +1,9 @@
+" :compiler support for Python syntax checking with pyflakes
+" <https://pypi.org/project/pyflakes/>
+if exists('current_compiler') || &compatible || !has('patch-7.4.191')
+ finish
+endif
+let current_compiler = 'pyflakes'
+
+CompilerSet makeprg=pyflakes\ %:S
+CompilerSet errorformat=%f:%l:%c:\ %m
diff --git a/vim/compiler/pylint.vim b/vim/compiler/pylint.vim
new file mode 100644
index 00000000..589f78e3
--- /dev/null
+++ b/vim/compiler/pylint.vim
@@ -0,0 +1,9 @@
+" :compiler support for Python linting with pylint
+" <https://pypi.org/project/pyflakes/>
+if exists('current_compiler') || &compatible || !has('patch-7.4.191')
+ finish
+endif
+let current_compiler = 'pylint'
+
+CompilerSet makeprg=pylint\ --output-format=parseable\ --score=n\ %:S
+CompilerSet errorformat=%f:%l:\ %m
diff --git a/vim/filetype.vim b/vim/filetype.vim
index 137d1cf5..eea7f1f5 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -24,6 +24,7 @@ augroup filetypedetect
" Apache config
autocmd BufNewFile,BufRead
\ .htaccess
+ \,htaccess
\,*/apache*/?*.conf
\ setfiletype apache
" Assembly language files
@@ -67,6 +68,16 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.csv
\ setfiletype csv
+ " Debian package sources
+ autocmd BufNewFile,BufRead
+ \ sources.list
+ \,*/etc/apt/sources.list.d/*.list
+ \ setfiletype debsources
+ " Desktop files
+ autocmd BufNewFile,BufRead
+ \ ?*.desktop
+ \,?*.directory
+ \ setfiletype desktop
" Diff and patch files
autocmd BufNewFile,BufRead
\ ?*.diff
@@ -76,6 +87,7 @@ augroup filetypedetect
" INI format files
autocmd BufNewFile,BufRead
\ ?*.ini
+ \,.editorconfig
\,perlcriticrc
\,.perlcriticrc
\ setfiletype dosini
@@ -83,6 +95,10 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.dot
\ setfiletype dot
+ " NFS exports
+ autocmd BufNewFile,BufRead
+ \ exports
+ \ setfiletype exports
" Forth
autocmd BufNewFile,BufRead
\ ?*.fs,?*.ft
@@ -95,11 +111,18 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ .gdbinit
\ setfiletype gdb
+ " Gemini markup
+ autocmd BufNewFile,BufRead
+ \ *.gmi
+ \,*.gemini
+ \ setfiletype gemtext
" Git commit messages
autocmd BufNewFile,BufRead
\ COMMIT_EDITMSG
+ \,EDIT_DESCRIPTION
\,MERGE_MSG
\,TAG_EDITMSG
+ \,NOTES_EDITMSG
\ setfiletype gitcommit
" Git config files
autocmd BufNewFile,BufRead
@@ -107,6 +130,7 @@ augroup filetypedetect
\,.gitconfig
\,.gitmodules
\,gitconfig
+ \,*/.config/git/config
\ setfiletype gitconfig
" Git rebase manifests
autocmd BufNewFile,BufRead
@@ -117,26 +141,29 @@ augroup filetypedetect
\ *gnupg/options
\,*gnupg/gpg.conf
\ setfiletype gpg
+ " Golang
+ autocmd BufNewFile,BufRead
+ \ ?*.go
+ \ setfiletype go
" UNIX group file
autocmd BufNewFile,BufRead
- \ /etc/group
- \,/etc/group-
- \,/etc/group.edit
- \,/etc/gshadow
- \,/etc/gshadow-
- \,/etc/gshadow.edit
+ \ */etc/group
+ \,*/etc/group-
+ \,*/etc/group.edit
+ \,*/etc/gshadow
+ \,*/etc/gshadow-
+ \,*/etc/gshadow.edit
\ setfiletype group
" GTK settings files
autocmd BufNewFile,BufRead
- \ .gktrc*,
- \,gktrc*
+ \ .gtkrc*
+ \,gtkrc*
\ setfiletype gtkrc
" Vim help files
autocmd BufNewFile,BufRead
- \ ~/.vim/doc/?*.txt
+ \ */*.vim/doc/?*.txt
\,*/vim-*/doc/?*.txt
\,*/vim/*/doc/?*.txt
- \,*/*.vim/doc/?*.txt
\,$VIMRUNTIME/doc/?*.txt
\ setfiletype help
" HTML files
@@ -146,7 +173,7 @@ augroup filetypedetect
\ setfiletype html
" hosts(5) file
autocmd BufNewFile,BufRead
- \ /etc/hosts
+ \ */etc/hosts
\ setfiletype hostconf
" inittab(5) files
autocmd BufNewFile,BufRead
@@ -157,6 +184,10 @@ augroup filetypedetect
\ ?*.java
\,?*.jav
\ setfiletype java
+ " Jinja2 templates
+ autocmd BufNewFile,BufRead
+ \ ?*.j2
+ \ setfiletype jinja2
" JSON files
autocmd BufNewFile,BufRead
\ ?*.js
@@ -170,6 +201,11 @@ augroup filetypedetect
\ ?*.l
\,?*.lex
\ setfiletype lex
+ " limits.conf(5) files
+ autocmd BufNewFile,BufRead
+ \ limits.conf
+ \,*/limits.d/*.conf
+ \ setfiletype limits
" Lisp
autocmd BufNewFile,BufRead
\ ?*.lisp
@@ -177,10 +213,19 @@ augroup filetypedetect
\,.emacs
\,emacs
\ setfiletype lisp
+ " Login configuration
+ autocmd BufNewFile,BufRead
+ \ */etc/login.defs
+ \ setf logindefs
" Lua files
autocmd BufNewFile,BufRead
\ ?*.lua
\ setfiletype lua
+ " Lynx configuration
+ au BufNewFile,BufRead
+ \ lynx.cfg
+ \,.lynxrc
+ \ setfiletype lynx
" m4 files
autocmd BufNewFile,BufRead
\ ?*.m4
@@ -190,10 +235,15 @@ augroup filetypedetect
\ ?*.msg
\,mutt-*-[0-9]\+-[0-9]\+-[0-9]\+
\ setfiletype mail
- " Mail messages
+ " Mail aliases
autocmd BufNewFile,BufRead
\ aliases
\ setfiletype mailaliases
+ " Mailcap (MIME app reference) files
+ autocmd BufNewFile,BufRead
+ \ mailcap
+ \,.mailcap
+ \ setfiletype mailcap
" Makefiles
autocmd BufNewFile,BufRead
\ Makefile
@@ -205,13 +255,24 @@ augroup filetypedetect
\ ?*.markdown
\,?*.md
\ setfiletype markdown
+ " Meson configuration
+ autocmd BufNewFile,BufRead
+ \ meson.build
+ \,meson_options.txt
+ \ setfiletype meson
+ " SNMP MIB files
+ autocmd BufNewFile,BufRead
+ \ *.mib
+ \,*.my
+ \ setfiletype mib
" Mutt configuration files
autocmd BufNewFile,BufRead
\ Muttrc
- \,*/.muttrc.d/*.rc
+ \,*/.muttrc.d/?*.rc
+ \,*/muttrc.d/?*.rc
\,.muttrc
\,muttrc
- \,/etc/Muttrc.d/*
+ \,*/etc/Muttrc.d/*
\ setfiletype muttrc
" BIND configuration file
autocmd BufNewFile,BufRead
@@ -237,14 +298,18 @@ augroup filetypedetect
\ setfiletype nroff
" UNIX password and shadow files
autocmd BufNewFile,BufRead
- \ /etc/passwd
- \,/etc/passwd-
- \,/etc/passwd.edit
- \,/etc/shadow
- \,/etc/shadow-
- \,/etc/shadow.edit
+ \ */etc/passwd
+ \,*/etc/passwd-
+ \,*/etc/passwd.edit
+ \,*/etc/shadow
+ \,*/etc/shadow-
+ \,*/etc/shadow.edit
\ setfiletype passwd
- " Perl 5 files
+ " Packet capture files
+ autocmd BufNewFile,BufRead
+ \ ?*.pcap
+ \ setfiletype pcap
+ " Perl files
autocmd BufNewFile,BufRead
\ ?*.pl
\,?*.pm
@@ -252,12 +317,6 @@ augroup filetypedetect
\,*/xt/?*.t
\,Makefile.PL
\ setfiletype perl
- " Perl 6 files
- autocmd BufNewFile,BufRead
- \ ?*.p6
- \,?*.pl6
- \,?*.pm6
- \ setfiletype perl6
" PHP files
autocmd BufNewFile,BufRead
\ ?*.php
@@ -270,9 +329,21 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.pod6
\ setfiletype pod6
+ " protocols(5) files
+ autocmd BufNewFile,BufRead
+ \ protocols
+ \ setfiletype protocols
+ " printcap(5) files
+ autocmd BufNewFile,BufRead
+ \ printcap
+ \ let b:ptcap_type = 'print'
+ \|setfiletype ptcap
" Python files
autocmd BufNewFile,BufRead
\ ?*.py
+ \,?*.pyw
+ \,?*.pythonstartup
+ \,?*.pythonrc
\ setfiletype python
" Readline configuration file
autocmd BufNewFile,BufRead
@@ -297,13 +368,27 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.rb
\ setfiletype ruby
+ " Rust
+ autocmd BufNewFile,BufRead
+ \ ?*.rs
+ \ setfiletype rust
+ " Samba config
+ autocmd BufNewFile,BufRead
+ \ smb.conf
+ \ setfiletype samba
+ " Scheme
+ au BufNewFile,BufRead
+ \ ?*.scm
+ \,*.ss
+ \,*.sld
+ \ setfiletype scheme
" sed files
autocmd BufNewFile,BufRead
\ ?*.sed
\ setfiletype sed
" Services files
autocmd BufNewFile,BufRead
- \ /etc/services
+ \ */etc/services
\ setfiletype services
" Bash shell
autocmd BufNewFile,BufRead
@@ -336,12 +421,21 @@ augroup filetypedetect
\,.shinit
\,.shrc
\,.xinitrc
- \,/etc/default/*
+ \,.xprofile
+ \,.xsession
+ \,.xsessionrc
+ \,*/etc/default/*
\,configure
\,profile
\,shinit
\,shrc
\,xinitrc
+ \,xprofile
+ \,xsession
+ \,xsessionrc
+ \,*/etc/X11/xinit
+ \,*/etc/X11/Xreset
+ \,*/etc/X11/Xsession
\ let b:is_posix = 1
\|setfiletype sh
" SQL
@@ -349,22 +443,32 @@ augroup filetypedetect
\ ?*.sql
\ setfiletype sql
" OpenSSH configuration
+ "" client
autocmd BufNewFile,BufRead
- \ ssh_config,*/.ssh/config
+ \ ssh_config
+ \,*/ssh_config.d/*.conf
+ \,*/.ssh/config,
+ \,*/.ssh/config.d/*.conf
\ setfiletype sshconfig
+ "" server
+ autocmd BufNewFile,BufRead
+ \ sshd_config
+ \,*/sshd_config.d/*.conf
+ \ setfiletype sshdconfig
" sudoers(5)
autocmd BufNewFile,BufRead
\ sudoers
\,sudoers.tmp
- \ setfiletype sshdconfig
- " OpenSSH server configuration
- autocmd BufNewFile,BufRead
- \ sshd_config
\ setfiletype sudoers
" Subversion commit
autocmd BufNewFile,BufRead
\ svn-commit*.tmp
\ setfiletype svn
+ " sysctl configuration files
+ autocmd BufNewFile,BufRead
+ \ */etc/sysctl.conf
+ \,*/etc/sysctl.d/*.conf
+ \ setfiletype sysctl
" Systemd unit files
autocmd BufNewFile,BufRead
\ */systemd/*.*
@@ -377,10 +481,6 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.ti
\ setfiletype terminfo
- " TextEditorAnywhere text field
- autocmd BufNewFile,BufRead
- \ TextEditorAnywhere_??_??_??.txt
- \ setfiletype textarea
" Tidy config
autocmd BufNewFile,BufRead
\ .tidyrc
@@ -391,11 +491,15 @@ augroup filetypedetect
\ .tmux.conf
\,tmux.conf
\ setfiletype tmux
+ " TOML configuration files
+ autocmd BufNewFile,BufRead
+ \ ?*.toml
+ \ setfiletype toml
" Tab-separated (TSV) files
autocmd BufNewFile,BufRead
\ ?*.tsv
\ setfiletype tsv
- " VimL files
+ " Vim script files
autocmd BufNewFile,BufRead
\ ?*.vim
\,.exrc
@@ -416,12 +520,10 @@ augroup filetypedetect
\ .wgetrc
\,wgetrc
\ setfiletype wget
- " Add automatic commands to find Xresources subfiles
+ " Add automatic commands to find .Xresources subfiles
autocmd BufNewFile,BufRead
\ .Xresources
- \,*/.Xresources.d/*
\,Xresources
- \,*/Xresources.d/*
\ setfiletype xdefaults
" XHTML files
autocmd BufNewFile,BufRead
@@ -455,8 +557,8 @@ augroup filetypedetect
\,zshrc
\ setfiletype zsh
- " If it's a new file in a bin, libexec, or scripts subdir that has a
- " Makefile.PL sibling, and I'm editing it, it's almost definitely Perl.
+ " If it's a new file in a bin, libexec, or scripts subdirectory that has
+ " a Makefile.PL sibling, and I'm editing it, it's almost definitely Perl.
autocmd BufNewFile
\ ?*/bin/?*
\,?*/libexec/?*
@@ -471,8 +573,8 @@ augroup filetypedetect
" Clumsy attempt at typing files in `sudo -e` if a filename hasn't already
" been found
autocmd BufNewFile,BufRead
- \ /var/tmp/?*????????.*
- \,/var/tmp/?*.????????
+ \ */var/tmp/?*????????.*
+ \,*/var/tmp/?*.????????
\ if !did_filetype()
\| call filetype#repeat#Sudo()
\|endif
@@ -483,14 +585,14 @@ augroup filetypedetect
\,?*.txt
\,INSTALL
\,README
- \,/etc/issue
- \,/etc/motd
+ \,*/etc/issue
+ \,*/etc/motd
\ setfiletype text
autocmd BufNewFile,BufRead
\ ?*.cfg
\,?*.conf
\,?*.config
- \,/etc/*
+ \,*/etc/*
\ setfiletype conf
autocmd BufNewFile,BufRead
\ */log/*
diff --git a/vim/ftplugin/csv.vim b/vim/ftplugin/csv.vim
index 9bd3e86e..68378d62 100644
--- a/vim/ftplugin/csv.vim
+++ b/vim/ftplugin/csv.vim
@@ -4,6 +4,6 @@ if exists('b:did_ftplugin')
endif
let b:did_ftplugin = 1
-" No autoformatting
+" No automatic formatting
setlocal formatoptions=
let b:undo_ftplugin = 'formatoptions<'
diff --git a/vim/ftplugin/mail.vim b/vim/ftplugin/mail.vim
new file mode 100644
index 00000000..bc10a2ec
--- /dev/null
+++ b/vim/ftplugin/mail.vim
@@ -0,0 +1,15 @@
+" Only do this when not yet done for this buffer--but don't set the flag
+" ourselves, either; this is intended to be a prelude to
+" $VIMRUNTIME/ftplugin/mail.vim
+"
+if exists('b:did_ftplugin')
+ finish
+endif
+
+" Force no_mail_maps value on to work around loading bad maps in
+" $VIMRUNTIME/ftplugin/mail.vim
+"
+if exists('no_mail_maps')
+ let b:no_mail_maps = no_mail_maps
+endif
+let no_mail_maps = 1
diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim
index 3f41cf8d..ddd88e2c 100644
--- a/vim/ftplugin/markdown.vim
+++ b/vim/ftplugin/markdown.vim
@@ -56,7 +56,7 @@ xnoremap <buffer> <expr> <LocalLeader>Q
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q'
\ . '|xunmap <buffer> <LocalLeader>Q'
-" Autoformat headings
+" Automatically format headings
command -buffer -nargs=1 MarkdownHeading
\ call markdown#Heading(<f-args>)
nnoremap <buffer> <LocalLeader>=
diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim
deleted file mode 100644
index 4db97b58..00000000
--- a/vim/ftplugin/textarea.vim
+++ /dev/null
@@ -1,12 +0,0 @@
-" Set mail message as an alternative filetype
-if !exists('b:alternate_filetypes')
- let b:alternate_filetypes = [&filetype, 'mail']
-endif
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('no_plugin_maps') || exists('no_textarea_maps')
- finish
-endif
-
-" #s expands to the #signature tag used in Cerb
-inoreabbrev #s #signature
diff --git a/vim/plugin/2html.vim b/vim/plugin/2html.vim
deleted file mode 100644
index 95dcbb6c..00000000
--- a/vim/plugin/2html.vim
+++ /dev/null
@@ -1 +0,0 @@
-let g:html_font = ['DejaVu Sans Mono', 'Ubuntu Mono', 'Consolas']
diff --git a/vim/plugin/fortune.vim b/vim/plugin/fortune.vim
deleted file mode 100644
index efc03467..00000000
--- a/vim/plugin/fortune.vim
+++ /dev/null
@@ -1,4 +0,0 @@
-command! -bar Fortune
- \ call fortune#()
-nnoremap <silent> <Plug>(Fortune)
- \ :<C-U>Fortune<CR>
diff --git a/vim/plugin/matchit.vim b/vim/plugin/matchit.vim
index f842bd9c..392b2728 100644
--- a/vim/plugin/matchit.vim
+++ b/vim/plugin/matchit.vim
@@ -1,5 +1,5 @@
" Get matchit.vim, one way or another
-if has('packages') && !has('nvim')
+if has('packages')
packadd matchit
else
runtime macros/matchit.vim
diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim
deleted file mode 100644
index 7848e95f..00000000
--- a/vim/plugin/put_date.vim
+++ /dev/null
@@ -1,6 +0,0 @@
-if exists('loaded_put_date') || &compatible || !exists('*strftime')
- finish
-endif
-let loaded_put_date = 1
-command! -bang -bar -nargs=* -range PutDate
- \ call put_date#(<q-line1>, <q-bang> ==# '!', <q-args>)
diff --git a/vim/scripts.vim b/vim/scripts.vim
index 3c3c53cd..e025a77a 100644
--- a/vim/scripts.vim
+++ b/vim/scripts.vim
@@ -13,14 +13,14 @@ if s:line !~# '^#!'
elseif s:line =~# '\<[gm]\=awk\d*\>'
setfiletype awk
-" Perl 5
+" Lua
+elseif s:line =~# '\<lua\d*\>'
+ setfiletype lua
+
+" Perl
elseif s:line =~# '\<perl5\=\>'
setfiletype perl
-" Perl 6
-elseif s:line =~# '\<perl6\>'
- setfiletype perl6
-
" PHP
elseif s:line =~# '\<php\d*\>'
setfiletype php
diff --git a/vim/syntax/jinja2.vim b/vim/syntax/jinja2.vim
new file mode 100644
index 00000000..2b4aef1a
--- /dev/null
+++ b/vim/syntax/jinja2.vim
@@ -0,0 +1,2 @@
+" Django is similar enough to Jinja2 to be useful for highlighting
+runtime! syntax/django.vim
diff --git a/vim/vimrc b/vim/vimrc
index 2328bb11..d32b437b 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,163 +1,222 @@
-" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-" Tom Ryder (tejr)’s Literate Vimrc
-" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
-"
-" Last updated: Thu, 19 Dec 2019 17:07:46 +1300
-"
-" │ And I was lifted up in heart, and thought
-" │ Of all my late-shown prowess in the lists,
-" │ How my strong lance had beaten down the knights,
-" │ So many and famous names; and never yet
-" │ Had heaven appeared so blue, nor earth so green,
-" │ For all my blood danced in me, and I knew
-" │ That I should light upon the Holy Grail.
-" │
-" │ —Tennyson
-"
-" This file is an attempt at something like a “literate vimrc”, in the
-" tradition of Donald Knuth’s “literate programming”:
+" -----------------------------------
+" Tom Ryder (tejr)'s Literate Vimrc
+" -----------------------------------
+"
+" Last updated: Fri, 06 May 2022 12:23:48 +0000
+"
+" > And I was lifted up in heart, and thought
+" > Of all my late-shown prowess in the lists,
+" > How my strong lance had beaten down the knights,
+" > So many and famous names; and never yet
+" > Had heaven appeared so blue, nor earth so green,
+" > For all my blood danced in me, and I knew
+" > That I should light upon the Holy Grail.
+"
+" ---Tennyson
+"
+" > your vimrc is better than the bible
+"
+" ---@polanco@mastodon.sdf.org
+" <https://mastodon.sdf.org/@polanco/104069285780040986>
+"
+
+" This file is an attempt at something like a "literate vimrc", in the
+" tradition of Donald Knuth's "literate programming":
" <http://www.literateprogramming.com/>
"
-" The dotfiles project that comprises it is maintained here:
-" <https://sanctum.geek.nz/cgit/dotfiles.git>
+" The dotfiles project as part of which it is maintained is here:
+" <https://dev.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.
-"
-" 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
-" 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 multibyte 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
+" This file 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,
+" including the +eval feature, and with the 'compatible' option turned off.
+" That's to allow line continuations. The vimrc stub at ~/.vimrc (Unix) or
+" ~/_vimrc (Windows) checks that these conditions are met before loading this
+" file.
+"
+" The Vim script linter Vint should raise no errors, warnings, or style
+" problems with this file. <https://github.com/Kuniwak/vint>
+"
+
+" We'll begin by making sure that this file and Vim are speaking the same
+" language. Since it's been the future for a few years now, this file
+" indulges in characters outside the ASCII character set. The presence of
+" such characters prompts Vint to suggest declaring the file encoding with
+" a :scriptencoding command:
+"
+" > vim/vimrc:1:1: Use scriptencoding when multibyte char exists (see :help
+" > :scriptencoding)
+"
+" Furthermore, the :help for :scriptencoding specifies that :scriptencoding
+" should be set *after* 'encoding'.
+"
+" Which encoding to use? The answer is the UTF-8 encoding for Unicode,
+" wherever possible. On POSIX-fearing operating systems, I define the primary
+" locale environment variable $LANG to `en_NZ.UTF-8`. This informs Vim's
+" choice of internal character encoding. In the absence of such a setting,
+" 'encoding' defaults to `latin1` (ISO-8859-1) in most circumstances. Since
+" this is almost never what I want, even if I haven't said so explicitly by
+" exporting $LANG, we'll fall back to UTF-8 instead.
+"
+" However, we need to test that the +multi_byte feature is available before
+" doing any of this, because it was a compile-time feature that wasn't even
+" enabled by default in Vim v7.0. Its status as an optional feature wasn't
+" removed until v8.1.0733.
+"
+" <https://github.com/vim/vim/releases/tag/v8.1.0733>
+"
+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
+" 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
-" 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:
-"
-" │ A comma not preceded by a backslash, and possibly followed by an arbitrary
-" │ number of spaces and commas.
-"
-" The pattern required for the split 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
-" [, ]* ← 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.
-"
-" We do all this with an autoloaded function option#Split().
-"
-" If an environment variable MYVIM exists, and it isn’t blank, apply its value
-" as the first value of 'runtimepath', after escaping it appropriately.
-" Otherwise, do it the other way around: the first path in the 'runtimepath'
-" list becomes MYVIM.
-"
-if exists('$MYVIM') && $MYVIM !=# ''
- execute 'set runtimepath^='.argument#Escape(option#item#Escape($MYVIM, 1))
-elseif &runtimepath !=# ''
- let $MYVIM = option#Split(&runtimepath)[0]
+" therein control so much of the behavior of Vim. We build this path up as
+" accurately as possible, accounting for Vim's unusual escaping behavior for
+" these list options.
+"
+" One of the first things we'll need to be able to do is split the value of
+" 'runtimepath' into its constituent paths. Correctly splitting the values of
+" comma-separated Vim options is surprisingly complicated. It's not as simple
+" as just splitting on commas, or even unescaped commas; a more accurate
+" definition of the delimiter is:
+"
+" > Any comma not preceded by a backslash, followed by any number of spaces
+" > and commas.
+"
+" The pattern we use for the call to split() therefore breaks down like this:
+"
+" \\ <- A literal backslash
+" \@<! <- A negative lookbehind assertion; this means that whatever
+" occurred before this pattern---in this case, a backslash---
+" cannot precede what follows, but anything that *does* precede it
+" is considered part of the datum, and not the 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. If this seems wrong to you, I encourage you
+" to read the source code for the ad-hoc tokenizer in copy_option_part() in
+" src/misc2.c in Vim's source code.
+"
+" Vim, I do love you, but sometimes you're really weird.
+"
+" We fold all that mess away into 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'. We'll use this later on in the file to
+" comprehensively match expected paths for vimrc files.
+"
+if &runtimepath ==# ''
+ throw 'Empty ''runtimepath'''
+endif
+let $MYVIM = option#Split(&runtimepath)[0]
+
+" The next components of the runtime directory that we'll set up here will
+" make use of the user's configured XDG base directories:
+"
+" <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables>
+"
+" Note that this isn't an attempt to shoehorn all of Vim into the XDG mold;
+" all of this distribution's files are still expected to be installed into
+" $MYVIM, per the above. We're just leaning on XDG's conventions to provide
+" separate locations for cache files and other configuration.
+"
+" We'll start by retrieving the list of valid paths for configuration from
+" both the XDG_CONFIG_HOME and XDG_CONFIG_DIRS variables, or from their
+" defaults, using autoloaded xdg# functions.
+"
+let s:xdgconfigdirs
+ \ = xdg#ConfigDirs()
+let s:xdgconfighome
+ \ = xdg#ConfigHome()
+let s:xdgdatadirs
+ \ = xdg#DataDirs()
+let s:xdgdatahome
+ \ = xdg#DataHome()
+let s:xdgstatehome
+ \ = xdg#StateHome()
+
+" We put XDG_CONFIG_HOME at the front of the 'runtimepath' list with insert(),
+" provided it isn't empty, which is what the function returns when the
+" configured path isn't absolute. This is per the standard's dictum:
+"
+" > All paths set in these environment variables must be absolute. If an
+" > implementation encounters a relative path in any of these variables it
+" > should consider the path invalid and ignore it.
+"
+" ---XDG Base Directory Specification v0.7 (24th November 2010), "Basics",
+" <https://specifications.freedesktop.org/basedir-spec/0.7/ar01s02.html>
+"
+" Ours not to reason why...
+"
+if s:xdgconfighome !=# '' || !empty(s:xdgconfigdirs)
+ execute 'set runtimepath^='.option#Escape(join(map(
+ \ extend(
+ \ s:xdgconfighome !=# '' ? [s:xdgconfighome] : [],
+ \ s:xdgconfigdirs
+ \),
+ \ 'option#item#Escape(v:val)'
+ \), ','))
+ execute 'set runtimepath+='.option#Escape(join(map(
+ \ reverse(extend(
+ \ s:xdgconfighome !=# '' ? [s:xdgconfighome] : [],
+ \ s:xdgconfigdirs
+ \)),
+ \ 'option#item#Escape(v:val.''/after'')'
+ \), ','))
endif
-" We need a command to reliably establish a full path, whether or not the
-" directories already exist. We create a wrapper for the autoloaded function
-" path#Create() with similar calling conventions to mkdir(), but with the ‘p’
-" value for the second parameter {prot} forced on. Calling it with a bang
-" like :CreatePath! creates a private directory (permissions 0700).
-"
-command! -bang -bar -complete=dir -nargs=1 CreatePath
- \ call path#Create(expand(<q-args>), <q-bang> ==# '!')
-
-" Now that we have a way to create directories if they don’t already exist,
-" let’s apply it for the first time to the user runtime directory. Note that
-" we aren’t checking whether this actually succeeded. We do want errors
-" raised if there were problems with the creation, but we’ll barrel on ahead
-" regardless after warning the user about our failure.
-"
" Using a logical but 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 own history to the default viminfo path instead. It also
-" contributes to our aim of having everything related to the Vim runtime
-" process in one dedicated directory tree.
+" write its own history to the default viminfo path instead.
"
-" 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', but that’s still too new for us to use just yet.
+" This is the portable way to specify the path to the viminfo file, as an
+" addendum of the path to the 'viminfo' option with an `n` prefix. Vim
+" v8.1.716 introduced a way to set this with an option named 'viminfofile',
+" but I don't see a reason to use that.
"
-" <https://github.com/vim/vim/releases/tag/v8.1.0716>
-"
-execute 'set viminfo+='.argument#Escape('n'.$MYVIM.'/viminfo')
-CreatePath $MYVIM
+if s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome)
+ call mkdir(s:xdgstatehome, 'p', 0700)
+ endif
+ execute 'set viminfo+='.option#Escape(
+ \ 'n'.s:xdgstatehome.'/viminfo'
+ \)
+endif
" Speaking of recorded data in viminfo files, the default Vim limit of a mere
-" 50 entries for command and search history is pretty stingy. 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
-" 'history'’ as 10000, so let’s just use that, and see if anything breaks.
+" 50 entries for command and search history is pretty stingy. The documented
+" maximum value for this option is 10000. I used that for a while, but
+" eventually found that on lower-powered machines, keeping this much command
+" history slowed Vim startup down a bit much for my liking, so I've scaled
+" this back to a more conservative 300. If I end up missing useful commands,
+" I might try switching this on available memory instead.
"
-set history=10000
+set history=300
-" We’ll now enable automatic backups of most file buffers, since that’s off by
-" default. In practice, I don’t need these backups very much, at least if I’m
+" We'll now enable automatic backups of most file buffers, since that's off by
+" default. In practice, I don't need these backups very much, at least if I'm
" using version control sensibly, but they have still saved my bacon a few
" times.
"
-" We’ll try to keep the backup files in a dedicated cache directory, to stop
+" We'll try to keep the backup files in a dedicated cache directory, to stop
" them popping up next to the file to which they correspond, and getting
" accidentally committed to version control.
"
-" If Vim is new enough, we’ll add two trailing slashes to the path we’re
+" 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.
"
@@ -165,81 +224,124 @@ set history=10000
" this trailing slashes hint for a long time before 'backupdir' caught up to
" them. The 'directory' option for swap files has supported it at least as
" far back as v5.8.0 (2001), and 'undodir' appears to have supported it since
-" its creation in v7.2.438. Even though ‘:help 'backupdir'’ didn’t say so,
+" its creation in v7.2.438. Even though `:help 'backupdir'` didn't say so,
" people assumed it would work the same way, when in fact Vim simply 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.
+" 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
+" It's all so awkward. Surely separate options named something like
" 'backupfullname', 'swapfilefullname' would have been clearer.
"
set backup
-execute 'set backupdir^='.argument#Escape(option#item#Escape(
- \ $MYVIM.'/backup'.(has#('patch-8.1.251') ? '//' : ''),
- \))
-CreatePath! $MYVIM/backup
+if s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome.'/backup')
+ call mkdir(s:xdgstatehome.'/backup', 'p', 0700)
+ endif
+ execute 'set backupdir^='.option#Escape(option#item#Escape(
+ \ s:xdgstatehome.'/backup'.(patch#('8.1.251') ? '//' : '')
+ \))
+endif
" Files in certain directories on Unix-compatible filesystems should not be
" backed up, for security reasons. This is particularly important if editing
-" temporary files created by sudoedit(8). On Unix-like systems, we here add
-" a few paths to the default value of 'backupskip' in order to prevent the
-" creation of such undesired backup files.
-"
-" * /dev/shm: RAM disk, default path for password-store’s temporary files
-" * /usr/tmp: Hard-coded path for sudoedit(8) [1/2]
-" * /var/tmp: Hard-coded path for sudoedit(8) [2/2]
-"
-" Prior to v8.1.1519, Vim didn’t check patterns added to 'backupskip' for
-" uniqueness, so adding the same path repeatedly resulted in duplicate strings
-" in the value. This was due to the absence of the P_NODUP flag for the
-" option’s definition in src/option.c in the Vim source code. If we’re using
-" a version older than v8.1.1519, we’ll need to explicitly reset 'backupskip'
-" to its default value before adding patterns to it, so that reloading this
-" file doesn’t stack up multiple copies of any added paths.
-"
-" <https://github.com/vim/vim/releases/tag/v8.1.1519>
-"
-if has#('unix')
- if !has#('patch-8.1.1519')
+" temporary files created by sudoedit(8). We add a few path patterns to the
+" default value of 'backupskip' here, in order to prevent the creation of such
+" undesired backup files.
+"
+if has('unix')
+
+ " Prior to v8.1.1519, Vim didn't check patterns added to 'backupskip' for
+ " uniqueness, so adding the same path repeatedly resulted in duplicate
+ " strings in the value. This was due to the absence of the P_NODUP flag for
+ " the option's definition in src/option.c in the Vim source code. If we're
+ " using a version older than v8.1.1519, we'll need to explicitly reset
+ " 'backupskip' to its default value before adding patterns to it, so that
+ " reloading this file doesn't stack up multiple copies of any added paths.
+ "
+ " <https://github.com/vim/vim/releases/tag/v8.1.1519>
+ "
+ if !patch#('8.1.1519')
set backupskip&
endif
- set backupskip^=/dev/shm/*,/usr/tmp/*,/var/tmp/*
+
+ " Typical temporary file locations
+ "" RAM disk, default path for password-store's temporary files
+ set backupskip+=/dev/shm/*
+ "" Hard-coded paths for sudoedit
+ set backupskip+=/usr/tmp/*,/var/tmp/*
+
+ " Per-repository temporary files for Git
+ "" Commit and tag messages
+ set backupskip+=*/*.git/?*_EDITMSG
+ "" Edited patches
+ set backupskip+=*/*.git/ADD_EDIT.patch
+ "" Email messages
+ set backupskip+=*/*.git/.gitsendemail.msg.*
+ "" Interactive rebase manifests
+ set backupskip+=*/*.git/rebase-merge/git-rebase-todo
+
+ " systemd user manager unit files
+ "" Full unit files
+ set backupskip+=*/systemd/user/.#?*.?*????????????????
+ "" Per-unit overrides
+ set backupskip+=*/systemd/user/?*.?*.d/.#override.conf????????????????
+
endif
" Keep swap files for file buffers in a dedicated directory, rather than the
" default of writing them to the same directory as the buffer file. Add two
" trailing slashes to the path to prompt Vim to use the full escaped path in
" its name, in order to avoid filename collisions, since the 'directory'
-" option has supported that hint for much longer than 'backupdir' has. We
-" apply path#Create() to attempt to create the path, if needed.
+" option has supported that hint for much longer than 'backupdir' has.
"
-execute 'set directory^='
- \.argument#Escape(option#item#Escape($MYVIM.'/swap//'))
-CreatePath! $MYVIM/swap
+if s:xdgstatehome !=# ''
+ if !isdirectory(s:xdgstatehome.'/swap')
+ call mkdir(s:xdgstatehome.'/swap', 'p', 0700)
+ endif
+ execute 'set directory^='.option#Escape(option#item#Escape(
+ \ s:xdgstatehome.'/swap//'
+ \))
+endif
" Keep tracked undo history for files permanently, in a dedicated cache
" directory, so that the u/:undo and CTRL-R/:redo commands will work between
" Vim invocations.
"
" The 'undodir' option has the same structure as 'backupdir' and 'directory';
-" if we have a user runtime directory, create a sub-subdirectory within it
-" dedicated to the undo files cache. Note also the trailing double-slash as
-" a signal to Vim to use the full path of the original file in its undo file
-" cache’s name.
+" if we have a user cache directory, create a subdirectory within it dedicated
+" to the undo files cache. Note also the trailing double-slash as a signal to
+" Vim to use the full path of the original file in its undo file cache's name.
"
" 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.
+" so we need to check for the feature's presence before we enable it.
"
-if has#('persistent_undo')
+if s:xdgstatehome !=# '' && has('persistent_undo')
set undofile
- execute 'set undodir^='
- \.argument#Escape(option#item#Escape($MYVIM.'/undo//'))
- CreatePath! $MYVIM/undo
+ if !isdirectory(s:xdgstatehome.'/undo')
+ call mkdir(s:xdgstatehome.'/undo', 'p', 0700)
+ endif
+ execute 'set undodir^='.option#Escape(option#item#Escape(
+ \ s:xdgstatehome.'/undo//'
+ \))
+endif
+
+" Set up a directory for files generated by :mkview. To date, I think I have
+" used this twice in my life, but may as well be consistent with the other
+" directories of this type. This isn't a comma-separated list like the others
+" ('backupdir', 'directory', 'spell', 'undodir')
+"
+if s:xdgstatehome !=# '' && has('mksession')
+ if !isdirectory(s:xdgstatehome.'/view')
+ call mkdir(s:xdgstatehome.'/view', 'p', 0700)
+ endif
+ execute 'set viewdir='.option#Escape(option#item#Escape(
+ \ s:xdgstatehome.'/view'
+ \))
endif
" Now that we have a bit more confidence in our runtime environment, set up
@@ -250,7 +352,7 @@ filetype plugin indent on
" There are a couple of contexts in which it's useful to reload filetypes for
" the current buffer, quietly doing nothing if filetypes aren't enabled.
" We'll set up a user command named :ReloadFileType to do this, with
-" a script-local function backing it.
+" an autoloaded function backing it.
"
command! -bar ReloadFileType
\ call reload#FileType()
@@ -265,10 +367,6 @@ command! -bar ReloadFileType
" define the new command wrapper around an autoloaded function that itself
" issues a :ReloadFileType command after the vimrc file is sourced.
"
-" We can't put the actual :source command into the script-local function we
-" define here, because Vim would get upset that we're trying to redefine
-" a function as it executes!
-"
command! -bar ReloadVimrc
\ call reload#Vimrc()
@@ -300,7 +398,7 @@ if exists('##SourceCmd')
\ ReloadVimrc
endif
-" For spelling, use New Zealand English by default, but later on we’ll
+" For spelling, use New Zealand English by default, but later on we'll
" configure a leader mapping to switch to United States English, since I so
" often have to write for Yankees.
"
@@ -309,65 +407,75 @@ set spelllang=en_nz
" Spell checking includes optional support for catching lower case letters at
" the start of sentences, and defines a pattern in 'spellcapcheck' for the end
" of a sentence. The default is pretty good, but with two-spacing with
-" 'cpoptions' including ‘J’ and 'formatoptions' including ‘p’ as set later in
+" 'cpoptions' including `J` and 'formatoptions' including `p` as set later in
" this file, we can be less ambiguous in this pattern. We require two
" consecutive spaces, a newline, a carriage return, or a tab to mark the end
-" of a sentence. This means that we could make abbreviations like “i.e.
-" something” without flagging “something” as a spelling error.
+" of a sentence. This means that we could make abbreviations like "i.e.
+" something" without flagging "something" as a spelling error.
"
set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
+" When spell-checking snakeCased or CamelCased words, treat every upper-case
+" character in a word text object as the beginning of a new word for separate
+" spell-checking. At the time of writing, this is still a very new option
+" (v8.2.0953, June 2020).
+"
+" <https://github.com/vim/vim/releases/tag/v8.2.0953>
+"
+if exists('+spelloptions')
+ set spelloptions+=camel
+endif
+
" For word completion in insert mode with CTRL-X CTRL-K, or if 'complete'
-" includes the ‘k’ flag, the 'dictionary' option specifies the path to the
+" includes the `k` flag, the 'dictionary' option specifies the path to the
" system word list. This makes the dictionary completion work consistently,
-" even if 'spell' isn’t set at the time to coax it into using 'spellfile'.
+" even if 'spell' isn't set at the time to coax it into using 'spellfile'.
"
-" It’s not an error if the system directory file added first doesn’t exist;
-" it’s just a common location that often yields a workable word list, and does
+" It's not an error if the system directory file added first doesn't exist;
+" it's just a common location that often yields a workable word list, and does
" so on all of my main machines.
"
" At some point, I may end up having to set this option along with 'spellfile'
" a bit more intelligently to ensure that spell checking and dictionary
" function consistently, and with reference to the same resources. For the
-" moment, I’ve just added another entry referring to a directory in the user
-" runtime directory, but I don’t have anything distinct to put there yet.
-"
-" 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 and installed with
-" ‘install-vim-thesaurus’.
-"
-" 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.
-"
-" Extra checks for appending the 'dictionary' and 'thesaurus' paths in MYVIM
-" need to be made, because the P_NDNAME property is assigned to them, which
-" enforces a character blacklist in the option value. We check for the
-" expected Vim error code here, and if the MYVIM path offends, we just skip
-" the setting entirely, rather than throwing cryptic errors at the user. None
-" of the blacklisted characters are particularly wise characters to have in
-" paths, anyway, legal though they may be on Unix filesystems. We can’t work
-" around this one with 'isfname'; the blacklist is hard-coded.
+" moment, I've just added additional entries referring to the user's data
+" directory.
"
set dictionary^=/usr/share/dict/words
-let s:ref = $MYVIM.'/ref'
-try
- execute 'set dictionary^='
- \.argument#Escape(option#item#Escape(s:ref.'/dictionary.txt'))
- execute 'set thesaurus^='
- \.argument#Escape(option#item#Escape(s:ref.'/thesaurus.txt'))
-catch /^Vim\%((\a\+)\)\=:E474:/
-endtry
-
-" Next, we’ll modernize a little in adjusting some options with old
+if s:xdgdatahome !=# '' || !empty(s:xdgdatadirs)
+ execute 'set dictionary^='.option#Escape(join(map(
+ \ extend(
+ \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [],
+ \ s:xdgdatadirs
+ \),
+ \ 'option#item#Escape(v:val.''/dictionary.txt'')'
+ \), ','))
+endif
+
+" In much the same way as 'dictionary', 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 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.
+"
+if s:xdgdatahome !=# '' || !empty(s:xdgdatadirs)
+ execute 'set thesaurus^='.option#Escape(join(map(
+ \ extend(
+ \ s:xdgdatahome !=# '' ? [s:xdgdatahome] : [],
+ \ s:xdgdatadirs
+ \),
+ \ 'option#item#Escape(v:val.''/thesaurus.txt'')'
+ \), ','))
+endif
+
+" Next, we'll modernize a little in adjusting some options with old
" language-specific defaults.
"
" Traditional vi was often used for development in the C programming language.
-" The default values for a lot of Vim’s options still reflect this common use
+" The default values for a lot of Vim's options still reflect this common use
" pattern. In this case, the 'comments' and 'commentstring' options reflect
" the C syntax for comments:
"
@@ -382,20 +490,20 @@ endtry
"
" #include "baz.h"
"
-" Times change, however, and I don’t get to work with C nearly as much as I’d
+" Times change, however, and I don't get to work with C nearly as much as I'd
" like. The defaults for these options no longer make sense, and so we blank
" them, compelling filetype plugins to set them as they need instead.
"
" The default value for the 'path' option is similar, in that it has an aged
" default; this option specifies directories in which project files and
-" includes can be unearthed by navigation commands like 'gf'. Specifically,
-" its default value comprises /usr/include, which is another C default. Let’s
+" includes can be unearthed by navigation commands like `gf`. Specifically,
+" its default value comprises /usr/include, which is another C default. Let's
" get rid of that, too.
"
set comments= commentstring= define= include=
set path-=/usr/include
-" Relax traditional vi’s harsh standards over what regions of the buffer can
+" Relax traditional vi's harsh standards over what regions of the buffer can
" be removed with backspace in insert mode. While this admittedly allows bad
" habits to continue, since insert mode by definition is not really intended
" for deleting text, I feel the convenience outweighs that in this case.
@@ -405,7 +513,7 @@ set backspace+=indent " Leading whitespace characters created by 'autoindent'
set backspace+=start " Text before the start of the current insertion
" When soft-wrapping text with the 'wrap' option on, which is off by default,
-" break the lines between words, rather than within them; it’s much easier to
+" break the lines between words, rather than within them; it's much easier to
" read.
"
set linebreak
@@ -418,11 +526,11 @@ set linebreak
" … 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, though
-" it’s unlikely I’ll ever use a different Unicode encoding by choice.
+" 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')
+if has('multi_byte_encoding')
set showbreak=…
else
set showbreak=...
@@ -430,16 +538,16 @@ endif
" The visual structure of code provided by indents breaks down if a lot of the
" lines wrap. Ideally, most if not all lines would be kept below 80
-" characters, but in cases where this isn’t possible, soft-wrapping longer
+" characters, but in cases where this isn't possible, soft-wrapping longer
" lines when 'wrap' is on so that the indent is preserved in the following
" line mitigates this breakdown somewhat.
"
-" With this 'breakindent' option set, it’s particularly important to have
+" With this 'breakindent' option set, it's particularly important to have
" 'showbreak' set to something besides an empty string, as done above,
-" otherwise without line numbers it’s hard to tell what’s a logical line and
-" what’s not.
+" otherwise without line numbers it's hard to tell what's a logical line and
+" what's not.
"
-" The 'breakindent' option wasn’t added until v7.4.338, so we need to check it
+" 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>
@@ -450,18 +558,18 @@ endif
" Rather than rejecting operations like :write or :saveas when 'readonly' is
" 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.
+" a prompt to allow me to confirm that I know what I'm doing.
"
set confirm
-" If Vim receives an Escape key code in insert mode, it shouldn’t wait to see
-" if it’s going to be followed by another key code, despite this being how the
+" If Vim receives an Escape key code in insert mode, it shouldn't wait to see
+" if it's going to be followed by another key code, despite this being how the
" function keys and Meta/Alt modifier are implemented for many terminal types.
-" Otherwise, if I press Escape, there’s an annoying delay before 'showmode'
-" stops showing '--INSERT--'.
+" Otherwise, if I press Escape, there's an annoying delay before 'showmode'
+" stops showing `--INSERT--`.
"
" This breaks the function keys and the Meta/Alt modifier in insert mode in
-" most or maybe all of the terminals I use, but I don’t want those keys in
+" most or maybe all of the terminals I use, but I don't want those keys in
" insert mode, anyway. All of this works fine in the GUI, of course.
"
set noesckeys
@@ -472,109 +580,109 @@ set noesckeys
set foldlevel=256
" Automatic text wrapping options using flags in the 'formatoptions' option
-" begin here. I rely on the filetype plugins to set the ‘t’ and ‘c’ flags for
+" begin here. I rely on the filetype plugins to set the `t` and `c` flags for
" this option to configure whether text or comments should be wrapped, as
-" appropriate for the document type or language, and so I don’t mess with
+" appropriate for the document type or language, and so I don't mess with
" either of those flags here.
" If a line is already longer than 'textwidth' would otherwise limit when
-" editing of that line begins in insert mode, don’t suddenly automatically
-" wrap it; I’ll break it apart myself with a command like 'gq'. This doesn’t
-" seem to stop paragraph reformatting with ‘a’, if that’s set.
+" editing of that line begins in insert mode, don't suddenly automatically
+" wrap it; I'll break it apart myself with a command like `gq`. This doesn't
+" seem to stop paragraph reformatting with `a`, if that's set.
"
set formatoptions+=l
-" Don’t wrap a line in such a way that a single-letter word like “I” or “a” is
+" Don't wrap a line in such a way that a single-letter word like "I" or "a" is
" at the end of it. Typographically, as far as I can tell, this seems to be
-" a stylistic preference rather than a rule, rather like avoiding “widow” and
-" “orphan” lines in typesetting. I think it generally looks better to have
-" the short word start the line, so we’ll switch it on.
+" a stylistic preference rather than a rule, rather like avoiding "widow" and
+" "orphan" lines in typesetting. I think it generally looks better to have
+" the short word start the line, so we'll switch it on.
"
set formatoptions+=1
" If the filetype plugins have correctly described what the comment syntax for
-" the buffer’s language looks like, it makes sense to use that to figure out
+" the buffer's language looks like, it makes sense to use that to figure out
" how to join lines within comments without redundant comment syntax cropping
-" up. For example, with this set, joining lines in this very comment with ‘J’
-" would remove the leading ‘"’ characters.
+" up. For example, with this set, joining lines in this very comment with `J`
+" would remove the leading `"` characters.
"
-" This 'formatoptions' flag wasn’t added until v7.3.541. Because we can’t
+" This 'formatoptions' flag wasn't added until v7.3.541. Because we can't
" test for the availability of option flags directly, we resort to a version
-" number check before attempting to set it. I don’t like using :silent! to
+" number check before attempting to set it. I don't like using :silent! to
" 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 has#('patch-7.3.541')
+if patch#('7.3.541')
set formatoptions+=j
endif
-" A momentary digression here into the doldrums of 'cpoptions'—after staunchly
-" opposing it for years, I have converted to two-spacing. You can blame Steve
-" Losh:
+" A momentary digression here into the doldrums of 'cpoptions'---after
+" staunchly opposing it for years, I have converted to two-spacing. You can
+" blame Steve Losh:
"
" <http://stevelosh.com/blog/2012/10/why-i-two-space/>
"
-" Consequently, we specify that sentence objects for the purposes of the ‘s’
-" text object, the ‘(’ and ‘)’ sentence motions, and formatting with the 'gq'
+" Consequently, we specify that sentence objects for the purposes of the `s`
+" text object, the `(` and `)` sentence motions, and formatting with the 'gq'
" command must be separated by *two* spaces. One space does not suffice.
"
" My defection to the two-spacers is also the reason I now leave 'joinspaces'
" set, per its default, so that two spaces are inserted when consecutive
-" sentences separated by a line break are joined onto one line by the ‘J’
+" sentences separated by a line break are joined onto one line by the `J`
" command.
"
set cpoptions+=J
" Separating sentences with two spaces has an advantage in making a clear
" distinction between two different types of periods: periods that abbreviate
-" longer words, as in “Mr. Moolenaar”, and periods that terminate sentences,
+" longer words, as in "Mr. Moolenaar", and periods that terminate sentences,
" like this one.
"
-" If we’re using two-period spacing for sentences, Vim can interpret the
+" If we're using two-period spacing for sentences, Vim can interpret the
" different spacing to distinguish between the two types, and can thereby
" avoid breaking a line just after an abbreviating period. For example, the
-" two words in “Mr. Moolenaar” should never be split apart, lest the
-" abbreviation “Mr.” look too much like the end of a sentence. This also
+" two words in "Mr. Moolenaar" should never be split apart, lest the
+" abbreviation "Mr." look too much like the end of a sentence. This also
" preserves the semantics of that same period for subsequent reformatting; its
-" single-space won’t get lost.
+" single-space won't get lost.
"
-" So, getting back to our 'formatoptions' settings, that is what the ‘p’ flag
+" So, getting back to our 'formatoptions' settings, that is what the `p` flag
" 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/releases/tag/v8.1.1523>
"
-if has#('patch-8.1.728')
+if patch#('8.1.728')
set formatoptions+=p
endif
" In an effort to avoid loading unnecessary files, we add a flag to the
" 'guioptions' option to prevent the menu.vim runtime file from being loaded.
-" It doesn’t do any harm, but I never use it, and it’s easy to turn it off.
+" It doesn't do any harm, but I never use it, and it's easy to turn it off.
"
-" The documentation for this flag in ‘:help 'go-M'’ includes a note saying the
+" The documentation for this flag in `:help 'go-M'` includes a note saying the
" flag should be set here, rather that in the GUI-specific gvimrc file, as one
" might otherwise think.
"
-if has#('gui_running')
+if has('gui_running')
set guioptions+=M
endif
-" By default, Vim doesn’t allow a file buffer to have unwritten changes if
-" it’s not displayed in a window. Setting this option removes that
+" By default, Vim doesn't allow a file buffer to have unwritten changes if
+" it's not displayed in a window. Setting this option removes that
" restriction so that buffers can remain in a modified state while not
" actually displayed anywhere.
"
-" This option is set in almost every vimrc I read; it’s so pervasive that
-" I sometimes see comments expressing astonishment or annoyance that it isn’t
-" set by default. However, I didn’t actually need this option for several
+" This option is set in almost every vimrc I read; it's so pervasive that
+" I sometimes see comments expressing astonishment or annoyance that it isn't
+" set by default. However, I didn't actually need this option for several
" years of Vim usage, because I instinctively close windows onto buffers only
" after the buffers within them have been written anyway.
"
" However, the option really is required for batch operations performed with
-" commands like :argdo or :bufdo, because Vim won’t otherwise tolerate
+" commands like :argdo or :bufdo, because Vim won't otherwise tolerate
" unwritten changes to a litany of buffers that are not displayed in any
" window. After I started using such command maps a bit more often,
" I realized I finally had a reason to turn this on permanently.
@@ -589,16 +697,16 @@ set hidden
set hlsearch
nohlsearch
-" Highlight search matches in my text while I’m still typing my pattern,
+" Highlight search matches in my text while I'm still typing my pattern,
" including scrolling the screen to show the first such match if necessary.
" This can be somewhat jarring, particularly when the cursor ends up scrolling
" a long way from home in a large file, but I think the benefits of being able
-" to see instances of what I’m trying to match as I type the pattern do
+" to see instances of what I'm trying to match as I type the pattern do
" outweigh that discomfort.
"
set incsearch
-" Don’t waste cycles and bandwidth redrawing the screen during execution of
+" Don't waste cycles and bandwidth redrawing the screen during execution of
" macro recordings and scripts.
"
set lazyredraw
@@ -615,39 +723,39 @@ set listchars+=trail:- " Trailing spaces
set listchars+=nbsp:+ " Non-breaking spaces
" The next pair of 'list' characters are arguably somewhat misplaced, in that
-" they don’t really represent invisible characters in the same way as the
+" they don't really represent invisible characters in the same way as the
" others, but are hints for the presence of other characters on unwrapped
-" lines that are wider than the screen. They’re very useful, though.
+" lines that are wider than the screen. They're very useful, though.
"
" If the current encoding supports it, use these non-ASCII characters for the
-" markers, as they’re visually distinctive:
+" markers, as they're visually distinctive:
"
" extends: Signals presence of unwrapped text to screen right
" » U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
" precedes: Signals presence of unwrapped text to screen left
" « U+00BB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
"
-" Failing that, ‘<’ and ‘>’ will do the trick.
+" Failing that, `<` and `>` will do the trick.
"
-if has#('multi_byte_encoding')
+if has('multi_byte_encoding')
set listchars+=extends:»,precedes:«
else
set listchars+=extends:>,precedes:<
endif
-" Don’t let your editor’s options be configured by content in arbitrary files!
-" Down with modelines! Purge them from your files! Écrasez l’infâme!
+" Don't let your editor's options be configured by content in arbitrary files!
+" Down with modelines! Purge them from your files! Écrasez l'infâme!
"
-" I think that modelines are Vim’s worst misfeature, and that 'nomodeline'
-" should be the default. It’s enabled pretty bad security vulnerabilities
-" over the years, and it’s a lot more effective to use filetype detection,
+" I think that modelines are Vim's worst misfeature, and that 'nomodeline'
+" should be the default. It's enabled pretty bad security vulnerabilities
+" over the years, and it's a lot more effective to use filetype detection,
" other automatic command hooks, or methods like .editorconfig to set
" variables specifically for a buffer or project.
"
set nomodeline
" 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.
+" 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
@@ -663,7 +771,7 @@ set nrformats-=octal
set noruler
" Sessions preserve window, tab, and buffer layout, and are thereby great for
-" more complex and longer-term projects like books, but they don’t play
+" more complex and longer-term projects like books, 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 behavior to stop it trying to restore the sorts
@@ -672,74 +780,60 @@ set noruler
set sessionoptions-=localoptions " No buffer options or mappings
set sessionoptions-=options " No global options or mappings
-" Turn 'showcmd' off if a system vimrc has been rude enough to set it; I don’t
+" Turn 'showcmd' off if a system vimrc has been rude enough to set it; I don't
" like how it can interfere with the display of longer lines.
"
set noshowcmd
-" The ‘I’ flag for the 'shortmess' option prevents the display of the Vim
+" The `I` flag for the 'shortmess' option prevents the display of the Vim
" startup screen with version information, :help hints, and donation
-" suggestion. After I registered Vim and donated to Uganda per the screen’s
-" plea, I didn’t feel bad about turning this off anymore. Even with this
-" setting in place, I wouldn’t normally see it too often anyway, as I seldom
+" suggestion. After I registered Vim and donated to Uganda per the screen's
+" plea, I didn't feel bad about turning this off anymore. Even with this
+" setting in place, I wouldn't normally see it too often anyway, as I seldom
" start Vim with no file arguments.
"
-" I haven’t felt the need to mess with the other flags in this option.
-" I don’t have any problems with spurious Enter prompts, which seems to be the
+" I haven't felt the need to mess with the other flags in this option.
+" I don't have any problems with spurious Enter prompts, which seems to be the
" main reason people pile it full of letters.
"
set shortmess+=I
-" We’ll only use the old 'showmatch' method of a brief jump to the matching
-" bracket under the cursor if the much-preferred matchparen.vim standard
-" plugin doesn’t look like it’s going to load, whether because plugins have
-" been disabled, or it’s not in any of the plugin directories.
-"
-if !plugin#Ready('matchparen')
- set showmatch matchtime=3
-endif
-
" I find the defaults of new windows opening above or to the left of the
-" previous window too jarring, because I’m used to both the i3 window manager
+" previous window too jarring, because I'm used to both the i3 window manager
" and the tmux terminal multiplexer doing it the other way around, in reading
" order. I prefer the visual effect of the previous text staying where it is,
" and the new window occupying previously blank space.
"
set splitbelow splitright
-" Vim has an internal list of terminal types that support using smoother
-" terminal redrawing, and for which 'ttyfast' is normally set, described in
-" ‘:help 'ttyfast'’. That list includes most of the terminals I use, but
-" there are a couple more for which the 'ttyfast' option should apply: the
-" windows terminal emulator PuTTY, and the terminal multiplexer tmux, both of
-" which I use heavily.
+" I don't like the titles of my terminal windows being changed, especially
+" when changing them back doesn't actually work. Just leave them alone, Vim,
+" even if you think you can handle it.
"
-if &term =~# '^putty\|^tmux'
- set ttyfast
-endif
+set notitle
-" We really don’t want a mouse; while I use it a lot for cut and paste in X,
+" We really don't want a mouse; while I use it a lot for cut and paste in X,
" it just gets in the way if the tool running in the terminal tries to use it
" too. Mouse events should be exclusively handled by the terminal emulator
-" application, so Vim shouldn’t try to give me terminal mouse support, even if
+" application, so Vim shouldn't try to give me terminal mouse support, even if
" it would work.
"
" The manual suggests that disabling this should be done by clearing 't_RV',
-" but that didn’t actually seem to work when I tried it.
+" but that didn't actually seem to work when I tried it.
"
set ttymouse=
" While using virtual block mode, allow me to navigate to any column of the
-" buffer window; don’t confine the boundaries of the block to the coordinates
+" buffer window; don't confine the boundaries of the block to the coordinates
" of characters that actually exist in the buffer text. While working with
-" formatted columnar data with this off is generally OK, it’s a hassle for
+" formatted columnar data with this off is generally OK, it's a hassle for
" more subtle applications of visual block mode.
"
set virtualedit+=block
-" I can’t recall a time that Vim’s error beeping or flashing was actually
+" I can't recall a time that Vim's error beeping or flashing was actually
" useful to me, and so we turn it off in the manner that the manual instructs
-" in ‘:help 'visualbell'’. This enables visual rather than audio error bells,
+" in `:help 'visualbell'`. This enables visual rather than audio error bells,
" but in the same breath, blanks the terminal attribute that would be used to
" trigger such screen blinking, indirectly disabling the bell altogether.
"
@@ -758,7 +852,7 @@ set visualbell t_vb=
"
" The default value of 'full' for the 'wildmode' option puts the full
" completion onto the line immediately, which I tolerate for insert mode
-" completion but don’t really like on the Ex command line. Instead, I arrange
+" completion but don't really like on the Ex command line. Instead, I arrange
" for that to happen only with a second key press.
"
set wildmenu
@@ -766,7 +860,7 @@ set wildmode=list:longest,full
" Define a list of patterns to ignore for file and directory command line
" completion. Files and directories with names matching any of these patterns
-" won’t be presented as candidates for tab completion on the command line.
+" won't be presented as candidates for tab completion on the command line.
"
" To make this list, I went right through my home directory with
" a `find`-toothed comb; counted the occurrences of every extension, forced
@@ -775,7 +869,7 @@ set wildmode=list:longest,full
"
" The following incantation does the trick with POSIX-compatible shell tools,
" giving patterns for the top 100 alphanumeric extensions for files from the
-" running user’s home directory:
+" running user's home directory:
"
" $ (LC_ALL=C ; find "$HOME" ! -type d -name '*.?*' -exec \
" sh -c 'for fn ; do
@@ -790,9 +884,9 @@ set wildmode=list:longest,full
"
" 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,”
+" 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
+" 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 standardized in POSIX.
"
@@ -808,12 +902,12 @@ set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup
" Allow me to type a path to complete on the Ex command line in all-lowercase,
" and transform the consequent completion to match the appropriate case, like
-" the Readline setting ‘completion-ignore-case’ can be used for GNU Bash.
+" the Readline setting `completion-ignore-case` can be used for GNU Bash.
"
" When completing filenames on the command line, choose completions without
" regard to case, allowing me the ease of typing a partial path in
" all-lowercase. This is very similar to the Readline setting
-" ‘completion-ignore-case’ used for Bash.
+" `completion-ignore-case` used for Bash.
"
" The 'wildignorecase' option is not related to the similarly-named
" 'wildignore' option, nor to the +wildmenu feature.
@@ -827,7 +921,7 @@ if exists('+wildignorecase')
set wildignorecase
endif
-" Enable syntax highlighting, but only if it’s not already on, to save
+" Enable syntax highlighting, but only if it's not already on, to save
" reloading the syntax files unnecessarily.
"
" <https://sanctum.geek.nz/blinkenlights/syntax-on.jpg>
@@ -835,33 +929,33 @@ endif
" For several months in 2018, as an experiment, I tried using terminals with
" no color at all, imitating a phenomenally productive BSD purist co-worker
" who abhorred color in any form on his terminals. He only drank black
-" coffee, too. If you’re reading this: Hello, bdh!
+" coffee, too. If you're reading this: Hello, bdh!
"
" That experiment was instructive and interesting, and I found I had been
" leaning on color information in some surprising ways. However, some months
" later, I found I still missed my colors, and so I went back to my
-" Kodachrome roots, and didn’t pine at all for that monochrome world.
+" Kodachrome roots, and didn't pine at all for that monochrome world.
"
" The thing I most like about syntax highlighting is detecting runaway
" strings, which generally works in even the most threadbare language syntax
-" highlighting definitions. I kept missing such errors when I didn’t have the
-" colors. I don’t have high standards for it otherwise, except maybe for
+" highlighting definitions. I kept missing such errors when I didn't have the
+" colors. I don't have high standards for it otherwise, except maybe for
" shell script.
"
if !exists('syntax_on')
syntax enable
endif
-" Before we attempt to pick a syntax highlighting color scheme, we’ll set up
+" Before we attempt to pick a syntax highlighting color scheme, we'll set up
" a couple of hooks for color scheme loading. In this case, we turn
-" 'cursorline' on if my 'sahara' color scheme is loaded, since I’ve configured
-" it to be a very dark gray that doesn’t stand out too much against a black
+" 'cursorline' on if my 'sahara' color scheme is loaded, since I've configured
+" it to be a very dark gray that doesn't stand out too much against a black
" background. For any other color scheme, turn the option off, because it
" almost always stands out too much for my liking.
"
-" You’d think the pattern here could be used to match the color scheme name,
-" and it can be...after patch v7.4.108, when Christian Brabandt fixed it.
-" Until that version, it matched against the current buffer name, so we’re
+" You'd think the pattern here could be used to match the color scheme name,
+" and it can be---after patch v7.4.108, when Christian Brabandt fixed it.
+" Until that version, it matched against the current buffer name, so we're
" forced to have an explicit test in the command instead.
"
" <https://github.com/vim/vim/releases/tag/v7.4.108>
@@ -869,11 +963,11 @@ endif
autocmd vimrc ColorScheme *
\ call colorscheme#UpdateCursorline(g:colors_name, ['sahara'])
-" Use 'dark' as my default value for 'background', in the absence of an
+" Use `dark` as my default value for 'background', in the absence of an
" environment variable COLORFGBG or a response in v:termrbgresp that would set
" it specifically.
"
-if !exists('$COLORFGBG') && get(v:, 'termrbgresp', '') ==# ''
+if !exists('$COLORFGBG') && !get(v:, 'termrbgresp')
set background=dark
endif
@@ -882,7 +976,7 @@ endif
" it.
"
if &background ==# 'dark'
- \ && (has#('gui_running') || &t_Co >= 256)
+ \ && (has('gui_running') || str2nr(&t_Co) >= 256)
\ && globpath(&runtimepath, 'colors/sahara.vim') !=# ''
colorscheme sahara
endif
@@ -903,32 +997,33 @@ endif
" use selection mode directly.
"
" * Avoid mapping in insert mode; let characters be literal to the greatest
-" extent possible, and avoid “doing more” in insert mode besides merely
-" inserting text as it’s typed.
+" extent possible, and avoid "doing more" in insert mode besides merely
+" inserting text as it's typed.
"
-" * Avoid key chords with Ctrl in favor of leader keys.
+" * Avoid key chords with CTRL in favor of leader keys.
"
" * Never use Alt/Meta key chords; the terminal support for them is just too
" confusing and flaky.
"
-" * Don’t suppress display of mapped commands for no reason; it’s OK to show
-" the user the command that’s being run under the hood. Do avoid HIT-ENTER
+" * Don't suppress display of mapped commands for no reason; it's OK to show
+" the user the command that's being run under the hood. Do avoid HIT-ENTER
" prompts, though.
"
-" * Avoid shadowing any of Vim’s existing functionality. If possible, extend
+" * Avoid shadowing any of Vim's existing functionality. If possible, extend
" or supplement what Vim does, rather than replacing it.
"
-" We’ll start with the non-leader mappings. Ideally, there shouldn’t be too
+" We'll start with the non-leader mappings. Ideally, there shouldn't be too
" many of these.
"
-" Use backspace as an even quicker way to switch to the current buffer’s
+" Use backspace as an even quicker way to switch to the current buffer's
" alternate buffer. User nickspoons of #vim was incredulous that I had never
" used CTRL-^ and indeed did not know about it. I have since repented.
"
-nnoremap <Backspace> <C-^>
+nnoremap <Backspace>
+ \ <C-^>
-" I find the space bar’s default behavior in normal mode of moving right one
+" I find the space bar's default behavior in normal mode of moving right one
" character to be useless. Instead, I remap it to be a lazy way of paging
" through the argument list buffers, scrolling a page until the last line of
" the buffer is visible, and then moving to the :next buffer.
@@ -937,53 +1032,13 @@ nnoremap <Backspace> <C-^>
"
nnoremap <expr> <Space>
\ line('w$') < line('$')
- \ ? "\<PageDown>"
- \ : ":\<C-U>next\<CR>"
-
-" I hate CTRL-C’s default insert mode behavior. It ends the insert session
-" without firing the InsertLeave event for automatic command hooks. Why would
-" anyone want that? It breaks plugins that hinge on mirrored functionality
-" between the InsertEnter and InsertLeave events, and doesn’t otherwise differ
-" from Escape or :stopinsert. Even worse, people think it’s a *synonym* for
-" Escape, and use it because it’s easier to reach than the Escape key or
-" CTRL-[. Terrible!
-"
-" Instead, I apply a custom plugin named insert_cancel.vim to make it cancel
-" the current insert operation; that is, if the buffer has changed at all
-" since the start of the insert operation, pressing CTRL-C will reverse it,
-" while ending insert mode and firing InsertLeave as normal. This makes way
-" more sense to me, and I use it all the time now.
-"
-" <https://sanctum.geek.nz/cgit/vim-insert-cancel.git/about/>
-"
-" You might think on a first look, as I did, that a plugin is overkill, and
-" that a mapping like this would be all that’s required:
-"
-" :inoremap <C-C> <Esc>u
-"
-" Indeed, it *mostly* works, but there are some subtle problems with it. The
-" primary issue is that if you didn’t make any changes during the insert mode
-" session that you’re terminating, it *still* reverses the previous change,
-" which will be something else entirely that you probably *didn’t* mean to be
-" undone. The plugin’s way of working around this and the other shortcomings
-" of the simple mapping above is not too much more complicated, but it was not
-" easy to figure out.
-"
-" At any rate, we only want to establish the mapping if we can expect the
-" plugin to load, so test that 'loadplugins' is set and that the plugin file
-" exists with the expected filename.
-"
-" If the plugin isn’t available, I just abandon CTRL-C to continue its
-" uselessness.
-"
-if plugin#Ready('insert_cancel')
- imap <C-C> <Plug>(InsertCancel)
-endif
+ \ ? "\<PageDown>"
+ \ : ":\<C-U>next\<CR>"
-" I often can’t remember (or guess) digraph codes, and want to look up how to
+" I often can't remember (or guess) digraph codes, and want to look up how to
" compose a specific character that I can name, at least in part. The table
-" in ‘:help digraph-table’ is what to use for that situation, and it solves
-" the problem, but I didn’t like the overhead of repeated lookups therein.
+" in `:help digraph-table` is what to use for that situation, and it solves
+" the problem, but I didn't like the overhead of repeated lookups therein.
"
" Steve Losh has a solution I liked where a double-tap of CTRL-K in insert
" mode brought up the applicable :help window:
@@ -1002,68 +1057,72 @@ endif
" > Í I' LATIN CAPITAL LETTER I WITH ACUTE
" > ...etc...
"
-" <https://sanctum.geek.nz/cgit/vim-digraph-search.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-digraph-search.git/about/>
"
" This leaves you in insert mode, ready to hit CTRL-K one more time and then
-" type the digraph that you’ve hopefully found.
+" type the digraph that you've hopefully found.
"
-" Since a double-tap of CTRL-K does nothing in default Vim, we don’t bother
-" checking that the plugin’s available before we map to it; it’ll just quietly
+" Since a double-tap of CTRL-K does nothing in default Vim, we don't bother
+" checking that the plugin's available before we map to it; it'll just quietly
" do nothing.
"
-imap <C-K><C-K> <Plug>(DigraphSearch)
+imap <C-K><C-K>
+ \ <Plug>(DigraphSearch)
" I end up hitting CTRL-L to clear or redraw the screen in interactive shells
" and tools like Mutt and Vim pretty often. It feels natural to me to stack
" issuing a :nohlsearch command to stop highlighting searches on top of this.
"
-" This gets by far the most use in normal mode, but I’d like it to work in
-" insert and visual modes, too, where it’s occasionally useful, especially on
+" This gets by far the most use in normal mode, but I'd like it to work in
+" insert and visual modes, too, where it's occasionally useful, especially on
" things like mobile phone terminal emulators that can be choppy and require
" a lot of redrawing.
"
" For each of these, we end the mapping with a CTRL-L in normal mode, thereby
-" extending rather than replacing Vim’s normal behavior.
+" extending rather than replacing Vim's normal behavior.
"
nnoremap <C-L>
\ :<C-U>nohlsearch<CR><C-L>
" The insert mode wrapper for normal CTRL-L uses i_CTRL-O to issue a single
-" normal mode command. We intentionally use ‘:normal’ rather than ‘:normal!’
+" normal mode command. We intentionally use `:normal` rather than `:normal!`
" so that the mapping works recursively. I tried using <C-O><C-L> with :imap
-" for this, but it didn’t work. Maybe i_CTRL-O doesn’t respect mappings.
-" I couldn’t find any documentation about it.
+" for this, but it didn't work. Maybe i_CTRL-O doesn't respect mappings.
+" I couldn't find any documentation about it.
"
-inoremap <C-L> <C-O>:execute "normal \<C-L>"<CR>
+inoremap <C-L>
+ \ <C-O>:execute "normal \<C-L>"<CR>
-" We use :vnoremap here rather than :xnoremap and thereby make the mapping
-" apply to select mode as well, because CTRL-L doesn’t reflect a printable
-" character, and so we may as well make it work, even though I don’t actually
-" use select mode directly.
+" We use :vmap here rather than :xmap to have the mapping applied for select
+" mode as well as visual mode. This is because CTRL-L doesn't reflect
+" a printable character, and so we don't shadow anything by making it work,
+" even though I don't actually use select mode directly very much.
"
-vmap <C-L> <Esc><C-L>gv
+vmap <C-L>
+ \ <Esc><C-L>gv
-" By default, the very-useful normal mode command ‘&’ that repeats the
-" previous :substitute command doesn’t preserve the flags from that
-" substitution. I’d prefer it to do so, like the :&& command does, and it’s
-" easily remapped for both normal and visual mode, so let’s just do it.
+" By default, the very-useful normal mode command `&` that repeats the
+" previous :substitute command doesn't preserve the flags from that
+" substitution. I'd prefer it to do so, like the :&& command does, and it's
+" easily remapped for both normal and visual mode, so let's just do it.
"
noremap &
\ :&&<CR>
ounmap &
sunmap &
-" I really like using the ‘!’ command in normal mode as an operator to filter
+" I really like using the `!` command in normal mode as an operator to filter
" text through a shell command. It always bugged me a little that there
-" didn’t seem to be an analogue for a motion to filter text through an
+" didn't seem to be an analogue for a motion to filter text through an
" internal command like :sort, so I wrote one.
"
-" <https://sanctum.geek.nz/cgit/vim-colon-operator.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-colon-operator.git/about/>
"
-nmap g: <Plug>(ColonOperator)
+nmap g:
+ \ <Plug>(ColonOperator)
-" I used Tim Pope’s unimpaired.vim plugin for ages, and I liked some of these
-" bracket pair mappings, so I’ve carried a few of the simpler ones over. All
+" I used Tim Pope's unimpaired.vim plugin for ages, and I liked some of these
+" bracket pair mappings, so I've carried a few of the simpler ones over. All
" of these can be prefixed with a count if needed, too. I use all of them
" pretty regularly, even though cycling through lists to look for something
" can be a bit wasteful.
@@ -1089,24 +1148,26 @@ nnoremap [l
nnoremap ]l
\ :lnext<CR>
-" Here’s another mapping I particularly liked from unimpaired.vim; insert
+" Here's another mapping I particularly liked from unimpaired.vim; insert
" blank lines from normal mode, using a custom plugin of mine called
-" put_blank_lines.vim. These use operator functions so that they’re
+" put_blank_lines.vim. These use operator functions so that they're
" repeatable without repeat.vim. They accept count prefixes, too.
"
-" <https://sanctum.geek.nz/cgit/vim-put-blank-lines.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-put-blank-lines.git/about/>
"
-nmap [<Space> <Plug>(PutBlankLinesAbove)
-nmap ]<Space> <Plug>(PutBlankLinesBelow)
+nmap [<Space>
+ \ <Plug>(PutBlankLinesAbove)
+nmap ]<Space>
+ \ <Plug>(PutBlankLinesBelow)
-" We’re on to the leader maps, now. It’s difficult to know in what order to
+" We're on to the leader maps, now. It's difficult to know in what order to
" describe and specify these. I used to have them in alphabetical order, but
" it seems much more useful to group them by the type of action they take.
"
-" First of all, let’s set the leader keys; backslash happens to be the
-" default, but I like to make my choice explicit here. As of 2019, I’m still
+" First of all, let's set the leader keys; backslash happens to be the
+" default, but I like to make my choice explicit here. As of 2019, I'm still
" not certain that comma is the best choice for my local leader. I use it all
-" the time for this purpose, and it works well, but I don’t much like that it
+" the time for this purpose, and it works well, but I don't much like that it
" shadows a useful function in the fFtT;, group, and I sometimes wonder if
" I would use the key for its original function more, had I not shadowed it.
"
@@ -1118,24 +1179,25 @@ let maplocalleader = ','
" relying on mapping 'timeout'.
"
if maplocalleader ==# ','
- noremap ,, ,
+ noremap ,,
+ \ ,
sunmap ,,
endif
-" Let’s start with some simple ones; these ones all just toggle a boolean
-" option, and print its new value. They’re dirt simple to specify, and don’t
+" Let's start with some simple ones; these ones all just toggle a boolean
+" option, and print its new value. They're dirt simple to specify, and don't
" require any plugins.
"
-" These are sometimes applicable in visual mode, and sometimes not. We’ll
+" These are sometimes applicable in visual mode, and sometimes not. We'll
" start with the ones that only make sense as normal mode maps. Annoyingly,
-" a visual mode mapping for 'cursorline' toggling doesn’t work at all;
+" a visual mode mapping for 'cursorline' toggling doesn't work at all;
" 'cursorline' is always off when in any visual mode, including block mode,
" where it actually might have been really handy.
"" Leader,TAB toggles automatic indentation based on the previous line
nnoremap <Leader><Tab>
\ :<C-U>set autoindent! autoindent?<CR>
-"" Leader,c toggles highlighted cursor row; doesn’t work in visual mode
+"" Leader,c toggles highlighted cursor row; doesn't work in visual mode
nnoremap <Leader>c
\ :<C-U>set cursorline! cursorline?<CR>
"" Leader,h toggles highlighting search results
@@ -1178,17 +1240,10 @@ noremap <Leader>w
ounmap <Leader>w
sunmap <Leader>w
-" This next one just shows option state of the 'formatoptions' affecting how
-" text is automatically formatted; it doesn’t change its value.
-
-"" Leader,f shows the current 'formatoptions' at a glance
-nnoremap <Leader>f
- \ :<C-U>set formatoptions?<CR>
-
" I often have to switch between US English and NZ English. The latter is
" almost exactly the same as UK English in most locales, although we use
" dollars rather than pounds. This is mostly so I remember things like
-" excluding or including the ‘u’ in words like 'favourite', depending on the
+" excluding or including the `u` in words like `favourite`, depending on the
" target audience. I generally use US English for international audiences.
"
nnoremap <Leader>z
@@ -1196,33 +1251,45 @@ nnoremap <Leader>z
nnoremap <Leader>u
\ :<C-U>set spelllang=en_us<CR>
-" The next mapping is also for toggling an option, but it’s more complicated;
+" I've also been trying to learn French lately (2023-04-03), and having
+" a spelling check there is handy for doing my homework.
+"
+" This mapping used to show the state of 'formatoptions', but I haven't been
+" using that nearly as often lately.
+"
+" <https://sanctum.geek.nz/images/ze-cultured-frenchman.png>
+"
+nnoremap <Leader>f
+ \ :<C-U>set spelllang=fr<CR>
+
+" The next mapping is also for toggling an option, but it's more complicated;
" it uses a simple plugin of mine called copy_linebreak.vim to manage several
" options at once, related to the 'wrap' option that soft-wraps text.
"
-" It’s designed for usage in terminal emulators and multiplexers to
+" It's designed for usage in terminal emulators and multiplexers to
" temporarily make the buffer text suitable for copying in such a way that the
-" wrapping and any associated soft formatting won’t pervert the text,
+" wrapping and any associated soft formatting won't pervert the text,
" including 'breakindent', 'linebreak', and 'showbreak' artifacts.
"
" This is really handy for quick selections of small regions of text. For
" larger blocks of text or for manipulating the text as it leaves the buffer,
" it makes more sense to use :! commands.
"
-" <https://sanctum.geek.nz/cgit/vim-copy-linebreak.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-copy-linebreak.git/about/>
"
"" Leader,b toggles settings friendly to copying and pasting
-nmap <Leader>b <Plug>(CopyLinebreakToggle)
+nmap <Leader>b
+ \ <Plug>(CopyLinebreakToggle)
" The above mappings show that mappings for toggling boolean options are
-" simple, but there isn’t a way to toggle single flags within option strings
+" simple, but there isn't a way to toggle single flags within option strings
" with just the :set command, so I wrote a plugin called toggle_flags.vim to
" provide :ToggleFlag and :ToggleFlagLocal commands. The first argument is
" the name of an option, and the second is the flag within it that should be
" toggled on or off.
-"" Leader,a toggles 'formatoptions' ‘a’ auto-flowing flag
+"" Leader,a toggles 'formatoptions' `a` auto-flowing flag
nnoremap <Leader>a
\ :<C-U>ToggleFlagLocal formatoptions a<CR>
"" Leader,L toggles 'colorcolumn' showing the first column beyond 'textwidth'
@@ -1232,12 +1299,13 @@ ounmap <Leader>L
sunmap <Leader>L
" This mapping uses my paste_insert.vim plugin to queue up automatic commands
-" for the next insert operation. It’s still pretty new. It replaces my old
+" for the next insert operation. It's still pretty new. It replaces my old
" paste_open.vim plugin which did this only for opening new lines, and which
-" kept confusing me. I’m hoping this will be better.
+" kept confusing me. I'm hoping this will be better.
"" Leader,p prepares the next insert for paste mode
-nmap <Leader>p <Plug>PasteInsert
+nmap <Leader>p
+ \ <Plug>PasteInsert
" These mappings are for managing filetypes. The first one uses the
" :ReloadFileType command that was defined much earlier in this file for
@@ -1264,20 +1332,19 @@ nnoremap <Leader>D
\ :PutDate!<CR>
" This group contains mappings that are to do with file and path management
-" relative to the current buffer. The Leader,P mapping that creates
-" directory hierarchies uses the :CreatePath command created earlier.
+" relative to the current buffer.
-"" Leader,g shows the current file’s fully expanded path
+"" Leader,g shows the current file's fully expanded path
nnoremap <Leader>g
\ :<C-U>echo expand('%:p')<CR>
-"" Leader,G changes directory to the current file’s location
+"" Leader,G changes directory to the current file's location
nnoremap <Leader>G
- \ :<C-U>cd %:h<Bar>pwd<CR>
-"" Leader,P creates the path to the current file if it doesn’t exist
+ \ :<C-U>cd %:h <Bar> pwd<CR>
+"" Leader,P creates the path to the current file if it doesn't exist
nnoremap <Leader>P
- \ :<C-U>CreatePath %:h<CR>
+ \ :<C-U>call mkdir(expand('%:h'), 'p')<CR>
-" This group contains mappings that show information about Vim’s internals:
+" This group contains mappings that show information about Vim's internals:
" marks, registers, variables, and the like.
"" Leader,H shows command history
@@ -1312,8 +1379,8 @@ nnoremap <Leader>y
\ :<C-U>registers<CR>
" This group contains mappings concerned with buffer navigation and
-" management. I use the “jetpack” buffer jumper one a lot. I got it from one
-" of bairui’s “Vim and Vigor” comics:
+" management. I use the "jetpack" buffer jumper one a lot. I got it from one
+" of bairui's "Vim and Vigor" comics:
"
" <http://of-vim-and-vigor.blogspot.com/p/vim-vigor-comic.html>
@@ -1329,27 +1396,28 @@ nnoremap <Leader>e
"" Leader,E locks a buffer, reversible with <Leader>e
nnoremap <Leader>E
\ :<C-U>set nomodifiable readonly<CR>
-"" Leader,j jumps to buffers—the “jetpack”
+"" Leader,j jumps to buffers---the "jetpack"
nnoremap <Leader>j
\ :<C-U>buffers<CR>:buffer<Space>
" Leader,o hacks up the list of old files from viminfo just long enough to
-" ensure that :browse :oldfiles fits in a screen, avoiding an Enter or ‘q’
+" ensure that :browse :oldfiles fits in a screen, avoiding an Enter or `q`
" keystroke before entering the number. This one is handy followed by
" <Leader>,\ to jump back to the last remembered position in that file, since
" by definition viminfo remembers that mark, too.
"
-nmap <Leader>o <Plug>(SelectOldFiles)
+nmap <Leader>o
+ \ <Plug>(SelectOldFiles)
" This group defines mappings for filtering and batch operations to clean up
" buffer text. All of these mappings use commands from my custom plugins:
"
" :KeepPosition
-" <https://sanctum.geek.nz/cgit/vim-keep-position.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-keep-position.git/about/>
" :SqueezeRepeatBlanks
-" <https://sanctum.geek.nz/cgit/vim-squeeze-repeat-blanks.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-squeeze-repeat-blanks.git/about/>
" :StripTrailingWhitespace
-" <https://sanctum.geek.nz/cgit/vim-strip-trailing-whitespace.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-strip-trailing-whitespace.git/about/>
"
"" Leader,x strips trailing whitespace
@@ -1371,7 +1439,7 @@ nnoremap <Leader>+
\ :<C-U>KeepPosition execute 'normal! 1GgqG'<CR>
" This group defines a few :onoremap commands to make my own text objects.
-" I should probably make some more of these, as they’ve proven to be
+" I should probably make some more of these, as they've proven to be
" terrifically handy.
"" Leader,_ uses last changed or yanked text as an object
@@ -1380,21 +1448,25 @@ onoremap <Leader>_
"" Leader,% or Leader,5 uses entire buffer as an object
onoremap <Leader>%
\ :<C-U>execute 'normal! 1GVG'<CR>
-omap <Leader>5 <Leader>%
+omap <Leader>5
+ \ <Leader>%
" This group defines some useful motions, including navigating by indent
" block using a custom plugin:
"
-" <https://sanctum.geek.nz/cgit/vim-vertical-region.git/about/>
+" <https://dev.sanctum.geek.nz/cgit/vim-vertical-region.git/about/>
"
"" Leader,{ and Leader,} move to top and bottom of indent region
-map <Leader>{ <Plug>(VerticalRegionUp)
+map <Leader>{
+ \ <Plug>(VerticalRegionUp)
sunmap <Leader>{
-map <Leader>} <Plug>(VerticalRegionDown)
+map <Leader>}
+ \ <Plug>(VerticalRegionDown)
sunmap <Leader>}
-"" Leader,\ jumps to the last edit position mark; think “Now, where was I?”
-noremap <Leader>\ `"
+"" Leader,\ jumps to the last edit position mark; think "Now, where was I?"
+noremap <Leader>\
+ \ `"
sunmap <Leader>\
" This group does both: useful motions on defined text objects.
@@ -1414,88 +1486,109 @@ nnoremap <Leader>/
nnoremap <Leader>?
\ :<C-U>lhelpgrep \c<S-Left>
-" This group contains miscellaneous mappings for which I couldn’t find any
+" This group contains miscellaneous mappings for which I couldn't find any
" other place. The plugin mappings probably require their own documentation
" comment block, but my hands are getting tired from all this typing.
"
-" * <https://sanctum.geek.nz/cgit/vim-alternate-filetype.git/about/>
-" * <https://sanctum.geek.nz/cgit/vim-regex-escape.git/about/>
-" * <https://sanctum.geek.nz/cgit/vim-replace-operator.git/about/>
-" * <https://sanctum.geek.nz/cgit/vim-scratch-buffer.git/about/>
+" * <https://dev.sanctum.geek.nz/cgit/vim-alternate-filetype.git/about/>
+" * <https://dev.sanctum.geek.nz/cgit/vim-regex-escape.git/about/>
+" * <https://dev.sanctum.geek.nz/cgit/vim-replace-operator.git/about/>
+" * <https://dev.sanctum.geek.nz/cgit/vim-scratch-buffer.git/about/>
"
"" Leader,. runs the configured make program into the location list
nnoremap <Leader>.
\ :<C-U>lmake!<CR>
"" Leader,q formats the current paragraph
-nnoremap <Leader>q gqap
+nnoremap <Leader>q
+ \ gqap
"" Leader,r acts as a replacement operator
-map <Leader>r <Plug>(ReplaceOperator)
+map <Leader>r
+ \ <Plug>(ReplaceOperator)
ounmap <Leader>r
sunmap <Leader>r
"" Leader,!/1 repeats the last command, adding a bang
nnoremap <Leader>!
\ :<Up><Home><S-Right>!<CR>
-nmap <Leader>1 <Leader>!
-"" Leader,#/3 switches the current buffer to the next altenate filetype
-nmap <Leader># <Plug>(AlternateFileType)
-nmap <Leader>3 <Leader>#
-"" Leader,$/4 gives me my fortune
-nmap <Leader>$ <Plug>(Fortune)
-nmap <Leader>4 <Leader>$
+nmap <Leader>1
+ \ <Leader>!
+"" Leader,#/3 switches the current buffer to the next alternate filetype
+nmap <Leader>#
+ \ <Plug>(AlternateFileType)
+nmap <Leader>3
+ \ <Leader>#
"" Leader,&/7 escapes regex metacharacters
-map <Leader>& <Plug>(RegexEscape)
+map <Leader>&
+ \ <Plug>(RegexEscape)
ounmap <Leader>&
sunmap <Leader>&
-map <Leader>7 <Leader>&
+map <Leader>7
+ \ <Leader>&
ounmap <Leader>7
sunmap <Leader>7
"" Leader,*/8 is "sticky star":
"" - Set search string to word under cursor
"" - Show search highlighting if it's enabled
"" - Don't move the cursor
-nnoremap <silent> <Leader>*
- \ :<C-U>let @/ = expand('<cword>')<CR>:let &hlsearch = &hlsearch<CR>
-nmap <Leader>8 <Leader>*
+nnoremap <Leader>*
+ \ :<C-U>let @/ = expand('<cword>') <Bar> let &hlsearch = &hlsearch<CR>
+nmap <Leader>8
+ \ <Leader>*
"" Leader,` opens a scratch buffer, horizontally split
-nnoremap <silent> <Leader>`
+nnoremap <Leader>`
\ :<C-U>ScratchBuffer<CR>
"" Leader,~ opens a scratch buffer, vertically split
-nnoremap <silent> <Leader>~
+nnoremap <Leader>~
\ :<C-U>vertical ScratchBuffer<CR>
-" And last, but definitely not least, I’m required by Vim fanatic law to
+" There's no digraph for ZERO WIDTH SPACE (U+200B), which I often need to work
+" around word boundary problems in tagging people on the Fediverse.
+"
+digraphs zs 8203
+
+" And last, but definitely not least, I'm required by Vim fanatic law to
" include a mapping that reloads my whole configuration. This uses the
" command wrapper defined much earlier in the file, so that filetypes also get
-" reloaded afterwards, meaning I don’t need to follow <Leader>R with
+" reloaded afterwards, meaning I don't need to follow <Leader>R with
" a <Leader>F to fix up broken global settings.
"
nnoremap <Leader>R
\ :<C-U>ReloadVimrc<CR>
-" I’ll close this file with a few abbreviations. Perhaps of everything in
-" here, I’m least confident that these should be in here, but they’ve proven
+" I'll close this file with a few abbreviations. Perhaps of everything in
+" here, I'm least confident that these should be in here, but they've proven
" pretty useful. First, some 'deliberate' abbreviations for stuff I type
" a lot:
"
-inoreabbrev tr@ tom@sanctum.geek.nz
-inoreabbrev tr/ <https://sanctum.geek.nz/>
+inoreabbrev tr@
+ \ tom@sanctum.geek.nz
+inoreabbrev tr/
+ \ <https://sanctum.geek.nz/>
" And then, just automatically fix some things I almsot always spell or type
" wrnog.
"
-inoreabbrev almsot almost
-inoreabbrev wrnog wrong
-inoreabbrev Fielding Feilding
-inoreabbrev THe The
-inoreabbrev THere There
+inoreabbrev almsot
+ \ almost
+inoreabbrev wrnog
+ \ wrong
+inoreabbrev Fielding
+ \ Feilding
+inoreabbrev Newsbeuter
+ \ Newsboat
+inoreabbrev newsbeuter
+ \ newsboat
+inoreabbrev THe
+ \ The
+inoreabbrev THere
+ \ There
" Here endeth the literate vimrc. Let us praise God.
"
-" │ Consequently, it is soon recognized that they write for the sake of
-" │ filling up the paper, and this is the case sometimes with the best
-" │ authors…as soon as this is perceived the book should be thrown away,
-" │ for time is precious.
-" │
-" │ —Schopenhauer
+" > Consequently, it is soon recognized that they write for the sake of
+" > filling up the paper, and this is the case sometimes with the best
+" > authors...as soon as this is perceived the book should be thrown away,
+" > for time is precious.
+" >
+" > ---Schopenhauer
"
diff --git a/vim/vimrc.stub b/vim/vimrc.stub
index d50cee55..92c53dfb 100644
--- a/vim/vimrc.stub
+++ b/vim/vimrc.stub
@@ -1,23 +1,25 @@
" We have a big, important decision to make here.
"
-" Check that we’re not running in 'compatible' mode, nor that the environment
-" calls for the same, and that we’re running Vim v7.0.0 or newer. If it’s all
+" Check that we're not running in 'compatible' mode, nor that the environment
+" calls for the same, and that we're running Vim v7.0.0 or newer. If it's all
" clear, we can load the main vimrc file from ~/.vim/vimrc to use Vim in all
" of its incompatible glory, and then stop sourcing the rest of this file.
"
-if !&compatible && !exists('$POSIXLY_CORRECT') && v:version >= 700
- runtime vimrc
- finish
+if !&compatible && !exists('$POSIXLY_CORRECT')
+ if v:version >= 700
+ runtime vimrc
+ finish
+ endif
endif
-" If we got this far, it means we’re running a tiny, 'compatible', and/or
+" If we got this far, it means we're running a tiny, 'compatible', and/or
" ancient version of Vim.
"
" So, strip out the user runtime directories from 'runtimepath', force
-" 'compatible' on, source your trusty ‘~/.exrc’, put on your dubbed cassette
-" copy of Kraftwerk’s ‘Computerwelt’, and start using vi v3.7 on your
-" engineering department’s Sun OS 4.x server via your VT220 terminal. It’s
-" July 1985, you write K&R C, and it’s good for you, like raisin bran.
+" 'compatible' on, source your trusty '~/.exrc', put on your dubbed cassette
+" copy of Kraftwerk's 'Computerwelt', and start using vi v3.7 on your
+" engineering department's Sun OS 4.x server via your VT220 terminal. It's
+" July 1985, you write K&R C, and it's good for you, like raisin bran.
"
set runtimepath-=~/.vim
set runtimepath-=~/.vim/after