5FLTMCXWFLP6MI36R73NDC5ZZGKRB66IXOWY7ZTESTLC7M357H2QC
" --- the plugins are between the call plug begin and end
call plug#begin('~/.vim/plugged')
Plug 'bronson/vim-trailing-whitespace'
Plug 'rking/ag.vim'
Plug 'SirVer/ultisnips', { 'on': [] } | Plug 'honza/vim-snippets'
Plug 'Valloric/YouCompleteMe', { 'on': [] }
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable'}
Plug 'tpope/vim-surround'
" Unite depend on vimproc
Plug 'Shougo/vimproc.vim',{'do':'make'}
Plug 'Shougo/unite.vim'
" Swift syntax and indent files
Plug 'keith/swift.vim'
" syntastic
Plug 'https://github.com/scrooloose/syntastic.git'
" uses the local eslint install
Plug 'mtscout6/syntastic-local-eslint.vim'
" vim-go
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
" vim-go has some commands that depend on ctrlp
Plug 'ctrlpvim/ctrlp.vim'
call plug#end()
" -- ultisnips / youcompleteme config
augroup load_us_ycm
autocmd!
autocmd InsertEnter * call plug#load('ultisnips', 'YouCompleteMe')
\| autocmd! load_us_ycm
augroup END
let g:ycm_autoclose_preview_window_after_completion=1
nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
" UltiSnips triggering
let g:UltiSnipsExpandTrigger = '<S-j>'
let g:UltiSnipsJumpForwardTrigger = '<S-j>'
let g:UltiSnipsJumpBackwardTrigger = '<S-k>'
" syntastic config
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_error_symbol = 'X'
let g:syntastic_style_error_symbol = '!'
let g:syntastic_warning_symbol = 'W'
let g:syntastic_style_warning_symbol = 'S'
highlight link SyntasticErrorSign SignColumn
highlight link SyntasticWarningSign SignColumn
highlight link SyntasticStyleErrorSign SignColumn
highlight link SyntasticStyleWarningSign SignColumn
" -- VIM-GO config
let g:go_fmt_command = "goimports"
let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
" let g:go_auto_sameids = 1 " this highlights matching declarations and I think I hate it
" these autocmd are like short cuts for moving between files
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
" prevent issues with syntastic
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:go_list_type = "quickfix"
" -- LOOK AND FEEL
set background=dark
colorscheme Tomorrow-Night
filetype on
syntax enable " enable syntax processing
set number " set line numbers
set showcmd " show command in bottom bar
set lazyredraw " redraw only when needed. (speeds things up)
set showmatch " highlight matching braces, brackets, parens
" -- save on buffer switch
set autowrite
" -- SEARCHING
set ignorecase " ignore case for searches
set incsearch " search as characters are input
set hlsearch " highlight search matches
nnoremap <silent> <Esc> :nohlsearch<Bar>:echo<CR>
" -- Keep more info in memory to speed things up:
set hidden
set history=100
" -- INDENT SETTINGS
autocmd Filetype html setlocal ts=2 sw=2 expandtab
autocmd Filetype ruby setlocal ts=2 sw=2 expandtab
autocmd Filetype javascript setlocal ts=4 sw=4 sts=0 noexpandtab
autocmd Filetype c setlocal ts=4 sw=4 expandtab cindent
autocmd Filetype swift setlocal ts=4 sw=4 expandtab cindent
autocmd BufNewFile,BufRead *.go setlocal noexpandtab ts=4 sw=4
filetype indent on
imap <S-tab> <C-d>
set smartindent
set autoindent
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set expandtab " tabs are spaces
set nowrap
" -- KEY BINDINGS / REMAPS
" gV - visually selects last inserted block
nnoremap gV `[v`]
" jj - is escape in insert mode
inoremap jj <esc>
" \a - invoces :Ag
nnoremap <leader>a :Ag
" \j - next buffer
nnoremap <leader>j :bn<ENTER>
" \jw - next buffer in new window
nnoremap <leader>wj :sbnext<ENTER>
" \pp - paste into buffer
nnoremap <leader>pp :r !pbpaste<CR>
" -- GO lang specific remapings
" \rr go run file
autocmd FileType go nmap <leader>rr <Plug>(go-run)
" \bb go build file
autocmd FileType go nmap <leader>bb :<C-u>call <SID>build_go_files()<CR>
" \tt go test file
autocmd FileType go nmap <leader>tt <Plug>(go-test)
" \tc go test coverage
autocmd FileType go nmap <Leader>tc <Plug>(go-coverage-toggle)
" \tcb go test coverage show in browser
autocmd FileType go nmap <Leader>tcb <Plug>(go-coverage-browser)
" \gc go run metalinter (ie all of the static analysis tools)
autocmd FileType go nmap <leader>gc :GoMetaLinter<CR>
" \i go show go info for under cursor
autocmd FileType go nmap <Leader>i <Plug>(go-info)
" \e run go rename
au FileType go nmap <Leader>e <Plug>(go-rename)
" ctrl. vim-go quick fix window next error
nnoremap <C-n> :cnext<CR>
" ctrl, vim-go quik fix window prev error
nnoremap <C-m> :cprevious<CR>
" ctrl/ vim-go quick fix window close
nnoremap <leader>c :cclose<CR>
" -- FUNCTIONS
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#cmd#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
# set vi mode by default
set -o vi
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
###########
# Functions
###########
# make a directory and change into it
mcd () {
mkdir -p $1
cd $1
}
# set the contents of a file to the mac os
# clipboard
copy () {
cat $1 | pbcopy
}
# iterate through each immediate child directory
# check to see if it's a git repo and run -- git pull
pullall () {
dir=`pwd`
for REPO in `ls -l | grep ^d | grep -oE '[^ ]+$'`;
do
command -p cd "$REPO";
if [ -d ".git" ]; then
cbranch=`git branch | grep "^\* " | sed "s/\* //g"`
if [ $cbranch != "master" ]; then
echo "checking out master branch..."
command git checkout "master"
fi
echo "pulling master branch of: $REPO ..."
command git pull
if [ $cbranch != "master" ]; then
echo "switching back to branch: $cbranch ..."
command -p cd "$cbranch"
fi
echo "done pulling $REPO ..."
echo "" #hacky way of newlining
fi
command -p cd $dir
done;
}
###################
# ALIASES for EB VM
###################
alias mysql-core='mysql -u root -h 127.0.0.1 -P `docker port mysql-core 3306 | cut -f 2 -d :`'
alias mysql-payments='mysql -u root -h 127.0.0.1 -P `docker port mysql-payments 3306 | cut -f 2 -d :`'
alias mysql-webhooks='mysql -u root -h 127.0.0.1 -P `docker port mysql-webhooks 3306 | cut -f 2 -d :`'
# prompt settings
export PS1="[\W] $ "
# color settings
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
# arc tools env variables
export EBPATH=/Users/ccummings/Eb-Github/eventbrite/
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
### PATH SETTINGS
# add GOPATH env variable for golang
export GOPATH=$HOME/go_projects
# export PATH=$ARCANIST_INSTALL_DIR/bin:/usr/local/bin:$GOPATH/bin:$PATH
export PATH=/usr/local/bin:$GOPATH/bin:$PATH
###
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
# swift repl fix - due to brew python being at the front of $PATH variable
alias swift="PATH=/usr/bin:$PATH swift"
# mysql stuff
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
# end mysql stuff
alias cp='cp -iv' # preferred cp implementation
alias mv='mv -iv' # preferred mv implementation
alias mkdir='mkdir -pv' # preferred mkdir implementation
alias ll='ls -FGlAhp' # preferred less implementation
cd() { builtin cd "$@"; ls -a; } # Always list directory contents after 'cd'
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias .2='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias finder='open -a Finder ./' # finder: Opens current directory in MacOS Finder
alias ~="cd ~" # ~: Go Home
# alias c='clear' # c: Clear terminal display
# alias which='type -all' # which: Find executables
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias show_options='shopt' # Show_options: display bash options settings
alias fix_stty='stty sane' # fix_stty: Restore terminal settings when screwed up
alias cic='set completion-ignore-case On' # cic: Make tab-completion case-insensitive
mkdircd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash
preview () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview
alias DT='tee ~/Desktop/terminalOut.txt' # DT: Pipe content to file on MacOS Desktop
alias edit='atom' # edit file with Atom text editor
# lr: Full Recursive Directory Listing
# ------------------------------------------
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
# -------------------------------
# 3. FILE AND FOLDER MANAGEMENT
# -------------------------------
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder
alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias make1mb='mkfile 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros)
alias make5mb='mkfile 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros)
alias make10mb='mkfile 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros)
# cdfinder: 'Cd's to frontmost window of MacOS Finder
# ------------------------------------------------------
cdfinder () {
currFolderPath=$( /usr/bin/osascript <<EOT
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT
)
echo "cd to \"$currFolderPath\""
cd "$currFolderPath"
}
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
alias getstaticip='dig +short myip.opendns.com @resolver1.opendns.com' # get the static ip of the current network
export ARCANIST_INSTALL_DIR=/Users/ccummings/.evbdevtools
source $ARCANIST_INSTALL_DIR/devtools/scripts/devenv_bash/arcanist_helpers.sh