diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-11 15:35:24 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-11 15:35:24 +1200 |
commit | c62f1a60047ec6403de06efdaceffaf1bffaa1a5 (patch) | |
tree | b35c8a471994f4f19fa16f5e33eb8d17678ed350 | |
parent | Include faked display of :ReloadVimrc command (diff) | |
download | dotfiles-c62f1a60047ec6403de06efdaceffaf1bffaa1a5.tar.gz dotfiles-c62f1a60047ec6403de06efdaceffaf1bffaa1a5.zip |
Factor out :ReloadVimrc extras into function
-rw-r--r-- | vim/vimrc | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -153,21 +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 redraw the screen and emit a faked display of the command, as well. +" 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 - \|redraw! - \|echomsg ':ReloadVimrc' + \ noautocmd source $MYVIMRC | call s:ReloadVimrc() " Reset and define a group of automatic command hooks specific to matters " related to reloading the vimrc itself. |