diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-11 15:35:38 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-11 15:35:38 +1200 |
commit | 3814784142de6c5cefb595d4af2b25772fc4a537 (patch) | |
tree | 54f339270dc5a49db5eb760a18fdeec70526a48c | |
parent | Merge branch 'release/v5.40.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-3814784142de6c5cefb595d4af2b25772fc4a537.tar.gz dotfiles-3814784142de6c5cefb595d4af2b25772fc4a537.zip |
Merge branch 'release/v5.41.0'v5.41.0
* release/v5.41.0:
Factor out :ReloadVimrc extras into function
Include faked display of :ReloadVimrc command
Clean up ad-hoc plugins
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/autoload/spellfile_local.vim | 11 | ||||
-rw-r--r-- | vim/autoload/utc.vim | 4 | ||||
-rw-r--r-- | vim/plugin/put_date.vim | 5 | ||||
-rw-r--r-- | vim/plugin/spellfile_local.vim | 25 | ||||
-rw-r--r-- | vim/plugin/utc.vim | 25 | ||||
-rw-r--r-- | vim/vimrc | 17 |
7 files changed, 35 insertions, 56 deletions
@@ -1,2 +1,2 @@ -tejr dotfiles v5.40.0 -Tue Jun 11 03:04:55 UTC 2019 +tejr dotfiles v5.41.0 +Tue Jun 11 03:35:38 UTC 2019 diff --git a/vim/autoload/spellfile_local.vim b/vim/autoload/spellfile_local.vim new file mode 100644 index 00000000..aafe64ef --- /dev/null +++ b/vim/autoload/spellfile_local.vim @@ -0,0 +1,11 @@ +function! spellfile_local#() abort + let spellfile = join([ + \ substitute(expand('%:p'), '[^0-9A-Za-z_.-]', '%', 'g'), + \ substitute(v:lang, '_.*', '', ''), + \ &encoding + \ ], '.') . '.add' + Establish $MYVIM/cache/spell/local + execute 'setlocal spellfile+=$MYVIM/cache/spell/local/'.spellfile + nnoremap <buffer> zG 2zg + xnoremap <buffer> zG 2zg +endfunction diff --git a/vim/autoload/utc.vim b/vim/autoload/utc.vim new file mode 100644 index 00000000..1a464342 --- /dev/null +++ b/vim/autoload/utc.vim @@ -0,0 +1,4 @@ +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 0828abe4..d911486e 100644 --- a/vim/plugin/put_date.vim +++ b/vim/plugin/put_date.vim @@ -2,10 +2,5 @@ if exists('loaded_put_date') finish endif let loaded_put_date = 1 - -" Define a :PutDate command that inserts a line into the buffer with an -" RFC-2822 date string, using the system strftime() implementation. Allow it -" to accept a range which defaults to the current line. -" command! -bar -range PutDate \ <line1>put =strftime('%a, %d %b %Y %T %z') diff --git a/vim/plugin/spellfile_local.vim b/vim/plugin/spellfile_local.vim index bb6421f2..b04b7573 100644 --- a/vim/plugin/spellfile_local.vim +++ b/vim/plugin/spellfile_local.vim @@ -3,32 +3,17 @@ if exists('loaded_spellfile_local') endif let loaded_spellfile_local = 1 -Establish $MYVIM/cache/spell - -let spellfile = join([ +let s:spellfile = join([ \ substitute(v:lang, '_.*', '', ''), \ &encoding \ ], '.') . '.add' -execute 'set spellfile=$MYVIM/cache/spell/'.spellfile - -Establish $MYVIM/cache/spell/local - -function! AddLocalSpellFile() abort - let spellfile = join([ - \ substitute(expand('%:p'), '[^0-9A-Za-z_.-]', '%', 'g'), - \ substitute(v:lang, '_.*', '', ''), - \ &encoding - \ ], '.') . '.add' - setlocal spellfile< - execute 'setlocal spellfile+=$MYVIM/cache/spell/local/'.spellfile - nnoremap <buffer> zG 2zg - xnoremap <buffer> zG 2zg -endfunction +Establish $MYVIM/cache/spell +execute 'set spellfile=$MYVIM/cache/spell/'.s:spellfile command! AddLocalSpellFile - \ call AddLocalSpellFile() + \ call spellfile_local#() augroup spellfile_local - autocmd BufRead * + autocmd BufNew,BufRead * \ AddLocalSpellFile augroup END diff --git a/vim/plugin/utc.vim b/vim/plugin/utc.vim index 8fb84890..e395ebd4 100644 --- a/vim/plugin/utc.vim +++ b/vim/plugin/utc.vim @@ -2,30 +2,5 @@ if exists('loaded_utc') finish endif let loaded_utc = 1 - -" Define a :UTC command wrapper, implemented with a script-local function of -" the same name. Use expand('$TZ') to ensure we're getting the value of the -" current timezone from the environment, and cache that in a local variable -" just long enough to manipulate the environment into using UTC for a command. -" -" While this is a tidy way to abstract the operation for the map, I don't like -" the function implementation much at all. It works OK in stable versions of -" Vim, but changing an environment variable just long enough to affect the -" outcome of a command as a side effect seems a bit gross. -" -" Worse, the whole thing presently seems to be broken in v8.1.1487; the -" timezone first chosen seems to 'stick' permanently, and the mapping each -" produce timestamps in that zone. I haven't worked out why this happens yet. -" Using the new getenv() and setenv() functions does not seem to fix it. It -" works fine in Debian GNU/Linux's packaged v8.0.x. - -function! s:UTC(command) abort - let tz = expand('$TZ') - let $TZ = 'UTC' | execute a:command | let $TZ = tz -endfunction - -" The :UTC command itself completes another command name, and accepts one -" required argument, which it passes in quoted form to the helper function. -" command! -bar -complete=command -nargs=1 UTC \ call s:UTC(<q-args>) @@ -153,16 +153,25 @@ command! -bar ReloadFileType " specified by filetype and indent plugins. To handle this, we'll define the " command to run :ReloadFileType after the vimrc file is sourced. " -" We can't put these two commands in a script-local function in the vimrc, in -" order to be tidy like we did for :ReloadFileType above, because Vim would -" get upset that we're trying to redefine a function as it executes! +" We can't put the actual :source command into the script-local function, +" because Vim would get upset that we're trying to redefine a function as it +" executes! " " Just to be on the safe side, we also suppress any further ##SourceCmd hooks " from running the :source command with a :noautocmd wrapper. This is " a defensive measure to avoid infinite recursion. " +" We emit a faked display of the command, as well, just to make it clear that +" something has happened. The :redraw just before that message seems to be +" necessary, but I'm not sure why. +" +function! s:ReloadVimrc() abort + ReloadFileType + redraw + echo ':ReloadVimrc' +endfunction command! -bar ReloadVimrc - \ noautocmd source $MYVIMRC | ReloadFileType + \ noautocmd source $MYVIMRC | call s:ReloadVimrc() " Reset and define a group of automatic command hooks specific to matters " related to reloading the vimrc itself. |