This commit is contained in:
Michael Campagnaro 2015-02-23 23:34:00 -05:00
parent e35f1757f0
commit 091ad65ce3
9 changed files with 201 additions and 81 deletions

1
vim/bundle/Vundle.vim Submodule

@ -0,0 +1 @@
Subproject commit 0b28e334e65b6628b0a61c412fcb45204a2f2bab

View File

@ -18,7 +18,7 @@ git clone https://github.com/ggreer/the_silver_searcher ag && cd ag && ./build.s
* Then, if you're using [pathogen](https://github.com/tpope/vim-pathogen):
```sh
cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +HelpTags
cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +Helptags
```
* Or, if you're using [Vundle](https://github.com/gmarik/vundle):
@ -27,7 +27,7 @@ cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && vim +HelpTag
echo "Bundle 'rking/ag.vim'" >> ~/.vimrc && vim +BundleInstall
```
### Configuation
### Configuration
You can specify a custom ag name and path in your .vimrc like so:
@ -49,12 +49,13 @@ Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ag
Some characters have special meaning, and need to be escaped your search pattern. For instance, '#'. You have to escape it like this `:Ag '\\\#define foo'` to search for `#define foo`. (From [blueyed in issue #5](https://github.com/mileszs/ack.vim/issues/5).)
Sometimes `git grep` is even faster, though in my experience it's not noticably so.
Sometimes `git grep` is even faster, though in my experience it's not noticeably so.
### Keyboard Shortcuts ###
In the quickfix window, you can use:
e to open file and close the quickfix window
o to open (same as enter)
go to preview file (open but maintain focus on ag.vim results)
t to open in new tab

View File

