From 0a0b398f4b0f5ea007f6951f3de3a1cc374aa6c5 Mon Sep 17 00:00:00 2001 From: Tom Plunket Date: Wed, 1 Jun 2016 12:11:34 -0700 Subject: [PATCH] Adds customizable list of items to look for when searching for the project root. --- autoload/ag.vim | 10 ++++++++-- doc/ag.txt | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index 432ef444..7d776e06 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -57,7 +57,11 @@ if !exists("g:ag_mapping_message") endif if !exists("g:ag_working_path_mode") - let g:ag_working_path_mode = 'c' + let g:ag_working_path_mode = 'c' +endif + +if !exists("g:ag_working_path_root_markers") + let g:ag_working_path_root_markers = ['.rootdir', '.git', '.hg', '.svn', 'bzr', '_darcs', 'build.xml', 'tags', 'TAGS'] endif function! ag#AgBuffer(cmd, args) @@ -220,7 +224,7 @@ function! s:guessProjectRoot() while len(l:splitsearchdir) > 2 let l:searchdir = '/'.join(l:splitsearchdir, '/').'/' - for l:marker in ['.rootdir', '.git', '.hg', '.svn', 'bzr', '_darcs', 'build.xml'] + for l:marker in g:ag_working_path_root_markers " found it! Return the dir if filereadable(l:searchdir.l:marker) || isdirectory(l:searchdir.l:marker) return l:searchdir @@ -232,3 +236,5 @@ function! s:guessProjectRoot() " Nothing found, fallback to current working dir return getcwd() endfunction + +" vim:ts=2:sw=2:et diff --git a/doc/ag.txt b/doc/ag.txt index e702c291..07e516ca 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -94,9 +94,17 @@ For background, see: https://github.com/rking/ag.vim/pull/88 *g:ag_working_path_mode* A mapping that describes where ag will be run. Default is the current working directory. Specifying 'r' as the argument will tell it to run from the project -rootdirectory. For now any other mapping will result to the default. -Example: +rootdirectory. For now any other mapping will result to the default. Example: > let g:ag_working_path_mode='r' +< + + *g:ag_working_path_root_markers* +A list of file and directory names to look for when |g:ag_working_path_mode| +is 'r' and |g:Ag_get_project_root| is left at its default value. Default list +is ['.rootdir', '.git', '.hg', '.svn', 'bzr', '_darcs', 'build.xml', 'tags', 'TAGS']. +Example: > + let g:ag_working_path_root_markers = ['tags'] +< *g:ag_highlight* If 1, highlight the search terms after searching. Default: 0. Example: >