aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-14 20:37:41 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-14 20:38:14 +1200
commit34f746015a76fda53b70dda91f81edf41f75d472 (patch)
treefaec7e7683406436a24e591d1357c19ee3d5b742
downloadvim-vimrc-reload-filetype-34f746015a76fda53b70dda91f81edf41f75d472.tar.gz
vim-vimrc-reload-filetype-34f746015a76fda53b70dda91f81edf41f75d472.zip
First versionv0.1.0
-rw-r--r--README.md17
-rw-r--r--VERSION1
-rw-r--r--doc/vimrc_reload_filetype.txt25
-rw-r--r--plugin/vimrc_reload_filetype.vim31
4 files changed, 74 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7f66b19
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+vimrc\_reload\_filetype.vim
+===========================
+
+This plugin installs a hook for re-sourcing the `vimrc` file that follows it
+with a command to reload filetype detection and filetype plugin loading for the
+current buffer, to correct the issue of `vimrc` `:set` commands clobbering
+filetype-specific `:setlocal` options.
+
+It also echoes a nice "Reloaded vimrc" message so you know it's working.
+
+License
+-------
+
+Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself.
+See `:help license`.
+
+[1]: https://sanctum.geek.nz/
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6e8bf73
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1.0
diff --git a/doc/vimrc_reload_filetype.txt b/doc/vimrc_reload_filetype.txt
new file mode 100644
index 0000000..03ec7c2
--- /dev/null
+++ b/doc/vimrc_reload_filetype.txt
@@ -0,0 +1,25 @@
+*vimrc_reload_filetype.txt* For Vim version 7.1 Last change: 2018 July 14
+
+DESCRIPTION *vimrc_reload_filetype*
+
+This plugin installs a hook for re-sourcing the |vimrc| file that follows it
+with a command to reload filetype detection and filetype plugin loading for
+the current buffer, to correct the issue of |vimrc| |:set| commands clobbering
+filetype-specific |:setlocal| options.
+
+It also echoes a nice "Reloaded vimrc" message so you know it's working.
+
+REQUIREMENTS *vimrc_reload_filetype-requirements*
+
+This plugin only loads if 'compatible' is not set. It requires |version-7.1|
+(or |version-7.0| with patch 187) for the |SourceCmd| |autocmd-event|.
+
+AUTHOR *vimrc_reload_filetype-author*
+
+Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.
+
+LICENSE *vimrc_reload_filetype-license*
+
+Licensed for distribution under the same terms as Vim itself (see |license|).
+
+ vim:tw=78:ts=8:ft=help:norl:
diff --git a/plugin/vimrc_reload_filetype.vim b/plugin/vimrc_reload_filetype.vim
new file mode 100644
index 0000000..c2587f9
--- /dev/null
+++ b/plugin/vimrc_reload_filetype.vim
@@ -0,0 +1,31 @@
+"
+" vimrc_reload_filetype.vim: Add hook to reload active buffer's filetype when
+" vimrc reloaded, so that we don't end up indenting four spaces in an open
+" VimL file, etc. Requires Vim 7.1 or 7.0 with patch 187 for SourceCmd.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('g:loaded_vimrc_reload_filetype') || &compatible
+ finish
+endif
+if !has('autocmd') || !exists('##SourceCmd')
+ finish
+endif
+let g:loaded_vimrc_reload_filetype = 1
+
+" Wrapper function reloads .vimrc and filetypes
+function! s:Reload() abort
+ source <afile>
+ if exists('#filetypedetect#BufRead')
+ doautocmd filetypedetect BufRead
+ endif
+ redraw
+ echomsg 'Reloaded vimrc: '.expand('<afile>')
+endfunction
+
+" This SourceCmd intercepts :source for .vimrc
+augroup vimrc_reload_filetype
+ autocmd!
+ autocmd SourceCmd $MYVIMRC call s:Reload()
+augroup END