@ -6,11 +6,11 @@ if !exists("g:agprg")
endif
if !exists("g:ag_apply_qmappings")
let g:ag_apply_qmappings = !exists("g:ag_qhandler")
let g:ag_apply_qmappings=1
endif
if !exists("g:ag_apply_lmappings")
let g:ag_apply_lmappings = !exists("g:ag_lhandler")
let g:ag_apply_lmappings=1
endif
if !exists("g:ag_qhandler")
@ -21,7 +21,19 @@ if !exists("g:ag_lhandler")
let g:ag_lhandler="botright lopen"
endif
if !exists("g:ag_mapping_message")
let g:ag_mapping_message=1
endif
function! ag#Ag(cmd, args)
let l:ag_executable = get(split(g:agprg, " "), 0)
" Ensure that `ag` is installed
if !executable(l:ag_executable)
echoe "Ag command '" . l:ag_executable . "' was not found. Is the silver searcher installed and on your $PATH?"
return
endif
" If no pattern is provided, search for the word under the cursor
if empty(a:args)
let l:grepargs = expand("<cword>")
@ -31,28 +43,45 @@ function! ag#Ag(cmd, args)
" Format, used to manage column jump
if a:cmd =~# '-g$'
let s:agformat_backup=g:agformat
let g:agformat="%f"
else
elseif exists("s:agformat_backup")
let g:agformat=s:agformat_backup
elseif !exists("g:agformat")
let g:agformat="%f:%l:%c:%m"
end
endif
let grepprg_bak=&grepprg
let grepformat_bak=&grepformat
let l:grepprg_bak=&grepprg
let l:grepformat_bak=&grepformat
let l:t_ti_bak=&t_ti
let l:t_te_bak=&t_te
try
let &grepprg=g:agprg
let &grepformat=g:agformat
set t_ti=
set t_te=
silent execute a:cmd . " " . escape(l:grepargs, '|')
finally
let &grepprg=grepprg_bak
let &grepformat=grepformat_bak
let &grepprg=l:grepprg_bak
let &grepformat=l:grepformat_bak
let &t_ti=l:t_ti_bak
let &t_te=l:t_te_bak
endtry
if a:cmd =~# '^l'
let l:match_count = len(getloclist(winnr()))
else
let l:match_count = len(getqflist())
endif
if a:cmd =~# '^l' && l:match_count
exe g:ag_lhandler
let l:apply_mappings = g:ag_apply_lmappings
else
let l:matches_window_prefix = 'l' " we're using the location list
elseif l:match_count
exe g:ag_qhandler
let l:apply_mappings = g:ag_apply_qmappings
let l:matches_window_prefix = 'c' " we're using the quickfix window
endif
" If highlighting is on, highlight the search keyword.
@ -63,17 +92,34 @@ function! ag#Ag(cmd, args)
redraw!
if l:apply_mappings
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> h <C-W><CR><C-W>K"
exec "nnoremap <silent> <buffer> H <C-W><CR><C-W>K<C-W>b"
exec "nnoremap <silent> <buffer> v <C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t"
exec "nnoremap <silent> <buffer> gv <C-W><CR><C-W>H<C-W>b<C-W>J"
echom "ag.vim keys: q=quit <cr>/t/h/v=enter/tab/split/vsplit go/T/H/gv=preview versions of same"
if l:match_count
if l:apply_mappings
nnoremap <silent> <buffer> h <C-W><CR><C-w>K
nnoremap <silent> <buffer> H <C-W><CR><C-w>K<C-w>b
nnoremap <silent> <buffer> o <CR>
nnoremap <silent> <buffer> t <C-w><CR><C-w>T
nnoremap <silent> <buffer> T <C-w><CR><C-w>TgT<C-W><C-W>
nnoremap <silent> <buffer> v <C-w><CR><C-w>H<C-W>b<C-W>J<C-W>t
exe 'nnoremap <silent> <buffer> e <CR><C-w><C-w>:' . l:matches_window_prefix .'close<CR>'
exe 'nnoremap <silent> <buffer> go <CR>:' . l:matches_window_prefix . 'open<CR>'
exe 'nnoremap <silent> <buffer> q :' . l:matches_window_prefix . 'close<CR>'
exe 'nnoremap <silent> <buffer> gv :let b:height=winheight(0)<CR><C-w><CR><C-w>H:' . l:matches_window_prefix . 'open<CR><C-w>J:exe printf(":normal %d\<lt>c-w>_", b:height)<CR>'
" Interpretation:
" :let b:height=winheight(0)<CR> Get the height of the quickfix/location list window
" <CR><C-w> Open the current item in a new split
" <C-w>H Slam the newly opened window against the left edge
" :copen<CR> -or- :lopen<CR> Open either the quickfix window or the location list (whichever we were using)
" <C-w>J Slam the quickfix/location list window against the bottom edge
" :exe printf(":normal %d\<lt>c-w>_", b:height)<CR> 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 <cr>/e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same"
endif
endif
else
echom 'No matches for "'.a:args.'"'
endif
endfunction
@ -85,17 +131,17 @@ function! ag#AgFromSearch(cmd, args)
endfunction
function! ag#GetDocLocations()
let dp = ''
for p in split(&rtp,',')
let p = p.'/doc/'
if isdirectory(p)
let dp = p.'*.txt '.dp
endif
endfor
return dp
let dp = ''
for p in split(&runtimepath,',')
let p = p.'/doc/'
if isdirectory(p)
let dp = p.'*.txt '.dp
endif
endfor
return dp
endfunction
function! ag#AgHelp(cmd,args)
let args = a:args.' '.ag#GetDocLocations()
call ag#Ag(a:cmd,args)
let args = a:args.' '.ag#GetDocLocations()
call ag#Ag(a:cmd,args)
endfunction

View File

