diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/rfgrep/Makefile | 6 | ||||
-rwxr-xr-x | contrib/rfgrep/rfgrep | 23 | ||||
-rw-r--r-- | contrib/vim/Makefile | 5 | ||||
-rw-r--r-- | contrib/vim/README.md | 68 | ||||
-rw-r--r-- | contrib/vim/plugin/rf.vim | 93 |
5 files changed, 0 insertions, 195 deletions
diff --git a/contrib/rfgrep/Makefile b/contrib/rfgrep/Makefile deleted file mode 100644 index 1468fec..0000000 --- a/contrib/rfgrep/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -BIN = rfgrep -PREFIX = /usr/local - -install: - mkdir -p $(DESTDIR)$(PREFIX)/bin - install -m755 $(BIN) $(DESTDIR)$(PREFIX)/bin/ diff --git a/contrib/rfgrep/rfgrep b/contrib/rfgrep/rfgrep deleted file mode 100755 index d1f262e..0000000 --- a/contrib/rfgrep/rfgrep +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -e - -files= -edit= - -EDITOR=${EDITOR:-vim} - -while getopts 'ef' opt; do - case $opt in - e) edit=1; shift ;; - f) files=1; shift ;; - esac -done - -if [ "$files" ]; then - rf '*' | xargs grep -Ir "$1" | awk -F':' '{print $1}' | sort | uniq -elif [ "$edit" ]; then - $EDITOR $(rf '*' | xargs grep -Ir "$1" | awk -F':' '{print $1}' | sort | uniq) -else - rf '*' | xargs grep -Ir "$1" -fi diff --git a/contrib/vim/Makefile b/contrib/vim/Makefile deleted file mode 100644 index 84493bc..0000000 --- a/contrib/vim/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DEST = ~/.vim/after/plugin - -install: - mkdir -p $(DEST) - install -m644 ./plugin/rf.vim $(DEST) diff --git a/contrib/vim/README.md b/contrib/vim/README.md deleted file mode 100644 index f108c89..0000000 --- a/contrib/vim/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# rf-vim - -> Simple `rf` Vim integration - -### Installation - -__Manual installation:__ - -If you are using default Vim paths (so not Neovim for example) you can -just run `make install`. Otherwise you should just be able to modify your -`runtimepath` and add `~/.vim/after/`. - -__Using vim-plug, Vundle, et al:__ - -```viml -Plug 'roryrjb/rf', { 'rtp': 'contrib/vim' } " vim-plug -Plugin 'roryrjb/rf', { 'rtp': 'contrib/vim' } " Vundle -``` - -Other plugin systems will likely have very similar options. In a nutshell -the vim plugin provided here isn't in the root of the repo and assumes -you have `rf` already installed and present in your `$PATH`. - -### Usage - -The plugin provides two functions: - -__RF:__ - -This function runs a getchar() loop, allowing you to search from the -root of the current working directory, using only substring patterns, -the idea being that it is very quick and simple to use, rather than -exposing more of the functionality that rf provides. - -I usually bind the function like so: - -``` -map <c-p> :RF <CR> -``` - -The function is very simple and will call rf with your pattern -*at every key stroke*. Usually this is performant enough, but -with extremely large directory trees, you may have to wait several -seconds for results, which isn't great. Aside from any improvements -to the implementation, just make sure that any `.rfignore` files, -whether local or global are ignoring everything that can be ignored. - -__RFGrep:__ - -``` -:RFGrep search-pattern filename-pattern -``` - -This function is a wrapper around `grep -r` and rf. It allows you -to grep recursively over a smaller subset of files. Again the -implementation is very simple but with very large directory trees -or with filename patterns that match a lot of files you may -hit the argument limit for grep. - -### Issues - -Aside from the above mentioned limitations and issues, if you -are using anything other than a "Bourne" shell (bash, ksh, zsh, sh) -the functions may not work, in that case you may want to explictly: - -``` -set shell=sh -``` diff --git a/contrib/vim/plugin/rf.vim b/contrib/vim/plugin/rf.vim deleted file mode 100644 index 859d81e..0000000 --- a/contrib/vim/plugin/rf.vim +++ /dev/null @@ -1,93 +0,0 @@ -if exists('loaded_rf') - finish -endif - -let loaded_rf = 1 -let g:rf_prefix = "" - -set errorformat+=%f - -function! g:RFGrepR(args) - " let results = system('grep -nrI ' . shellescape(a:args) . " $(rf -- " . shellescape(a:ft) . ")") - let results = system("rf -s'' | xargs grep -nrI '" . shellescape(a:args) . "'") - cgete results | copen 9 -endfunction - -function! g:RFPrompt() - echo "RF: " - - let l:rf_pattern = '' - let l:rf_cmd = 0 - let l:rf_results = [] - - while 1 - let c = getchar() - - if c == 13 - if l:rf_pattern == '' - cclose - break - endif - - let i = getqflist({'idx' : 0}).idx - - if len(l:rf_results) > 0 - cclose - execute('e ' . l:rf_results[i - 1]) - endif - - break - elseif c == "\<BS>" - let l:rf_pattern = l:rf_pattern[0:-2] - elseif c == "\<UP>" - let i = getqflist({'idx' : 0}).idx - - if i > 0 - call setqflist([], 'a', {'idx' : i - 1}) - redraw - endif - - let l:rf_cmd = 1 - elseif c == "\<DOWN>" - let i = getqflist({'idx' : 0}).idx - call setqflist([], 'a', {'idx' : i + 1}) - redraw - let l:rf_cmd = 1 - else - let ch = nr2char(c) - let l:rf_pattern = l:rf_pattern . ch - endif - - if l:rf_cmd == 0 - echo "RF: " . l:rf_pattern - redraw - - if len(g:rf_prefix) - let results = system('rf -l9 -d ' . shellescape(g:rf_prefix) . ' -s -- ' . shellescape(l:rf_pattern)) - else - let results = system('rf -l9 -ws -- ' . shellescape(l:rf_pattern)) - endif - - let results_list = split(results, '\n') - let l:rf_results = results_list - - if len(results_list) > 0 - if len(results_list) < 9 - execute "cgete results | copen " . len(results_list) - else - cgete results | copen 9 - endif - - redraw - else - cexpr [] - cclose - endif - else - let l:rf_cmd = 0 - endif - endwhile -endfunction - -command! -nargs=* RF call RFPrompt() -command! -nargs=* RFGrep call RFGrepR(<f-args>) |