I am using ag with ctrlp as suggested here :
if executable('ag') set grepprg=ag\ --nogroup\ --nocolor let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' let g:ctrlp_use_caching = 0 else let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'] endif
This works fine if I run vim from a project folder with a .git folder inside it. However, I get an empty list of files (with no results) when I start Vim from a directory that is not the root of the git project. To clarify, with the following folder hierarchy:
Proj1/
The actual command ag ag %s -l --nocolor -g "" works fine when I run it from the command line in the same directory (it finds all the files).
Here is all my ctrlp config:
map <cp> :CtrlP<cr> map <ct> :CtrlPTag<cr> let g:ctrlp_dotfiles = 1 let g:ctrlp_show_hidden = 1 let g:ctrlp_cmd = 'CtrlPMixed' " search anything (in files, buffers and MRU files at the same time.) let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_working_path_mode = 'ra' " search for nearest ancestor like .git, .hg, and the directory of the current file let g:ctrlp_match_window = 'top,order:ttb' let g:ctrlp_max_height = 12 " maxiumum height of match window let g:ctrlp_switch_buffer = 'et' " jump to a file if it open already let g:ctrlp_use_caching = 1 " enable caching let g:ctrlp_clear_cache_on_exit = 0 " speed up by not removing clearing cache evertime let g:ctrlp_mruf_max = 250 " number of recently opened files if exists('g:ctrlp_user_command') unlet g:ctrlp_user_command end if exists('g:ctrlp_custom_ignore') unlet g:ctrlp_custom_ignore end if executable('ag') set grepprg=ag\ --nogroup\ --nocolor let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'" let g:ctrlp_use_caching = 0 else let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'] endif let g:ctrlp_prompt_mappings = { \ 'AcceptSelection("e")': ['<ct>'], \ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'], \ 'ToggleType(1)': ['<cu>', '<c-up>'], \ 'ToggleType(-1)': ['<cy>', '<c-down>'], \ 'PrtExit()': ['<cl>', '<esc>', '<cc>', '<cg>'], \ 'PrtSelectMove("j")': ['<cn>', '<down>'], \ 'PrtSelectMove("k")': ['<cp>', '<up>'], \ 'PrtHistory(-1)': ['<cj>'], \ 'PrtHistory(1)': ['<ck>'], \ } let g:ctrlp_buftag_types = { \ 'coffee' : '--language-force=coffee --coffee-types=cmfvf' \ }
How can I get ctrlp/ag to work correctly outside of git repo?
git vim ag ctrlp
Sasgorilla
source share