@ -54,13 +54,73 @@ 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.
See http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-than-ack/ for
more information.
==============================================================================
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: >
let g:agprg="ag --column --smart-case"
<
*g:aghighlight*
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
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): >
let g:agformat="%f:%l:%m"
<
*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: >
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: >
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: >
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: >
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
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
<
==============================================================================
MAPPINGS *ag-mappings*
The following keyboard shortcuts are available in the quickfix window:
e open file and close the quickfix window.
o open file (same as enter).
go preview file (open but maintain focus on ag.vim results).
@ -78,3 +138,5 @@ v open in vertical split.
gv open in vertical split silently.
q close the quickfix window.
vim:tw=78:fo=tcq2:ft=help:norl:

31
vimrc
View File

@ -1,8 +1,21 @@
let mapleader=","
set nocompatible
filetype off
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PLUGINS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugins go here
Plugin 'gmarik/Vundle.vim'
" All of your Plugins must be added before the following line
call vundle#end()
call pathogen#infect()
call pathogen#helptags()
@ -23,11 +36,11 @@ endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>ff :call SelectaCommand("find * -type f", "", ":e")<cr>
nnoremap <leader>f :call SelectaCommand("find * -type f ! -path 'resources/public/js/*' ! -path 'resources/.sass-cache/*' ! -path 'target/*'", "", ":e")<cr>
" # NERDtree
nmap <leader>d :NERDTreeToggle<CR>
nmap <leader>f :NERDTreeFind<CR>
"nmap <leader>d :NERDTreeToggle<CR>
"nmap <leader>ff :NERDTreeFind<CR>
" # gist-vim
let g:gist_detect_filetype = 1
@ -35,13 +48,19 @@ let g:gist_open_browser_after_post = 1
let g:gist_show_privates = 1
let g:gist_post_private = 1
" vim-clojure-static
let g:clojure_align_multiline_strings = 1
" Default
let g:clojure_fuzzy_indent = 1
let g:clojure_fuzzy_indent_patterns = ['^match', '^with', '^def', '^let']
let g:clojure_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading-context)$']
" # c-tags
set tags+=tags;$HOME
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
" allow unsaved background buffers and remember marks/undo for them
set hidden
set history=10000
@ -133,8 +152,8 @@ map <Leader>bb :!bundle install<cr>
map <leader>gs :Gstatus<CR>
map <leader>gw :!git add . && git commit -m 'WIP'<cr>
map <leader>pn :sp ~/jelly/documents/Notes/stack.txt<cr>
map <leader>sn :sp ~/jelly/documents/software-notes/pcg-dive.md<cr>
map <leader>rn :sp ~/work/pcg/files/notes/refactoring-notes.md<cr>
map <leader>sn :sp ~/jelly/documents/software-notes/clojure.md<cr>
map <leader>rn :sp ~/work/dive-networks/files/notes/refactoring-notes.md<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CLOJURE AND CLOJURESCRIPT

View File

