Skip to content

Commit

Permalink
Merge branch 'feature-disable-upward-search-optionally'
Browse files Browse the repository at this point in the history
  • Loading branch information
talha131 committed Feb 10, 2017
2 parents 775ea57 + 8b236d9 commit 7c5b24d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ every local vimrc file.

- Default: `1`

### The `g:localvimrc_disable_upward_search` setting

The plugin searches for `g:localvimrc_name` file from the directory of the current file up to the root directory.
Set this option to `1` to disable upward search. If set to `1` plugin searches only in the file directory.

- Default: `0`

### The `g:localvimrc_debug` setting

Debug level for this script.
Expand Down
14 changes: 13 additions & 1 deletion plugin/localvimrc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ if (!exists("g:localvimrc_debug"))
let g:localvimrc_debug = 0
endif

" define default "localvimrc_disable_upward_search" {{{2
if (!exists("g:localvimrc_disable_upward_search"))
let g:localvimrc_disable_upward_search = 0
endif

" initialize data dictionary {{{2
" key: localvimrc file
" value: [ answer, sandbox_answer, checksum ]
Expand Down Expand Up @@ -200,10 +205,17 @@ function! s:LocalVimRC()
endif
call s:LocalVimRCDebug(2, "searching directory \"" . l:directory . "\"")

" should Vim search upward?
let l:searchDirection = ";" " upward search
if (g:localvimrc_disable_upward_search == 1)
let l:searchDirection = "" " only current directory
call s:LocalVimRCDebug(2, "Upward search is disabled")
endif

" generate a list of all local vimrc files with absolute file names along path to root
let l:rcfiles = []
for l:rcname in s:localvimrc_name
for l:rcfile in findfile(l:rcname, l:directory . ";", -1)
for l:rcfile in findfile(l:rcname, l:directory . l:searchDirection, -1)
let l:rcfile_unresolved = fnamemodify(l:rcfile, ":p")
let l:rcfile_resolved = resolve(l:rcfile_unresolved)
call insert(l:rcfiles, { "resolved": l:rcfile_resolved, "unresolved": l:rcfile_unresolved } )
Expand Down

0 comments on commit 7c5b24d

Please sign in to comment.