Permalink
Browse files

add possibility to modify autocommand event

  • Loading branch information...
1 parent 616dc53 commit 6d071c82f01bde1aa996d746461ff8dfbf04c31d @embear committed Feb 23, 2014
Showing with 26 additions and 2 deletions.
  1. +14 −0 doc/localvimrc.txt
  2. +12 −2 plugin/localvimrc.vim
View
@@ -116,6 +116,20 @@ Filename of local vimrc files.
Default: ".lvimrc"
------------------------------------------------------------------------------
+*g:localvimrc_event*
+
+List of autocommand events that trigger local vimrc file loading.
+
+Default: [ "BufWinEnter" ]
+
+NOTE: BufWinEnter is the default to enable lines like
+
+ setlocal colorcolumn=+1
+
+ in the local vimrc file. Settings "local to window" need to be set for
+ every time a buffer is displayed in a window.
+
+------------------------------------------------------------------------------
*g:localvimrc_reverse*
Reverse behavior of loading local vimrc files.
View
@@ -36,6 +36,14 @@ else
let s:localvimrc_name = g:localvimrc_name
endif
+" define default "localvimrc_event" {{{2
+" copy to script local variable to prevent .lvimrc modifying the name option.
+if (!exists("g:localvimrc_event") || !(type(g:localvimrc_event) == type([])))
+ let s:localvimrc_event = [ "BufWinEnter" ]
+else
+ let s:localvimrc_event = g:localvimrc_event
+endif
+
" define default "localvimrc_reverse" {{{2
" copy to script local variable to prevent .lvimrc modifying the reverse
" option.
@@ -133,8 +141,10 @@ if has("autocmd")
augroup localvimrc
autocmd!
- " call s:LocalVimRC() when creating ore reading any file
- autocmd BufWinEnter * call s:LocalVimRC()
+ for event in s:localvimrc_event
+ " call s:LocalVimRC() when creating ore reading any file
+ exec "autocmd ".event." * call s:LocalVimRC()"
+ endfor
augroup END
endif

0 comments on commit 6d071c8

Please sign in to comment.