Skip to content

Adds customizable list of items to look for when searching for project root #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions autoload/ag.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -232,3 +236,5 @@ function! s:guessProjectRoot()
" Nothing found, fallback to current working dir
return getcwd()
endfunction

" vim:ts=2:sw=2:et
12 changes: 10 additions & 2 deletions doc/ag.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down