mirror of
https://github.com/amix/vimrc
synced 2025-06-30 11:54:59 +08:00
lets try again...
This commit is contained in:
1
sources_non_forked/ack.vim/.gitignore
vendored
Normal file
1
sources_non_forked/ack.vim/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
tags
|
96
sources_non_forked/ack.vim/README.md
Normal file
96
sources_non_forked/ack.vim/README.md
Normal file
@ -0,0 +1,96 @@
|
||||
# ack.vim #
|
||||
|
||||
This plugin is a front for the Perl module
|
||||
[App::Ack](http://search.cpan.org/~petdance/ack/ack). Ack can be used as a
|
||||
replacement for 99% of the uses of _grep_. This plugin will allow you to run
|
||||
ack from vim, and shows the results in a split window.
|
||||
|
||||
The *Official Version* of this plugin is available at [vim.org](http://www.vim.org/scripts/script.php?script_id=2572).
|
||||
|
||||
## Installation ##
|
||||
|
||||
|
||||
### Ack
|
||||
|
||||
You have to install [ack](http://betterthangrep.com/), of course.
|
||||
|
||||
Install on Debian / Ubuntu with:
|
||||
|
||||
sudo apt-get install ack-grep
|
||||
|
||||
For Debian / Ubuntu you can add this line into your .vimrc:
|
||||
|
||||
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
|
||||
Install on Gentoo with:
|
||||
|
||||
sudo emerge ack
|
||||
|
||||
Install with Homebrew:
|
||||
|
||||
brew install ack
|
||||
|
||||
Install with MacPorts:
|
||||
|
||||
sudo port install p5-app-ack
|
||||
|
||||
Install with Gentoo Prefix
|
||||
|
||||
emerge ack
|
||||
|
||||
Otherwise, you are on your own.
|
||||
|
||||
### The Plugin
|
||||
|
||||
If you have [Rake](http://rake.rubyforge.org/) installed, you can just run: `rake install`.
|
||||
|
||||
Otherwise, the file ack.vim goes in ~/.vim/plugin, and the ack.txt file belongs in ~/.vim/doc. Be sure to run
|
||||
|
||||
:helptags ~/.vim/doc
|
||||
|
||||
afterwards.
|
||||
|
||||
|
||||
## Usage ##
|
||||
|
||||
:Ack [options] {pattern} [{directory}]
|
||||
|
||||
Search recursively in {directory} (which defaults to the current directory) for the {pattern}.
|
||||
|
||||
Files containing the search term will be listed in the split window, along with
|
||||
the line number of the occurrence, once for each occurrence. [Enter] on a line
|
||||
in this window will open the file, and place the cursor on the matching line.
|
||||
|
||||
Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `doc/ack.txt`, or install and `:h Ack` for more information.)
|
||||
|
||||
**From the [ack docs](http://betterthangrep.com/)** (my favorite feature):
|
||||
|
||||
--type=TYPE, --type=noTYPE
|
||||
|
||||
Specify the types of files to include or exclude from a search. TYPE is a filetype, like perl or xml. --type=perl can also be specified as --perl, and --type=noperl can be done as --noperl.
|
||||
|
||||
If a file is of both type "foo" and "bar", specifying --foo and --nobar will exclude the file, because an exclusion takes precedence over an inclusion.
|
||||
|
||||
Type specifications can be repeated and are ORed together.
|
||||
|
||||
See ack --help=types for a list of valid types.
|
||||
|
||||
### Keyboard Shortcuts ###
|
||||
|
||||
In the quickfix window, you can use:
|
||||
|
||||
o to open (same as enter)
|
||||
go to preview file (open but maintain focus on ack.vim results)
|
||||
t to open in new tab
|
||||
T to open in new tab silently
|
||||
v to open in vertical split
|
||||
gv to open in vertical split silently
|
||||
q to close the quickfix window
|
||||
|
||||
This Vim plugin is derived (and by derived, I mean copied, essentially) from
|
||||
Antoine Imbert's blog post [Ack and Vim
|
||||
Integration](http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html) (in
|
||||
particular, the function at the bottom of the post). I added a help file that
|
||||
provides just enough reference to get you going. I also highly recommend you
|
||||
check out the docs for the Perl script 'ack', for obvious reasons: [ack -
|
||||
grep-like text finder](http://betterthangrep.com/).
|
23
sources_non_forked/ack.vim/Rakefile
Normal file
23
sources_non_forked/ack.vim/Rakefile
Normal file
@ -0,0 +1,23 @@
|
||||
# Added by Josh Nichols, a.k.a. technicalpickles
|
||||
require 'rake'
|
||||
|
||||
files = ['doc/ack.txt', 'plugin/ack.vim']
|
||||
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts " Copied #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
70
sources_non_forked/ack.vim/doc/ack.txt
Normal file
70
sources_non_forked/ack.vim/doc/ack.txt
Normal file
@ -0,0 +1,70 @@
|
||||
*ack.txt* Plugin that integrates ack with Vim
|
||||
|
||||
==============================================================================
|
||||
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *ack*
|
||||
|
||||
This plugin is a front for the Perl module App::Ack. Ack can be used as a
|
||||
replacement for grep. This plugin will allow you to run ack from vim, and
|
||||
shows the results in a split window.
|
||||
|
||||
:Ack[!] [options] {pattern} [{directory}] *:Ack*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
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.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
Just like |:Ack|, but instead of making a new list, the matches are
|
||||
appended to the current |quickfix| list.
|
||||
|
||||
:AckFromSearch [{directory}] *:AckFromSearch*
|
||||
|
||||
Just like |:Ack| but the pattern is from previous search.
|
||||
|
||||
:LAck [options] {pattern} [{directory}] *:LAck*
|
||||
|
||||
Just like |:Ack| but instead of the |quickfix| list, matches are placed in
|
||||
the current |location-list|.
|
||||
|
||||
:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
|
||||
|
||||
Just like |:AckAdd| but instead of the |quickfix| list, matches are added
|
||||
to the current |location-list|
|
||||
|
||||
:AckFile [options] {pattern} [{directory}] *:AckFile*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for filenames matching the {pattern}. Behaves just like the
|
||||
|:grep| command, but will open the |Quickfix| window for you.
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
See http://betterthangrep.com/ for more information.
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *ack-mappings*
|
||||
|
||||
The following keyboard shortcuts are available in the quickfix window:
|
||||
|
||||
o open file (same as enter).
|
||||
|
||||
go preview file (open but maintain focus on ack.vim results).
|
||||
|
||||
t open in a new tab.
|
||||
|
||||
T open in new tab silently.
|
||||
|
||||
v open in vertical split.
|
||||
|
||||
gv open in vertical split silently.
|
||||
|
||||
q close the quickfix window.
|
80
sources_non_forked/ack.vim/plugin/ack.vim
Normal file
80
sources_non_forked/ack.vim/plugin/ack.vim
Normal file
@ -0,0 +1,80 @@
|
||||
" NOTE: You must, of course, install the ack script
|
||||
" in your path.
|
||||
" On Debian / Ubuntu:
|
||||
" sudo apt-get install ack-grep
|
||||
" On your vimrc:
|
||||
" let g:ackprg="ack-grep -H --nocolor --nogroup --column"
|
||||
"
|
||||
" With MacPorts:
|
||||
" sudo port install p5-app-ack
|
||||
|
||||
" Location of the ack utility
|
||||
if !exists("g:ackprg")
|
||||
let g:ackprg="ack -H --nocolor --nogroup --column"
|
||||
endif
|
||||
|
||||
function! s:Ack(cmd, args)
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args
|
||||
end
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m"
|
||||
end
|
||||
|
||||
let grepprg_bak=&grepprg
|
||||
let grepformat_bak=&grepformat
|
||||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . l:grepargs
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
|
||||
if a:cmd =~# '^l'
|
||||
botright lopen
|
||||
else
|
||||
botright copen
|
||||
endif
|
||||
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
||||
exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> o <CR>"
|
||||
exec "nnoremap <silent> <buffer> go <CR><C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> v <C-W><C-W><C-W>v<C-L><C-W><C-J><CR>"
|
||||
exec "nnoremap <silent> <buffer> gv <C-W><C-W><C-W>v<C-L><C-W><C-J><CR><C-W><C-J>"
|
||||
|
||||
" If highlighting is on, highlight the search keyword.
|
||||
if exists("g:ackhighlight")
|
||||
let @/=a:args
|
||||
set hlsearch
|
||||
end
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! s:AckFromSearch(cmd, args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
|
||||
call s:Ack(a:cmd, '"' . search .'" '. a:args)
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* -complete=file Ack call s:Ack('grep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
Reference in New Issue
Block a user