gabesoft / vim-ags

Silver searcher plugin for vim
183 stars 12 forks source link

Problems getting search to follow symlinks #15

Closed raddevon closed 9 years ago

raddevon commented 9 years ago

I'm searching in a folder full of symlinks and getting no results for patterns I know are present. I've tried enabling symlink following in a couple of ways. In my config file, I added this: let g:ags_agargs['--follow'] = ['',''], but I get an Undefined variable error. I've also tried adding the option in the command (:Ags --follow pattern, but that also fails to produce results (No matches for '--follow pattern').

I can run the search for the same pattern specifying the location of the source file and get results, so it definitely seems the symlink is not being followed.

gabesoft commented 9 years ago

After running :Ags --follow pattern try running :AgsShowLastCommand to see the actual ag command that was run. Then try that in a terminal and see what results you get. If the results are different that would be a bug.

raddevon commented 9 years ago

This was not the problem I thought. I was searching in my dotfiles. All the files were being ignored by Ag by default since they were hidden files. Got that fixed. Thank you for the debugging tip.

Can you address how to add new default args? I would like hidden files to be searched by default, so I will need to add --hidden to the default arguments for the search. How can I do this since let g:ags_agargs['--hidden'] = ['',''] causes vim to complain?

gabesoft commented 9 years ago

You'd have to define g:ags_agargs in your vimrc. Something like below

let g:ags_agargs = {
            \ '--break'             : [ '', '' ],
            \ '--color'             : [ '', '' ],
            \ '--hidden'            : [ '', '' ],
            \ '--color-line-number' : [ '"1;30"', '' ],
            \ '--color-match'       : [ '"32;40"', '' ],
            \ '--color-path'        : [ '"1;31"', '' ],
            \ '--column'            : [ '', '' ],
            \ '--context'           : [ 'g:ags_agcontext', '-C' ],
            \ '--filename'          : [ '', '' ],
            \ '--group'             : [ '', '' ],
            \ '--heading'           : [ '', '-H' ],
            \ '--max-count'         : [ 'g:ags_agmaxcount', '-m' ],
            \ '--numbers'           : [ '', '' ]
            \ }

Or you may be able to do it the way you had it but put it in a place that runs after the plugins are loaded. For example with pathogen you'd put it in an after directory.

raddevon commented 9 years ago

Awesome. Thank you so much for the help!