@ -5,6 +5,7 @@ if [[ $platform == 'Linux' ]]; then
alias ll='ls -lrth --color'
elif [[ $platform == 'Darwin' ]]; then
alias l='ls -laG'
alias ls='ls -laG'
alias ll='ls -lG'
fi
@ -32,17 +33,18 @@ alias bo='bundle open'
alias cls=clear
alias code='cd ~/code'
alias cpr='cp -r'
alias d='dart'
alias cw='compass watch'
alias d='cd ~/work/dive-networks/dive'
alias da='dartanalyzer'
alias dc='dart --checked'
alias dd='dartdoc'
alias dot='cd ~/.dotfiles'
alias dot='cd ~/.'
alias dr='cd ~/Dropbox'
alias duh='du -csh'
alias functions='vim ~/.dotfiles/zsh/functions'
alias f='fg'
alias gib='gem install bundler'
alias gems='cd ~/pcg/gems'
alias gems='cd ~/dive-networks/gems'
alias history='fc -l 1'
alias histroy='history'
alias h='heroku'
@ -51,13 +53,16 @@ alias hc='heroku config'
alias hca='heroku config:add'
alias hcu='heroku config:unset'
alias irb='irb --readline -r irb/completion'
alias lcc='lein clean'
alias lca='lein cljsbuild auto dev'
alias ldi='lein deps install'
alias li='lineman'
alias lir='lineman run'
alias lib='lineman build'
alias lig='lineman grunt'
alias lis='lineman spec'
alias lic='lineman spec-ci'
alias lmi='lein modules install'
alias lsd='lein start-dev'
alias mc='mvn compile'
alias mct='mvn test'
alias mi='mvn install'
@ -123,10 +128,12 @@ alias gdm='git diff master'
alias gds='git diff --stat=160,120'
alias gdw='git diff --color-words'
alias gf='git fetch'
alias gfa='git fetch --all'
alias gfix="git commit --amend -C HEAD"
alias gfixs="git commit -S -a --amend -C HEAD" # signed
alias gfo='git fetch origin'
alias gfm='git fetch origin master'
alias gfup='git fetch upstream'
alias gh="source ~/.githelpers && show_git_head"
alias gl='gll -25'
alias gli='git show --pretty="format:" --name-only'
@ -143,15 +150,18 @@ alias gp='git push'
alias gpa='git push && echo "pushing tags..." && git push --tags'
alias gpd='git push && git push heroku master'
alias gpdf='gpf && gphf'
alias gpp='git push && git push production HEAD:production'
alias gppp='git push production'
alias gpp='echo "Pushing Upstream master to production" && git push production upstream/master:master'
alias gps='git push staging master -f'
alias gpps='echo "Pushing Upstream master to staging" && git push staging upstream/master:master -f'
alias gppf='gpf && git push production HEAD:production -f'
alias gph='echo "pushing $(git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3) to Heroku master" && git push heroku HEAD:master'
alias gphf='git push heroku master --force'
alias gpf='git push -f'
alias gpu='git push -u origin master'
alias gpup='git push upstream master'
alias gpff='git pull --ff-only'
alias gpl='git pull'
alias gplup='git pull upstream master'
alias gpo='git push origin'
alias gpom='git push origin master'
alias gpr='git pull --rebase'
@ -164,12 +174,17 @@ alias grbi='git rebase -i'
alias grbm='git fetch origin master && git rebase master'
alias grbmi='git fetch origin master && git rebase master -i'
alias grbo='git fetch origin master && git rebase origin/master'
alias grbmo="echo 'use grbo instead'"
alias grbu='git fetch upstream master && git rebase upstream/master'
alias grbup='echo "use grbu"'
alias grbupm='echo "use grbu"'
alias gre='git remote'
alias grea='git remote add'
alias greao='git remote add origin'
alias gref='git reflog'
alias grev='git remote -v'
alias grm='git rm'
alias grmr='git rm -r'
alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"'
alias gsh='git show'
alias gst='git status'
@ -189,36 +204,20 @@ alias gxx='git reset --hard HEAD~1 && git pull --ff-only'
alias gstats="echo 'Total commits: $(git rev-list HEAD --count)'; echo '\nAuthor breakdown:'; git shortlog | grep -E '^[^ ]'"
# Notes
alias art='cd ~/Dropbox/notes/art'
alias notes='cd ~/jelly/documents'
alias bucket='cd ~/Dropbox/notes/buckets'
alias pn='vim ~/jelly/documents/Notes/stack.txt'
alias sharp='vim ~/Dropbox/notes/sharpening-notes'
alias writing='cd ~/brain/writing'
alias what='cd ~/brain/writing/2014/what-happened'
# Projects
alias projects='cd ~/jelly/projects'
alias web='cd ~/jelly/projects/websites/michael.is'
alias weba='cd ~/jelly/projects/websites/michael.is/angular'
alias dot='cd ~/jelly/dev/projects/dotfiles'
alias dot='cd ~/jelly/projects/dotfiles'
alias work='cd ~/work'
alias brain='cd ~/brain'
alias school='cd ~/brain/school'
alias pcg='cd ~/work/pcg'
alias dive='cd ~/work/pcg/dive-network/dive'
alias di='cd ~/work/pcg/dive-network/dive/src-cljs/dive'
alias pcg='cd ~/work/dive-networks'
alias dive='cd ~/work/dive-networks/dive/dive-web-app'
alias di='cd ~/work/dive-networks/dive/dive-web-app/src/cljs/dive'
# Work
alias pcgn='vim ~/work/pcg/files/notes/personal-notes.md'
alias pcgr='vim ~/work/pcg/files/notes/refactoring-notes.md'
alias pcgf='cd ~/work/pcg/files'
alias bastion='ssh 54.86.79.26 -l pcg-user -i ~/.ssh/pcg-ec2-pcg-user'
alias sigma='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@sigma'
alias qonos='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@qonos'
alias samza1='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza1'
alias samza2='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza2'
alias samza3='cd ~/pcg/pcg-ansible && ssh -vF files/ssh/config pcg-user@samza3'
alias dstaging='ssh pcg-user@192.168.2.20 -i ~/.ssh/dive_20140923_rsa'
alias dclear='ssh pcg-user@192.168.2.90 -i ~/.ssh/dive_20140923_rsa'
source ~/work/dive-networks/aliases
alias dh='git push heroku-staging master -f'

