From 4c54fbe2e27fa433129107e62461c2365d245d92 Mon Sep 17 00:00:00 2001 From: Josh Hoff Date: Sat, 20 Dec 2014 17:27:38 -0600 Subject: [PATCH 1/3] Ignore things set in 'wildignore' This is on by default (which will change the default behavior for users, but I think it's a good default). There might be patterns that need to be escaped, but I haven't had an issue with mine yet. --- autoload/ag.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/autoload/ag.vim b/autoload/ag.vim index 86cbe95f..fdd63b2c 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -25,6 +25,10 @@ if !exists("g:ag_mapping_message") let g:ag_mapping_message=1 endif +if !exists("g:ag_use_wildignore") + let g:ag_use_wildignore=1 +endif + function! ag#Ag(cmd, args) let l:ag_executable = get(split(g:agprg, " "), 0) @@ -41,6 +45,11 @@ function! ag#Ag(cmd, args) let l:grepargs = a:args . join(a:000, ' ') end + " Possibly add --ignore flags for patterns set in the 'wildignore' option + if g:ag_use_wildignore + let g:agprg = ag#AddWildignoreToAgCommand(g:agprg) + endif + " Format, used to manage column jump if a:cmd =~# '-g$' let s:agformat_backup=g:agformat @@ -123,6 +132,16 @@ function! ag#Ag(cmd, args) endif endfunction +function! ag#AddWildignoreToAgCommand(cli_arguments) + let l:new_arguments = copy(a:cli_arguments) + + for ignore_me in split(&wildignore, ",") + let l:new_arguments = printf("%s --ignore \"%s\"", l:new_arguments, l:ignore_me) + endfor + + return l:new_arguments +endfunction + function! ag#AgFromSearch(cmd, args) let search = getreg('/') " translate vim regular expression to perl regular expression. From 45fee3cc4c26082dc837351d3382848f57facf9c Mon Sep 17 00:00:00 2001 From: Josh Hoff Date: Sat, 20 Dec 2014 17:35:43 -0600 Subject: [PATCH 2/3] Remove extra space after sentences --- doc/ag.txt | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/ag.txt b/doc/ag.txt index 37b107b7..d6dd3d5d 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -3,14 +3,14 @@ ============================================================================== INTRODUCTION *ag* -This plugin is a front for the_silver_searcher: ag. Ag can be used as a -replacement for ack. This plugin will allow you to run ag from vim, and -shows the results in a split window. +This plugin is a front for the_silver_searcher: ag. Ag can be used as a +replacement for ack. This plugin will allow you to run ag from vim, and shows +the results in a split window. :Ag[!] [options] {pattern} [{directory}] *:Ag* Search recursively in {directory} (which defaults to the current - directory) for the {pattern}. Behaves just like the |:grep| command, but + directory) for the {pattern}. Behaves just like the |:grep| command, but will open the |Quickfix| window for you. If [!] is not given the first error is jumped to. @@ -36,12 +36,12 @@ shows the results in a split window. :AgFile [options] {pattern} [{directory}] *:AgFile* Search recursively in {directory} (which defaults to the current - directory) for filenames matching the {pattern}. Behaves just like the + directory) for filenames matching the {pattern}. Behaves just like the |:grep| command, but will open the |Quickfix| window for you. :AgHelp[!] [options] {pattern} *:AgHelp* - Search vim documentation files for the {pattern}. Behaves just like the + Search vim documentation files for the {pattern}. Behaves just like the |:Ag| command, but searches only vim documentation .txt files :LAgHelp [options] {pattern} *:LAgHelp* @@ -50,8 +50,8 @@ shows the results in a split window. in the current |location-list|. 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 +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 line. See http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-than-ack/ for @@ -62,18 +62,18 @@ OPTIONS *ag-options* *g:agprg* The location of the Ag program, and any options you want passed to it before -searching. Default: "ag --column". Example: > +searching. Default: "ag --column". Example: > let g:agprg="ag --column --smart-case" < *g:aghighlight* -If 1, highlight the search terms after searching. Default: 0. Example: > +If 1, highlight the search terms after searching. Default: 0. Example: > let g:aghighlight=1 < *g:agformat* -Format to recognize the matches. See 'errorformat' for more info. Default: -"%f" when searching for files, "%f:%l:%c:%m" if not otherwise set. For +Format to recognize the matches. See 'errorformat' for more info. Default: +"%f" when searching for files, "%f:%l:%c:%m" if not otherwise set. For example, if your `g:agprg` is set to just "ag" (no column numbers in the output, so when you jump to a match your cursor will be on the start of the line): > @@ -82,35 +82,35 @@ line): > *g:ag_apply_lmappings* Whether or not to add custom mappings to location list windows opened by this -plugin. Only applies if you're using the location list. Default 1. Example: > +plugin. Only applies if you're using the location list. Default 1. Example: > let g:ag_apply_lmappings=0 < *g:ag_apply_qmappings* Whether or not to add custom mappings to quickfix windows opened by this -plugin. Only applies if you're using the error list. Default 1. Example: > +plugin. Only applies if you're using the error list. Default 1. Example: > let g:ag_apply_qmappings=0 < *g:ag_lhandler* A custom command used to open the location list after it's populated. -Default: "botright lopen". You might want to set this to change where the -location list is opened, or what size it is. Example: > +Default: "botright lopen". You might want to set this to change where the +location list is opened, or what size it is. Example: > let g:ag_lhandler="topleft lopen" < *g:ag_qhandler* -A custom command used to open the error list after it's populated. Default: -"botright copen". You might want to set this to change where the quickfix -window is opened, or what size it is. Example: > +A custom command used to open the error list after it's populated. Default: +"botright copen". You might want to set this to change where the quickfix +window is opened, or what size it is. Example: > let g:ag_qhandler="copen 20" < *g:ag_mapping_message* Whether or not to show the message explaining the extra mappings that are -added to the results list this plugin populates. This message is not shown if +added to the results list this plugin populates. This message is not shown if the mappings are not applied (see |g:ag_apply_qmappings| and -|g:ag_apply_lmappings| for more info. Default 1. Example: > +|g:ag_apply_lmappings| for more info. Default 1. Example: > let g:ag_mapping_message=0 < From d85c514c51c4d4c10d7878cfb43d347817956a79 Mon Sep 17 00:00:00 2001 From: Josh Hoff Date: Sat, 20 Dec 2014 17:35:53 -0600 Subject: [PATCH 3/3] Document g:ag_use_wildignore --- doc/ag.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ag.txt b/doc/ag.txt index d6dd3d5d..7d23f9da 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -113,6 +113,11 @@ 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_use_wildignore* +Whether or not to ignore patterns specified in the 'wildignore' option. +Default 1. Example: > + let g:ag_use_wildignore=0 +< ============================================================================== MAPPINGS *ag-mappings*