aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-08 22:27:58 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-08 22:37:20 +1200
commit13b91d3bac6351acc846ce3faf4558340f0e3fc8 (patch)
treee5c9ce0f6b46f7da771a90812900cf61d9ea2c7a
parentMore adjustment of $MYVIM comment documentation (diff)
downloaddotfiles-13b91d3bac6351acc846ce3faf4558340f0e3fc8.tar.gz
dotfiles-13b91d3bac6351acc846ce3faf4558340f0e3fc8.zip
Move vimrc-reload-filetype back into vimrc
I think this is a more sensible location for it. We'll see.
m---------vim/bundle/vimrc_reload_filetype0
-rw-r--r--vim/vimrc37
2 files changed, 33 insertions, 4 deletions
diff --git a/vim/bundle/vimrc_reload_filetype b/vim/bundle/vimrc_reload_filetype
deleted file mode 160000
-Subproject 1a59433fa33f737264af73a7323ce669fa14a21
diff --git a/vim/vimrc b/vim/vimrc
index d66c94a1..57b1c134 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -97,10 +97,39 @@ augroup END
autocmd vimrc BufWritePost $MYVIMRC,$MYVIM/vimrc
\ source $MYVIMRC
-" Global indent settings go here. Filetype indent plugins will often refine
-" these settings for individual buffers. For example, 'expandtab' is not
-" appropriate for Makefiles, nor for the Go programming language. For
-" another, two-space indents are more traditional for Vim script.
+" Similarly, if this file or the vimrc stub that calls it is sourced, whether
+" because of the above hook, or the <Leader>R mapping prescribed later in this
+" file, add a hook that re-runs filetype detection and thereby ftplugin
+" loading. This is chiefly so that any global options set in this file don't
+" trample over needed buffer-local settings.
+"
+" If there's stuff in any of your ftplugins that doesn't cope well with being
+" reloaded, and just assumes a single BufRead event, it might be necessary to
+" rewrite those parts to be idempotent, or to add load guards around them so
+" that they only run once.
+"
+" Note that the SourceCmd event wasn't added until Vim 7.0.187, so we need to
+" check it exists first.
+"
+if exists('##SourceCmd')
+
+ " We can't wrap this in a script-local function like I normally would,
+ " because then Vim will get upset that we're trying to redefine it the next
+ " time it loads. It's only four commands, anyway.
+ "
+ autocmd vimrc SourceCmd $MYVIMRC,$MYVIM/vimrc
+ \ source <afile>
+ \|if exists('#filetypedetect#BufRead')
+ \| doautocmd filetypedetect BufRead
+ \|endif
+
+endif
+
+" Global indent and other whitespace-related settings go here. Filetype
+" indent plugins will often refine these settings for individual buffers. For
+" example, 'expandtab' is not appropriate for Makefiles, nor for the Go
+" programming language. For another, two-space indents are more traditional
+" for Vim script.
"
" In general, however, I prefer spaces to tabs as a default, and I like to use
" four of them, for a more distinct visual structure. Should you happen to