From 24d3b94d611a3087a5c98deae4ff8773b8302d7c Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Sat, 15 Feb 2014 21:50:57 -0500 Subject: [PATCH 1/6] Added more options - There are now a few options that you can specify - current_file_ext -- limits the search to files that have the current buffer's file's extension only - current_file_dir -- limits the search to files that are in the current buffer's file's directory - scmdir -- starts the search at the "root" of a source directory, based on the existence of a .git, .scm or .hg dir - specific_dirs -- limits the search to these directories - You can also customize the quickfix mappings - Each mapping is customizable using a dictionary --- autoload/ag.vim | 153 ++++++++++++++++++++++++++++++++++++++---------- doc/ag.txt | 75 ++++++++++++++++++++++++ plugin/ag.vim | 2 + 3 files changed, 200 insertions(+), 30 deletions(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index 630736cb..c9186ec6 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -25,13 +25,101 @@ if !exists("g:ag_mapping_message") let g:ag_mapping_message=1 endif -function! ag#Ag(cmd, args) +if !exists("g:ag_scm_dirs") + let g:ag_scm_dirs = [ '.git', '.svn', '.hg' ] +endif + +if !exists("g:ag_results_mapping") + let g:ag_results_mapping = {} +endif + +if !has_key(g:ag_results_mapping, 'open_and_close') + let g:ag_results_mapping['open_and_close'] = 'e' +endif + +if !has_key(g:ag_results_mapping, 'open') + let g:ag_results_mapping['open'] = 'o,' +endif + +if !has_key(g:ag_results_mapping, 'preview_open') + let g:ag_results_mapping['preview_open'] = 'go' +endif + +if !has_key(g:ag_results_mapping, 'new_tab') + let g:ag_results_mapping['new_tab'] = 't' +endif + +if !has_key(g:ag_results_mapping, 'new_tab_silent') + let g:ag_results_mapping['new_tab_silent'] = 'T' +endif + +if !has_key(g:ag_results_mapping, 'horizontal_split') + let g:ag_results_mapping['horizontal_split'] = 'h' +endif + +if !has_key(g:ag_results_mapping, 'horizontal_split_silent') + let g:ag_results_mapping['horizontal_split_silent'] = 'H' +endif + +if !has_key(g:ag_results_mapping, 'vertical_split') + let g:ag_results_mapping['vertical_split'] = 'v' +endif + +if !has_key(g:ag_results_mapping, 'vertical_split_silent') + let g:ag_results_mapping['vertical_split_silent'] = 'gv' +endif + +if !has_key(g:ag_results_mapping, 'quit') + let g:ag_results_mapping['quit'] = 'q' +endif + +function! ag#FindSCMDir() + let filedir = expand('%:p:h') + for candidate in g:ag_scm_dirs + let dir = finddir(candidate, filedir . ';') + if dir != "" + let dir = substitute(dir, '/' . candidate, '', '') + return dir + endif + endfor + return "~" +endfunction + +function! ag#ApplyMapping(dictkey, mapping) + for key in split(g:ag_results_mapping[a:dictkey], ',') + exe "nnoremap " . key . " " . a:mapping + endfor +endfunction + +function! ag#Ag(cmd, args, opts) + let l:ag_args = "" + + if empty(a:opts) + let a:opts = {} + endif + + " Handle the types of files to search + if has_key(a:opts, 'current_file_ext') + let l:ag_args = l:ag_args . " -G'\\." . expand('%:e') . "$'" + endif + " If no pattern is provided, search for the word under the cursor - if empty(a:args) - let l:grepargs = expand("") - else - let l:grepargs = a:args . join(a:000, ' ') - end + let l:pat = expand('') + if !empty(a:args) + let l:pat = a:args + let l:pat = substitute(l:pat, '\%(\\<\|\\>\)', '\\b', 'g') + let l:pat = substitute(l:pat, '\\', '\\\\', 'g') + endif + let l:ag_args = l:ag_args . ' ' . l:pat + + " If they want to search from the 'scm' directory + if has_key(a:opts, 'scmdir') + let l:ag_args = l:ag_args . ' ' . ag#FindSCMDir() + elseif has_key(a:opts, 'current_file_dir') + let l:ag_args = l:ag_args . ' ' . expand('%:p:h') + elseif has_key(a:opts, 'specific_dirs') + let l:ag_args = l:ag_args . ' ' . a:opts['specific_dirs'] + endif " Format, used to manage column jump if a:cmd =~# '-g$' @@ -45,7 +133,7 @@ function! ag#Ag(cmd, args) try let &grepprg=g:agprg let &grepformat=g:agformat - silent execute a:cmd . " " . escape(l:grepargs, '|') + silent execute a:cmd . " " . escape(l:ag_args, "|") finally let &grepprg=grepprg_bak let &grepformat=grepformat_bak @@ -69,7 +157,7 @@ function! ag#Ag(cmd, args) " If highlighting is on, highlight the search keyword. if exists("g:aghighlight") - let @/=a:args + let @/ = l:pat set hlsearch end @@ -77,18 +165,18 @@ function! ag#Ag(cmd, args) if l:match_count if l:apply_mappings - nnoremap h K - nnoremap H Kb - nnoremap o - nnoremap t T - nnoremap T TgT - nnoremap v HbJt - - exe 'nnoremap e :' . l:matches_window_prefix .'close' - exe 'nnoremap go :' . l:matches_window_prefix . 'open' - exe 'nnoremap q :' . l:matches_window_prefix . 'close' - - exe 'nnoremap gv :let b:height=winheight(0)H:' . l:matches_window_prefix . 'openJ:exe printf(":normal %d\c-w>_", b:height)' + call ag#ApplyMapping('horizontal_split', 'K') + call ag#ApplyMapping('horizontal_split_silent', 'Kb') + call ag#ApplyMapping('open', '') + call ag#ApplyMapping('new_tab', 'T') + call ag#ApplyMapping('new_tab_silent', 'TgT') + call ag#ApplyMapping('vertical_split', 'HbJt') + + call ag#ApplyMapping('open_and_close', ':' . l:matches_window_prefix . 'close') + call ag#ApplyMapping('preview_open', ':' . l:matches_window_prefix . 'open') + call ag#ApplyMapping('quit', ':' . l:matches_window_prefix . 'close') + + call ag#ApplyMapping('vertial_split_silent', ':let b:height=winheight(0)H:' . l:matches_window_prefix . 'openJ:exe printf(":normal %d\c-w>_", b:height)') " Interpretation: " :let b:height=winheight(0) Get the height of the quickfix/location list window " Open the current item in a new split @@ -98,19 +186,25 @@ function! ag#Ag(cmd, args) " :exe printf(":normal %d\c-w>_", b:height) Restore the quickfix/location list window's height from before we opened the match if g:ag_mapping_message && l:apply_mappings - echom "ag.vim keys: q=quit /e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same" + echom "ag.vim keys: " . g:ag_results_mapping['quit'] . "=quit " . + \ g:ag_results_mapping['open'] . '/' . + \ g:ag_results_mapping['open_and_close'] . '/' . + \ g:ag_results_mapping['new_tab'] . '/' . + \ g:ag_results_mapping['horizontal_split'] . '/' . + \ g:ag_results_mapping['vertical_split'] . "=enter/edit/tab/split/vsplit " . + \ g:ag_results_mapping['preview_open'] . '/' . + \ g:ag_results_mapping['horizontal_split_silent'] . '/' . + \ g:ag_results_mapping['vertical_split_silent'] . "=preview versions of same" endif endif else - echom 'No matches for "'.a:args.'"' + echom 'No matches for "' . l:pat . '"' endif endfunction -function! ag#AgFromSearch(cmd, args) - let search = getreg('/') - " translate vim regular expression to perl regular expression. - let search = substitute(search,'\(\\<\|\\>\)','\\b','g') - call ag#Ag(a:cmd, '"' . search .'" '. a:args) +function! ag#AgFromSearch(cmd, opts) + let search = getreg('/') + call ag#Ag(a:cmd, search, a:opts) endfunction function! ag#GetDocLocations() @@ -124,7 +218,6 @@ function! ag#GetDocLocations() return dp endfunction -function! ag#AgHelp(cmd,args) - let args = a:args.' '.ag#GetDocLocations() - call ag#Ag(a:cmd,args) +function! ag#AgHelp(cmd, args) + call ag#Ag(a:cmd, a:args, {'specific_dirs': ag#GetDocLocations()}) endfunction diff --git a/doc/ag.txt b/doc/ag.txt index 37b107b7..47716d68 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -49,6 +49,17 @@ shows the results in a split window. Just like |:AgHelp| but instead of the |quickfix| list, matches are placed in the current |location-list|. +:AgForCurrentFileDir [options] {pattern} *:AgForCurrentFileDir* + + Uses the 'current_file_dir' option to ensure that we limit the search to + the directory of the current buffer's file + +:AgForProjectRoot [options] {pattern} *:AgForProjectRoot* + + The notion of a "project" is the directory subtree that starts at the root + of a source control managed directory. This is currently defined with + 'g:ag_scm_dirs' variable. + Files containing the search term will be listed in the split window, along with the line number of the occurrence, once for each occurrence. on a line in this window will open the file, and place the cursor on the matching @@ -113,6 +124,45 @@ the mappings are not applied (see |g:ag_apply_qmappings| and |g:ag_apply_lmappings| for more info. Default 1. Example: > let g:ag_mapping_message=0 < + *g:ag_scm_dirs* +This is a list containing the directories that should be treated as source +control management directories. It's what allows this plugin to limit the +searches to subtrees of entire source directories. + +============================================================================== +THE AG FUNCTION *ag-function* + +The ag#Ag() function has some special configuration options that you might be +interested in. The permutations are annoying so pre-canning all of those +permutations hasn't been done. The function looks like > + + ag#Ag(command, arguments, options) +< +The first two should always look something like: > + + ag#Ag('grep', , ...) +< +But the "options" argument is a dictionary. You can put the following into +the dictionary: +> + 'current_file_ext': 1 +< + Limits the search to the current buffer's file's extension (e.g. ".vim") +> + 'current_file_dir': 1 +< + Limits the search to the current buffer's file's directory. +> + 'scmdir': 1 +< + Limits the search to the "project" root subtree. This will search up the + directory tree for the first of the elements in the g:ag_scm_dirs list and + use that containing directoy as the directory argument to ag. +> + 'specific_dirs': 'directory1 directory2 and so forth' +< + Limits the search to the specific directories given in this string + ============================================================================== MAPPINGS *ag-mappings* @@ -139,4 +189,29 @@ gv open in vertical split silently. q close the quickfix window. + *g:ag_results_mapping* +You can customize all of the mappings using the g:ag_results_mapping +dictionary. The default values for the dictionary are: > + + { + 'open_and_close': 'e' + 'open': 'o,' + 'preview_open': 'go' + 'new_tab': 't' + 'new_tab_silent': 'T' + 'horizontal_split': 'h' + 'horizontal_split_silent': 'H' + 'vertical_split': 'v' + 'vertical_split_silent': 'gv' + 'quit': 'q' + } +< +Personally, I prefer that closes the quickfix window, so I've customized +these as: > + + let g:ag_results_mapping = { + \ 'open_and_close': '', + \ 'open': 'o', + \ } +< vim:tw=78:fo=tcq2:ft=help:norl: diff --git a/plugin/ag.vim b/plugin/ag.vim index eb5bc224..5bcd49de 100644 --- a/plugin/ag.vim +++ b/plugin/ag.vim @@ -7,3 +7,5 @@ command! -bang -nargs=* -complete=file LAgAdd call ag#Ag('lgrepadd', -g', ) command! -bang -nargs=* -complete=help AgHelp call ag#AgHelp('grep',) command! -bang -nargs=* -complete=help LAgHelp call ag#AgHelp('lgrep',) +command! -bang -nargs=* -complete=file AgForCurrentFileDir call ag#Ag('grep', , {'current_file_dir': 1}) +command! -bang -nargs=* -complete=file AgForProjectRoot call ag#Ag('grep', , {'current_file_ext': 1, 'scmdir': 1}) From 6581f94ac0329c5dbfc87c420c8394c353d62352 Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Mon, 24 Feb 2014 08:50:01 -0500 Subject: [PATCH 2/6] Referencing 'vertial' when it should be 'vertical' --- autoload/ag.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index c9186ec6..0579600d 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -176,7 +176,7 @@ function! ag#Ag(cmd, args, opts) call ag#ApplyMapping('preview_open', ':' . l:matches_window_prefix . 'open') call ag#ApplyMapping('quit', ':' . l:matches_window_prefix . 'close') - call ag#ApplyMapping('vertial_split_silent', ':let b:height=winheight(0)H:' . l:matches_window_prefix . 'openJ:exe printf(":normal %d\c-w>_", b:height)') + call ag#ApplyMapping('vertical_split_silent', ':let b:height=winheight(0)H:' . l:matches_window_prefix . 'openJ:exe printf(":normal %d\c-w>_", b:height)') " Interpretation: " :let b:height=winheight(0) Get the height of the quickfix/location list window " Open the current item in a new split From d8fc2afc2a4a394ceeebc0f3d5aa7e9c4859d5c4 Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Mon, 24 Feb 2014 09:50:31 -0500 Subject: [PATCH 3/6] 'scmdir' feature bug fix - If the current file's directory is the same as the one containing the scm directory, then we fail to return '.' --- autoload/ag.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index 0579600d..8f0b7cf8 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -77,7 +77,9 @@ function! ag#FindSCMDir() let filedir = expand('%:p:h') for candidate in g:ag_scm_dirs let dir = finddir(candidate, filedir . ';') - if dir != "" + if dir == candidate + return '.' + elseif dir != "" let dir = substitute(dir, '/' . candidate, '', '') return dir endif From df646e69eb65c0af6217fbf60129128570d79b8a Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Mon, 24 Feb 2014 10:39:49 -0500 Subject: [PATCH 4/6] Added AgForExtension to allow specific file exts - See the doc file --- autoload/ag.vim | 19 ++++++++++++++++++- doc/ag.txt | 16 ++++++++++++++-- plugin/ag.vim | 1 + 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index 8f0b7cf8..f3a0b83e 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -93,6 +93,20 @@ function! ag#ApplyMapping(dictkey, mapping) endfor endfunction +function! ag#AgForExtension(cmd, opts, regex, ...) + let exts = [] + " map() is just too much of a pain in the ass + for e in a:000 + call add(exts, substitute(e, '^\.\=\(.*\)', '\\.\1$', '')) + endfor + if empty(exts) + echoerr "No extensions provided." + else + let extRegex = join(exts, '|') + call ag#Ag(a:cmd, a:regex, extend(a:opts, {'specific_file_exts': extRegex})) + endif +endfunction + function! ag#Ag(cmd, args, opts) let l:ag_args = "" @@ -103,6 +117,8 @@ function! ag#Ag(cmd, args, opts) " Handle the types of files to search if has_key(a:opts, 'current_file_ext') let l:ag_args = l:ag_args . " -G'\\." . expand('%:e') . "$'" + elseif has_key(a:opts, 'specific_file_exts') + let l:ag_args = l:ag_args . " -G'" . a:opts['specific_file_exts'] . "'" endif " If no pattern is provided, search for the word under the cursor @@ -135,7 +151,8 @@ function! ag#Ag(cmd, args, opts) try let &grepprg=g:agprg let &grepformat=g:agformat - silent execute a:cmd . " " . escape(l:ag_args, "|") + let toExecute = a:cmd . " " . escape(l:ag_args, "|") + silent execute toExecute finally let &grepprg=grepprg_bak let &grepformat=grepformat_bak diff --git a/doc/ag.txt b/doc/ag.txt index 47716d68..d86c6d1a 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -49,17 +49,29 @@ shows the results in a split window. Just like |:AgHelp| but instead of the |quickfix| list, matches are placed in the current |location-list|. -:AgForCurrentFileDir [options] {pattern} *:AgForCurrentFileDir* +:AgForCurrentFileDir [options] {pattern} *:AgForCurrentFileDir* Uses the 'current_file_dir' option to ensure that we limit the search to the directory of the current buffer's file -:AgForProjectRoot [options] {pattern} *:AgForProjectRoot* +:AgForProjectRoot [options] {pattern} *:AgForProjectRoot* The notion of a "project" is the directory subtree that starts at the root of a source control managed directory. This is currently defined with 'g:ag_scm_dirs' variable. +:AgForExtension [options] {pattern} *:AgForExtension* + + This command exists to let you specify a number of specific file extensions. + It implies the "scmdir" option so if you don't want that you'll have to + create a new command on your own (or override this one). Call it like + this: > + + AgForExtension 'search for me' .js .java .txt +< + This will search for 'search for me' in {js}, {java} and {txt} files. The + leading "." on all of the extensions is optional. + Files containing the search term will be listed in the split window, along with the line number of the occurrence, once for each occurrence. on a line in this window will open the file, and place the cursor on the matching diff --git a/plugin/ag.vim b/plugin/ag.vim index 5bcd49de..04f6adc3 100644 --- a/plugin/ag.vim +++ b/plugin/ag.vim @@ -9,3 +9,4 @@ command! -bang -nargs=* -complete=help AgHelp call ag#AgHelp('grep',',) command! -bang -nargs=* -complete=file AgForCurrentFileDir call ag#Ag('grep', , {'current_file_dir': 1}) command! -bang -nargs=* -complete=file AgForProjectRoot call ag#Ag('grep', , {'current_file_ext': 1, 'scmdir': 1}) +command! -bang -nargs=+ -complete=file AgForExtension call ag#AgForExtension('grep', {'scmdir': 1}, ) From 619ad562fd39415db39b3069486679e611cbbcd1 Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Tue, 25 Feb 2014 07:58:18 -0500 Subject: [PATCH 5/6] Fixes based on review --- autoload/ag.vim | 102 ++++++++++++++++++------------------------------ plugin/ag.vim | 10 ++--- 2 files changed, 44 insertions(+), 68 deletions(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index f3a0b83e..40390987 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -29,48 +29,21 @@ if !exists("g:ag_scm_dirs") let g:ag_scm_dirs = [ '.git', '.svn', '.hg' ] endif -if !exists("g:ag_results_mapping") - let g:ag_results_mapping = {} -endif - -if !has_key(g:ag_results_mapping, 'open_and_close') - let g:ag_results_mapping['open_and_close'] = 'e' -endif - -if !has_key(g:ag_results_mapping, 'open') - let g:ag_results_mapping['open'] = 'o,' -endif - -if !has_key(g:ag_results_mapping, 'preview_open') - let g:ag_results_mapping['preview_open'] = 'go' -endif - -if !has_key(g:ag_results_mapping, 'new_tab') - let g:ag_results_mapping['new_tab'] = 't' -endif - -if !has_key(g:ag_results_mapping, 'new_tab_silent') - let g:ag_results_mapping['new_tab_silent'] = 'T' -endif - -if !has_key(g:ag_results_mapping, 'horizontal_split') - let g:ag_results_mapping['horizontal_split'] = 'h' -endif - -if !has_key(g:ag_results_mapping, 'horizontal_split_silent') - let g:ag_results_mapping['horizontal_split_silent'] = 'H' -endif - -if !has_key(g:ag_results_mapping, 'vertical_split') - let g:ag_results_mapping['vertical_split'] = 'v' -endif - -if !has_key(g:ag_results_mapping, 'vertical_split_silent') - let g:ag_results_mapping['vertical_split_silent'] = 'gv' -endif - -if !has_key(g:ag_results_mapping, 'quit') - let g:ag_results_mapping['quit'] = 'q' +let s:ag_results_mapping = { + \ 'open_and_close' : 'e', + \ 'open' : 'o,', + \ 'preview_open' : 'go', + \ 'new_tab' : 't', + \ 'new_tab_silent' : 'T', + \ 'horizontal_split' : 'h', + \ 'horizontal_split_silent' : 'H', + \ 'vertical_split' : 'v', + \ 'vertical_split_silent' : 'gv', + \ 'quit' : 'q' + \ } + +if exists("g:ag_results_mapping_replacements") + call extend(s:ag_results_mapping, g:ag_results_mapping_replacements, 'force') endif function! ag#FindSCMDir() @@ -88,7 +61,7 @@ function! ag#FindSCMDir() endfunction function! ag#ApplyMapping(dictkey, mapping) - for key in split(g:ag_results_mapping[a:dictkey], ',') + for key in split(s:ag_results_mapping[a:dictkey], ',') exe "nnoremap " . key . " " . a:mapping endfor endfunction @@ -103,22 +76,25 @@ function! ag#AgForExtension(cmd, opts, regex, ...) echoerr "No extensions provided." else let extRegex = join(exts, '|') - call ag#Ag(a:cmd, a:regex, extend(a:opts, {'specific_file_exts': extRegex})) + let l:opts = a:opts + call ag#Ag(a:cmd, a:regex, extend(l:opts, {'specific_file_exts': extRegex})) endif endfunction +function! ag#AgFrontend(cmd, args) + call ag#Ag(a:cmd, a:args, {}) +endfunction + function! ag#Ag(cmd, args, opts) let l:ag_args = "" - if empty(a:opts) - let a:opts = {} - endif + let l:opts = a:opts " Handle the types of files to search - if has_key(a:opts, 'current_file_ext') + if has_key(l:opts, 'current_file_ext') let l:ag_args = l:ag_args . " -G'\\." . expand('%:e') . "$'" - elseif has_key(a:opts, 'specific_file_exts') - let l:ag_args = l:ag_args . " -G'" . a:opts['specific_file_exts'] . "'" + elseif has_key(l:opts, 'specific_file_exts') + let l:ag_args = l:ag_args . " -G'" . l:opts['specific_file_exts'] . "'" endif " If no pattern is provided, search for the word under the cursor @@ -131,12 +107,12 @@ function! ag#Ag(cmd, args, opts) let l:ag_args = l:ag_args . ' ' . l:pat " If they want to search from the 'scm' directory - if has_key(a:opts, 'scmdir') + if has_key(l:opts, 'scmdir') let l:ag_args = l:ag_args . ' ' . ag#FindSCMDir() - elseif has_key(a:opts, 'current_file_dir') + elseif has_key(l:opts, 'current_file_dir') let l:ag_args = l:ag_args . ' ' . expand('%:p:h') - elseif has_key(a:opts, 'specific_dirs') - let l:ag_args = l:ag_args . ' ' . a:opts['specific_dirs'] + elseif has_key(l:opts, 'specific_dirs') + let l:ag_args = l:ag_args . ' ' . l:opts['specific_dirs'] endif " Format, used to manage column jump @@ -205,15 +181,15 @@ function! ag#Ag(cmd, args, opts) " :exe printf(":normal %d\c-w>_", b:height) Restore the quickfix/location list window's height from before we opened the match if g:ag_mapping_message && l:apply_mappings - echom "ag.vim keys: " . g:ag_results_mapping['quit'] . "=quit " . - \ g:ag_results_mapping['open'] . '/' . - \ g:ag_results_mapping['open_and_close'] . '/' . - \ g:ag_results_mapping['new_tab'] . '/' . - \ g:ag_results_mapping['horizontal_split'] . '/' . - \ g:ag_results_mapping['vertical_split'] . "=enter/edit/tab/split/vsplit " . - \ g:ag_results_mapping['preview_open'] . '/' . - \ g:ag_results_mapping['horizontal_split_silent'] . '/' . - \ g:ag_results_mapping['vertical_split_silent'] . "=preview versions of same" + echom "ag.vim keys: " . s:ag_results_mapping['quit'] . "=quit " . + \ s:ag_results_mapping['open'] . '/' . + \ s:ag_results_mapping['open_and_close'] . '/' . + \ s:ag_results_mapping['new_tab'] . '/' . + \ s:ag_results_mapping['horizontal_split'] . '/' . + \ s:ag_results_mapping['vertical_split'] . "=enter/edit/tab/split/vsplit " . + \ s:ag_results_mapping['preview_open'] . '/' . + \ s:ag_results_mapping['horizontal_split_silent'] . '/' . + \ s:ag_results_mapping['vertical_split_silent'] . "=preview versions of same" endif endif else diff --git a/plugin/ag.vim b/plugin/ag.vim index 04f6adc3..817b7a5f 100644 --- a/plugin/ag.vim +++ b/plugin/ag.vim @@ -1,10 +1,10 @@ " NOTE: You must, of course, install ag / the_silver_searcher -command! -bang -nargs=* -complete=file Ag call ag#Ag('grep',) -command! -bang -nargs=* -complete=file AgAdd call ag#Ag('grepadd', ) +command! -bang -nargs=* -complete=file Ag call ag#Ag('grep',, {}) +command! -bang -nargs=* -complete=file AgAdd call ag#Ag('grepadd', , {}) command! -bang -nargs=* -complete=file AgFromSearch call ag#AgFromSearch('grep', ) -command! -bang -nargs=* -complete=file LAg call ag#Ag('lgrep', ) -command! -bang -nargs=* -complete=file LAgAdd call ag#Ag('lgrepadd', ) -command! -bang -nargs=* -complete=file AgFile call ag#Ag('grep -g', ) +command! -bang -nargs=* -complete=file LAg call ag#Ag('lgrep', , {}) +command! -bang -nargs=* -complete=file LAgAdd call ag#Ag('lgrepadd', , {}) +command! -bang -nargs=* -complete=file AgFile call ag#Ag('grep -g', , {}) command! -bang -nargs=* -complete=help AgHelp call ag#AgHelp('grep',) command! -bang -nargs=* -complete=help LAgHelp call ag#AgHelp('lgrep',) command! -bang -nargs=* -complete=file AgForCurrentFileDir call ag#Ag('grep', , {'current_file_dir': 1}) From aa917105699973c04890210d48add2705c526edc Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Tue, 25 Feb 2014 08:01:24 -0500 Subject: [PATCH 6/6] Needed to update the doc to match the code change --- doc/ag.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ag.txt b/doc/ag.txt index d86c6d1a..368f2aaf 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -201,9 +201,10 @@ gv open in vertical split silently. q close the quickfix window. - *g:ag_results_mapping* -You can customize all of the mappings using the g:ag_results_mapping -dictionary. The default values for the dictionary are: > + *g:ag_results_mapping_replacements* +You can customize all of the mappings using the +g:ag_results_mapping_replacements dictionary. The default values for the +dictionary are: > { 'open_and_close': 'e' @@ -221,7 +222,7 @@ dictionary. The default values for the dictionary are: > Personally, I prefer that closes the quickfix window, so I've customized these as: > - let g:ag_results_mapping = { + let g:ag_results_mapping_replacements = { \ 'open_and_close': '', \ 'open': 'o', \ }