Skip to content

Commit

Permalink
add ability to view local vimrc before sourcing
Browse files Browse the repository at this point in the history
  • Loading branch information
embear committed Oct 7, 2016
1 parent 2d4c622 commit f0c9b8d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ vX.X.X : XXXX-XX-XX

- |g:localvimrc_whitelist| and |g:localvimrc_blacklist| now takes optionally a list of regular expressions.
- add convenience variables |g:localvimrc_script_unresolved| and |g:localvimrc_script_dir_unresolved|.
- add ability to view local vimrc before sourcing when |g:localvimrc_ask| is enabled.

v2.4.0 : 2016-02-05

Expand Down
3 changes: 3 additions & 0 deletions doc/localvimrc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ vX.X.X : XXXX-XX-XX
- add convenience variables |g:localvimrc_script_unresolved| and
|g:localvimrc_script_dir_unresolved|.

- add ability to view local vimrc before sourcing when |g:localvimrc_ask| is
enabled.

v2.4.0 : 2016-02-05

- add setting |g:localvimrc_event| which defines the autocommand events that
Expand Down
22 changes: 19 additions & 3 deletions plugin/localvimrc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,14 @@ function! s:LocalVimRC()
if (l:answer !~? "^a$")
call s:LocalVimRCDebug(2, "need to ask")
let l:answer = ""
let l:message = ""
while (l:answer !~? '^[ynaq]$')
if (s:localvimrc_persistent == 0)
let l:message = "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[q]uit) "
let l:message .= "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[s]how/[q]uit) "
elseif (s:localvimrc_persistent == 1)
let l:message = "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[q]uit ; persistent [Y]es/[N]o/[A]ll) "
let l:message .= "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[s]how/[q]uit ; persistent [Y]es/[N]o/[A]ll) "
else
let l:message = "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[q]uit) "
let l:message .= "localvimrc: source " . l:rcfile . "? ([y]es/[n]o/[a]ll/[s]how/[q]uit) "
endif

" turn off possible previous :silent command to force this
Expand All @@ -308,6 +309,21 @@ function! s:LocalVimRC()
call s:LocalVimRCDebug(2, "aborting on empty answer")
let l:answer = "q"
endif

" add the content of the file for repeating the question
let l:message = ""
if (l:answer =~? "^s$")
let l:message .= "localvimrc: >>>>>>>> start content of " . l:rcfile . "\n"
let l:content_max = 10
let l:content = readfile(l:rcfile, "", l:content_max + 1)
for l:line in l:content
let l:message .= "localvimrc: " . l:line . "\n"
endfor
if len(l:content) > l:content_max
let l:message .= "localvimrc: ======== TRUNCATED AFTER " . l:content_max . " LINES!\n"
endif
let l:message .= "localvimrc: <<<<<<<< end content of " . l:rcfile . "\n"
endif
endwhile
endif

Expand Down

0 comments on commit f0c9b8d

Please sign in to comment.