View File

@ -243,6 +243,8 @@ zgitinit() {
}
zgitinit
zgit_info_update
# Temporarily disabling as this is slowing down new term tabs, especially when opening a
# work git directory
# zgit_info_update
# vim:set ft=zsh:

View File

@ -21,7 +21,7 @@ function git-done {
}
function git-nuke {
git branch -D $1 && git push origin :$1
git checkout master && git branch -D $1 && git push origin :$1
}
function git-on-master {
@ -64,12 +64,6 @@ function chrome () {
open -a /Applications/Google\ Chrome.app/ "$1"
}
# Open a file in chrome
function chrome-kiosk () {
open -a /Applications/Google\ Chrome.app/ --args --kiosk --no-first-run --no-default-browser-check --noerrdialogs --no-message-box --disable-desktop-notifications --allow-running-insecure-content --always-authorize-plugins --allow-outdated-plugins "$1"
}
# See top 10 bash commands
function hist() {
cat ~/.history|cut -d ';' -f 2- 2>/dev/null| awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
@ -86,4 +80,3 @@ function bump_gem_version {
git push origin && git push origin --tags
fi
}

7
zshrc
View File

@ -33,7 +33,7 @@ export TERM=xterm-256color
export EDITOR=vi
# Grep tweaks
export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=personal" # --exclude-dir=images --exclude-dir=coverage
export GREP_OPTIONS="-nRi --color --exclude-dir=.git --exclude-dir=tmp --exclude-dir=log --exclude-dir=node_modules --exclude-dir=bower_components --exclude-dir=coverage --exclude-dir=.bundle --exclude=*.csv --exclude=*.pdf --exclude-dir=vendor --exclude-dir=rdoc --exclude-dir=target --exclude-dir=personal" # --exclude-dir=images --exclude-dir=coverage
# Save a ton of history
export HISTSIZE=20000
@ -80,12 +80,9 @@ export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
# Setup Ansible
ANSIBLE_DIR=/Users/pulsar/Code/open-source/python/ansible
ANSIBLE_DIR=/Users/pulsar/jelly/oss/python/ansible
export PATH=${ANSIBLE_DIR}/bin:${PATH}
export PYTHONPATH=${ANSIBLE_DIR}/lib:${PYTHONPATH}
export ANSIBLE_LIBRARY=${ANSIBLE_DIR}/library
export MANPATH=${ANSIBLE_DIR}/docs/man:${MANPATH}
export ANSIBLE_HOSTS=~/.ansible_hosts
# Setup Dart
export PATH=/Applications/Dart/dart-sdk/bin:${PATH}