From a2e117375b1ae913e3dd18412f6e9d2d105e72e1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 19:28:03 +1200 Subject: More comment corrections --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5d12b321..02fa7e6e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -991,7 +991,7 @@ autocmd vimrc ColorScheme sahara " We'll have Vim try to use my 'sahara' fork of the 'desert256' color scheme. " If we fail to load the color scheme, for whatever reason, suppress the -" error, and default to a dark background (if not already) for the the default +" error, and default to a dark background (if not already) for the default " color scheme in the absence of guidance otherwise from a COLORFGBG " environment variable or a t_RB terminal response. Vim otherwise defaults to " 'light', which is less likely in my case. @@ -1466,7 +1466,7 @@ nnoremap j " 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' -" keypress before entering the number. This one is handy followed by +" keystroke before entering the number. This one is handy followed by " ,\ to jump back to the last remembered position in that file, since " by definition viminfo remembers that mark, too. " -- cgit v1.2.3 From a19e427e59884f3150874f14be43c16fb7c48c43 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 19:29:42 +1200 Subject: Document choice of format for PutDate() --- vim/plugin/put_date.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim index d911486e..486171a3 100644 --- a/vim/plugin/put_date.vim +++ b/vim/plugin/put_date.vim @@ -2,5 +2,6 @@ if exists('loaded_put_date') finish endif let loaded_put_date = 1 +let s:rfc_2822 = '%a, %d %b %Y %T %z' command! -bar -range PutDate - \ put =strftime('%a, %d %b %Y %T %z') + \ put =strftime(s:rfc_2822) -- cgit v1.2.3 From d03a9d7b3f724706775c793df7b6b627ea4ef60a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 19:45:40 +1200 Subject: Consolidate utc.vim and put_date.vim into latter --- vim/autoload/put_date.vim | 19 +++++++++++++++++++ vim/autoload/utc.vim | 4 ---- vim/plugin/put_date.vim | 5 ++--- vim/plugin/utc.vim | 6 ------ vim/vimrc | 6 +++--- 5 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 vim/autoload/put_date.vim delete mode 100644 vim/autoload/utc.vim delete mode 100644 vim/plugin/utc.vim diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim new file mode 100644 index 00000000..2b618632 --- /dev/null +++ b/vim/autoload/put_date.vim @@ -0,0 +1,19 @@ +let s:rfc_2822 = '%a, %d %b %Y %T %z' + +function! put_date#(line, bang, ...) abort + let line = a:line + let utc = a:bang ==# '!' + let format = a:0 + \ ? substitute(a:1, '\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/utc.vim b/vim/autoload/utc.vim deleted file mode 100644 index 1a464342..00000000 --- a/vim/autoload/utc.vim +++ /dev/null @@ -1,4 +0,0 @@ -function! utc#(command) abort - let tz = expand('$TZ') - let $TZ = 'UTC' | execute a:command | let $TZ = tz -endfunction diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim index 486171a3..e54d6054 100644 --- a/vim/plugin/put_date.vim +++ b/vim/plugin/put_date.vim @@ -2,6 +2,5 @@ if exists('loaded_put_date') finish endif let loaded_put_date = 1 -let s:rfc_2822 = '%a, %d %b %Y %T %z' -command! -bar -range PutDate - \ put =strftime(s:rfc_2822) +command! -bang -bar -nargs=* -range PutDate + \ call put_date#(, , ) diff --git a/vim/plugin/utc.vim b/vim/plugin/utc.vim deleted file mode 100644 index 9b8b647a..00000000 --- a/vim/plugin/utc.vim +++ /dev/null @@ -1,6 +0,0 @@ -if exists('loaded_utc') - finish -endif -let loaded_utc = 1 -command! -bar -complete=command -nargs=1 UTC - \ call utc#() diff --git a/vim/vimrc b/vim/vimrc index 02fa7e6e..8e063900 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1384,15 +1384,15 @@ nnoremap t nnoremap T \ :setlocal filetype= -" These mappings use my put_date.vim and utc.vim plugins for date insertion -" into the buffer. +" These mappings use my put_date.vim plugin for date insertion into the +" buffer. "" Leader,d inserts the local date (RFC 2822) nnoremap d \ :PutDate "" Leader,D inserts the UTC date (RFC 2822) nnoremap D - \ :UTC PutDate + \ :PutDate! " This group contains mappings that are to do with file and path management " relative to the current buffer. The Leader,P mapping that creates -- cgit v1.2.3 From 20d4d7c73e6e095f7328f986e235b7385e073f09 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 20:19:19 +1200 Subject: Refactor and fix arg errors in put_date.vim plugin --- vim/autoload/put_date.vim | 8 ++++---- vim/plugin/put_date.vim | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim index 2b618632..c9f52c12 100644 --- a/vim/autoload/put_date.vim +++ b/vim/autoload/put_date.vim @@ -1,10 +1,10 @@ let s:rfc_2822 = '%a, %d %b %Y %T %z' -function! put_date#(line, bang, ...) abort +function! put_date#(line, utc, format) abort let line = a:line - let utc = a:bang ==# '!' - let format = a:0 - \ ? substitute(a:1, '\a', '%&', 'g') + let utc = a:utc + let format = strlen(a:format) + \ ? substitute(a:format, '\a', '%&', 'g') \ : s:rfc_2822 if utc if exists('$TZ') diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim index e54d6054..7608f978 100644 --- a/vim/plugin/put_date.vim +++ b/vim/plugin/put_date.vim @@ -3,4 +3,4 @@ if exists('loaded_put_date') endif let loaded_put_date = 1 command! -bang -bar -nargs=* -range PutDate - \ call put_date#(, , ) + \ call put_date#(, ==# '!', ) -- cgit v1.2.3 From 1865e4449a7619d901a69b235ec1380a4537b888 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 20:19:53 +1200 Subject: Add a rough normal mode map to repeat with bang --- vim/vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index 8e063900..9f4d68e5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1555,6 +1555,9 @@ nnoremap ? "" Leader,. runs the configured make program into the location list nnoremap . \ :lmake! +"" Leader,! repeats the last command, adding a bang +nnoremap ! + \ :! "" Leader,q formats the current paragraph nnoremap q gqap "" Leader,r acts as a replacement operator -- cgit v1.2.3 From 8e32154a72d26673913d7a679d8c893ea44d682b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 20:45:26 +1200 Subject: Add SelectOldFiles mapping --- vim/plugin/select_old_files.vim | 2 ++ vim/vimrc | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vim/plugin/select_old_files.vim b/vim/plugin/select_old_files.vim index dbfbd64c..5d880404 100644 --- a/vim/plugin/select_old_files.vim +++ b/vim/plugin/select_old_files.vim @@ -4,3 +4,5 @@ endif let loaded_select_old_files = 1 command! -bar SelectOldFiles \ call select_old_files#() +nnoremap SelectOldFiles + \ :SelectOldFiles diff --git a/vim/vimrc b/vim/vimrc index 9f4d68e5..7f2d9ae8 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1470,8 +1470,7 @@ nnoremap j " ,\ to jump back to the last remembered position in that file, since " by definition viminfo remembers that mark, too. " -nnoremap o - \ :SelectOldFiles +nmap o 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: -- cgit v1.2.3 From a01eba1329fc53e2ed13862f3e4c86cb9d0a0392 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 20:46:19 +1200 Subject: Enhance load guard or select_old_files.vim --- vim/plugin/select_old_files.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/plugin/select_old_files.vim b/vim/plugin/select_old_files.vim index 5d880404..c03f0c39 100644 --- a/vim/plugin/select_old_files.vim +++ b/vim/plugin/select_old_files.vim @@ -1,4 +1,4 @@ -if exists('loaded_select_old_files') +if exists('loaded_select_old_files') || &compatible || !exists(':oldfiles') finish endif let loaded_select_old_files = 1 -- cgit v1.2.3 From 72195cf648af3c9db85a0f864574965dc6b8409d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 20:46:57 +1200 Subject: Refactor select_old_files.vim to allow count --- vim/autoload/select_old_files.vim | 16 +++++++++++++--- vim/plugin/select_old_files.vim | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/vim/autoload/select_old_files.vim b/vim/autoload/select_old_files.vim index 518b98d4..aceff110 100644 --- a/vim/autoload/select_old_files.vim +++ b/vim/autoload/select_old_files.vim @@ -1,7 +1,17 @@ -function! select_old_files#() abort +function! select_old_files#(...) abort + if a:0 + if a:1 =~# '^\d\+$' + let limit = a:1 + else + echoerr 'Invalid count' + endif + elseif exists('g:select_old_files_limit') + let limit = g:select_old_files_limit + else + let limit = &lines - 2 + endif let oldfiles = v:oldfiles - let limit = get(g:, 'select_old_files_limit', &lines - 1) - let v:oldfiles = v:oldfiles[:limit-2] + let v:oldfiles = v:oldfiles[:limit - 1] browse oldfiles let v:oldfiles = oldfiles endfunction diff --git a/vim/plugin/select_old_files.vim b/vim/plugin/select_old_files.vim index c03f0c39..77c7746e 100644 --- a/vim/plugin/select_old_files.vim +++ b/vim/plugin/select_old_files.vim @@ -2,7 +2,7 @@ if exists('loaded_select_old_files') || &compatible || !exists(':oldfiles') finish endif let loaded_select_old_files = 1 -command! -bar SelectOldFiles - \ call select_old_files#() +command! -bar -nargs=? SelectOldFiles + \ call select_old_files#() nnoremap SelectOldFiles \ :SelectOldFiles -- cgit v1.2.3 From 13d56da45a47f73b55aa5544aafe68d36774b51d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 17 Jun 2019 00:47:52 +1200 Subject: Overhaul local Vim spellfile word list plugin --- vim/autoload/spellfile_local.vim | 79 +++++++++++++++++++++++++++++++++++----- vim/plugin/spellfile_local.vim | 13 ++----- vim/vimrc | 16 ++++++++ 3 files changed, 89 insertions(+), 19 deletions(-) diff --git a/vim/autoload/spellfile_local.vim b/vim/autoload/spellfile_local.vim index aafe64ef..081b2970 100644 --- a/vim/autoload/spellfile_local.vim +++ b/vim/autoload/spellfile_local.vim @@ -1,11 +1,72 @@ +function! s:SplitOption(string) abort + return map( + \ split(a:string, '\\\@ zG 2zg - xnoremap zG 2zg + + set spellfile< + + let spelllangs = s:SplitOption(&spelllang) + if !len(spelllangs) || &spelllang[0] ==# '' + echoerr 'Blank ''spelllang''' + endif + let spelllang = substitute(spelllangs[0], '_.*', '', '') + + if !len(&encoding) + echoerr 'Blank ''encoding''' + endif + + let spellfiles = s:SplitOption(&spellfile) + if len(spellfiles) != 1 || spellfiles[0] ==# '' + return + endif + + let spelldir = fnamemodify(spellfiles[0], ':h') + if spelldir ==# '' + echoerr 'Blank directory' + endif + + try + let path = substitute(expand('%:p'), '/', '%', 'g') + if path ==# '' + echoerr 'Blank path' + endif + call s:Establish(spelldir.'/path') + call add(spellfiles, spelldir.'/path/'.join([ + \ path + \,spelllang + \,&encoding + \,'add' + \], '.')) + + if &filetype ==# '' + echoerr 'Blank filetype' + endif + call s:Establish(spelldir.'/filetype') + call add(spellfiles, spelldir.'/filetype/'.join([ + \ &filetype + \,spelllang + \,&encoding + \,'add' + \], '.')) + catch + endtry + + let &l:spellfile = s:JoinOption(spellfiles) + endfunction diff --git a/vim/plugin/spellfile_local.vim b/vim/plugin/spellfile_local.vim index c026d626..f6918bfb 100644 --- a/vim/plugin/spellfile_local.vim +++ b/vim/plugin/spellfile_local.vim @@ -1,19 +1,12 @@ -if exists('loaded_spellfile_local') +if exists('loaded_spellfile_local') || &compatible finish endif let loaded_spellfile_local = 1 -let s:spellfile = join([ - \ substitute(v:lang, '_.*', '', ''), - \ &encoding - \ ], '.') . '.add' -Establish $MYVIM/cache/spell -execute 'set spellfile=$MYVIM/cache/spell/'.s:spellfile - -command! -bar AddLocalSpellFile +command! -bar SetLocalSpellFiles \ call spellfile_local#() augroup spellfile_local autocmd BufNew,BufRead * - \ AddLocalSpellFile + \ SetLocalSpellFiles augroup END diff --git a/vim/vimrc b/vim/vimrc index 7f2d9ae8..dc9430e1 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -398,6 +398,22 @@ if has('persistent_undo') set undodir^=$MYVIM/cache/undo// endif +" 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. We'll set the 'spellfile' option too, to +" place it in the cache directory into which we've been putting everything. +" We'll follow Vim's standard naming convention for the file itself, though. +" If available, my plugin spellfile_local.vim will extend this later to add +" more spelling word lists per filetype and per file. +" +set spelllang=en_nz +Establish $MYVIM/cache/spell +let &spellfile = $MYVIM.'/cache/spell/'.join([ + \ substitute(&spelllang, '_.*', '', '') + \,&encoding + \,'add' + \], '.') + " 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 " system word list. This makes the dictionary completion work consistently, -- cgit v1.2.3 From c60eb545d316eac73f6ef27d1e3ed51f1aaf3c85 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 17 Jun 2019 00:48:17 +1200 Subject: Adjust comma position in broken lines --- vim/vimrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index dc9430e1..9cc74c3b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -103,9 +103,9 @@ scriptencoding utf-8 " Vim, I love you, but you are really weird. " let s:runtimepath = map( - \ split(&runtimepath, '\\\@ Date: Mon, 17 Jun 2019 00:48:35 +1200 Subject: Add load guards to Vim plugins not spun out yet --- vim/plugin/paste_insert.vim | 2 +- vim/plugin/put_date.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim index 9cd5415e..2c17f802 100644 --- a/vim/plugin/paste_insert.vim +++ b/vim/plugin/paste_insert.vim @@ -1,4 +1,4 @@ -if exists('loaded_paste_insert') +if exists('loaded_paste_insert') || &compatible finish endif let loaded_paste_insert = 1 diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim index 7608f978..e78f5fcd 100644 --- a/vim/plugin/put_date.vim +++ b/vim/plugin/put_date.vim @@ -1,4 +1,4 @@ -if exists('loaded_put_date') +if exists('loaded_put_date') || &compatible || !has('*strftime') finish endif let loaded_put_date = 1 -- cgit v1.2.3 From e0c4a26bbf36e0660f961477b99ab0089185f7c0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 17 Jun 2019 00:52:58 +1200 Subject: Spelling and capitalisation fixes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9f124ea4..6b3b5dad 100644 --- a/README.md +++ b/README.md @@ -349,7 +349,7 @@ keybindings. It's extensively commented. I define my own `filetype.vim` and `scripts.vim`, so that filetype detection works in a way I like, and loads quickly. They are unlikely to suit you as -they are, but if you want to use it, you can extend them with your favourite +they are, but if you want to use it, you can extend them with your favorite filetypes in custom `ftdetect` rules. #### Plugins @@ -485,7 +485,7 @@ Installed by the `install-bin` target: * `apf(1df)` inserts arguments to a command with ones read from a file, intended as a framework for shell wrappers or functions. * `ax(1df)` evaluates an AWK expression given on the command line; this is - intended as a quick way to test how Awk would interpret a given expression. + intended as a quick way to test how AWK would interpret a given expression. * `bcq(1df)` runs `bc(1)`, quieting it down if need be. * `bel(1df)` prints a terminal bell character. * `bl(1df)` generates a given number of blank lines. @@ -536,7 +536,7 @@ Installed by the `install-bin` target: * `mex(1df)` makes given filenames in `$PATH` executable. * `mi5(1df)` is a crude preprocessor for `m4`. * `mim(1df)` starts an interactive Mutt message with its input. -* `mftl(1df)` finds usable-looking targets in makefiles. +* `mftl(1df)` finds usable-looking targets in Makefiles. * `mkcp(1df)` creates a directory and copies preceding arguments into it. * `mkmv(1df)` creates a directory and moves preceding arguments into it. * `motd(1df)` shows the system MOTD. @@ -545,7 +545,7 @@ Installed by the `install-bin` target: * `oii(1df)` runs a command on input only if there is any. * `onl(1df)` crunches input down to one printable line. * `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s - `s_client` subcommand. + `s_client` sub-command. * `p(1df)` prints concatenated standard input; `cat(1)` as it should always have been. * `pa(1df)` prints its arguments, one per line. -- cgit v1.2.3 From 0c886a2906fd0f03cb4e1627a911220cb5432fd1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 17 Jun 2019 00:53:17 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 67ae0149..ff435ccc 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v6.20.0 -Sun, 16 Jun 2019 06:06:53 +0000 +tejr dotfiles v6.21.0 +Sun, 16 Jun 2019 12:53:17 +0000 -- cgit v1.2.3 From a8422fd0e781c275d082cf5a9400f47ee38676eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 17 Jun 2019 00:53:17 +1200 Subject: Update dotfiles(7) manual page --- man/man7/dotfiles.7df | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index a4800f6b..e43c4f38 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -496,7 +496,7 @@ It's extensively commented. I define my own \f[C]filetype.vim\f[] and \f[C]scripts.vim\f[], so that filetype detection works in a way I like, and loads quickly. They are unlikely to suit you as they are, but if you want to use it, -you can extend them with your favourite filetypes in custom +you can extend them with your favorite filetypes in custom \f[C]ftdetect\f[] rules. .SS Plugins .PP @@ -736,7 +736,7 @@ input, prompting if appropriate. file, intended as a framework for shell wrappers or functions. .IP \[bu] 2 \f[C]ax(1df)\f[] evaluates an AWK expression given on the command line; -this is intended as a quick way to test how Awk would interpret a given +this is intended as a quick way to test how AWK would interpret a given expression. .IP \[bu] 2 \f[C]bcq(1df)\f[] runs \f[C]bc(1)\f[], quieting it down if need be. @@ -834,7 +834,7 @@ Good for quick tests. .IP \[bu] 2 \f[C]mim(1df)\f[] starts an interactive Mutt message with its input. .IP \[bu] 2 -\f[C]mftl(1df)\f[] finds usable\-looking targets in makefiles. +\f[C]mftl(1df)\f[] finds usable\-looking targets in Makefiles. .IP \[bu] 2 \f[C]mkcp(1df)\f[] creates a directory and copies preceding arguments into it. @@ -852,7 +852,7 @@ one per line. \f[C]onl(1df)\f[] crunches input down to one printable line. .IP \[bu] 2 \f[C]osc(1df)\f[] implements a \f[C]netcat(1)\f[]\-like wrapper for -\f[C]openssl(1)\f[]'s \f[C]s_client\f[] subcommand. +\f[C]openssl(1)\f[]'s \f[C]s_client\f[] sub\-command. .IP \[bu] 2 \f[C]p(1df)\f[] prints concatenated standard input; \f[C]cat(1)\f[] as it should always have been. -- cgit v1.2.3