diff --git a/vimrc b/vimrc index 3f9b56e..899232c 100644 --- a/vimrc +++ b/vimrc @@ -15,29 +15,22 @@ Plugin 'gmarik/Vundle.vim' "Frameworks/languages Plugin 'tpope/vim-rails' -Plugin 'tpope/vim-bundler' Plugin 'tpope/vim-fugitive' -" follow instructions here => https://github.com/skwp/vim-rspec Plugin 'thoughtbot/vim-rspec' Plugin 'tpope/vim-dispatch' - -"Coding Plugin 'Lokaltog/vim-easymotion' Plugin 'scrooloose/nerdcommenter' Plugin 'scrooloose/nerdtree' -Plugin 'kien/ctrlp.vim' -Plugin 'jc00ke/vim-tomdoc' +Plugin 'ervandew/supertab' +Plugin 'junegunn/vim-easy-align' +Plugin 'szw/vim-ctrlspace' + Plugin 'mattn/emmet-vim' Plugin 'scrooloose/syntastic' -Plugin 'nathanaelkane/vim-indent-guides' Plugin 'MarcWeber/vim-addon-mw-utils' Plugin 'tomtom/tlib_vim' -Plugin 'garbas/vim-snipmate' -Plugin 'honza/vim-snippets' -Plugin 'ervandew/supertab' Plugin 'bling/vim-airline' Plugin 'tpope/vim-endwise' -Plugin 'junegunn/vim-easy-align' Plugin 'vim-scripts/EasyGrep' Plugin 'gorkunov/smartpairs.vim' @@ -46,6 +39,7 @@ Plugin 'rizzatti/funcoo.vim' Plugin 'rizzatti/dash.vim' "Syntaxes +Plugin 'nathanaelkane/vim-indent-guides' Plugin 'tpope/vim-haml' Plugin 'slim-template/vim-slim' Plugin 'vim-ruby/vim-ruby' @@ -68,14 +62,6 @@ filetype plugin indent on " Turn on file type detection. let mapleader = "," nnoremap \ , -" Use ii to escape -inoremap jk :w - -" close -nnoremap cl :close -" Buffer hotkey -nnoremap b :buffer - "au FocusLost * :wa " Autosave everything set autowriteall "save file when buffer switched set ttyfast @@ -99,12 +85,44 @@ set hlsearch " highlight matches set incsearch " incremental searching set ignorecase " searches are case insensitive... set smartcase " ... unless they contain at least one capital letter -"set grepprg=git\ grep\ -nHI\ --exclude-standard\ --heading\ --color\ --no-index\ -e\ $1 -"command -nargs=+ Ggr execute 'silent Ggrep!' | cw | redraw! + +" Run a given vim command on the results of fuzzy selecting from a given shell +" command. See usage below. +" Note: I'm using Iterm2 and remapped ^[ to "Send Hex Codes: 0x03" which is == ^C +function! SelectaCommand(choice_command, selecta_args, vim_command) + try + let selection = system(a:choice_command . " | selecta " . a:selecta_args) + catch /Vim:Interrupt/ + " Swallow the ^C so that the redraw below happens; otherwise there will be + " leftovers from selecta on the screen + redraw! + return '' + endtry + redraw! + exec a:vim_command . " " . selection +endfunction + +let ignore = [".git", "vendor", ".svg", ".eot", ".jpg", '\/\.', '^\..*'] " ignore hidden files +let excludes= " \| GREP_OPTIONS=\'\' egrep -v -e \'" . join(map(ignore, 'v:val'), "\|") . "\'" + +" 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 :call SelectaCommand("git ls-files --exclude-standard" .g:excludes, "", ":e") + +function! SelectaBuffer() + let bufnrs = filter(range(1, bufnr("$")), 'buflisted(v:val)') + let buffers = map(bufnrs, 'bufname(v:val)') + call SelectaCommand('echo "' . join(buffers, "\n") . '"', "", ":b") +endfunction + +" Fuzzy select a buffer. Open the selected buffer with :b. +nnoremap :call SelectaBuffer() + +"set grepprg=git\ grep\ --exclude-standard\ -n\ $* function! Grep() - let params = input('search for: ', expand('%')) - exec ':silent Ggrep!' . params + let params = input('search for: ', expand('')) + exec ':silent Ggrep! -I' . params cw redraw! endfunction @@ -117,9 +135,9 @@ set listchars="" " Reset the listchars set listchars=tab:\ \ " a tab should display as " ", trailing whitespace as "." set listchars+=trail:. " show trailing spaces as dots set listchars+=extends:> " The character to show in the last column when wrap is - "" off and the line continues beyond the right of the screen +"" off and the line continues beyond the right of the screen set listchars+=precedes:< " The character to show in the last column when wrap is - "" off and the line continues beyond the left of the screen +"" off and the line continues beyond the left of the screen " "Tabs Indentations @@ -140,6 +158,11 @@ function TrimWhiteSpace() '' endfunction +nmap mm ` + +" Use ii to escape +inoremap jk :w + autocmd FileWritePre * :call TrimWhiteSpace() autocmd FileAppendPre * :call TrimWhiteSpace() autocmd FilterWritePre * :call TrimWhiteSpace() @@ -148,7 +171,7 @@ autocmd BufWritePre * :call TrimWhiteSpace() " rename current file and new file path function! RenameFile() let old_name = expand('%') - let new_name = input('New file name: ', expand('')) + let new_name = input('New file name: ', expand('%')) if new_name != '' && new_name != old_name exec ':saveas ' . new_name exec ':silent !rm ' . old_name @@ -177,15 +200,6 @@ let g:syntastic_style_error_symbol='>' let g:syntastic_warning_symbol='⚠' let g:syntastic_style_warning_symbol='>' -"set nofoldenable -"set foldmethod=syntax " Pretty slow -"set foldlevel=1 -"au BufRead * normal zR -"au BufNewFile,BufReadPost *.rb setl nofoldenable -"au BufNewFile,BufReadPost *.rb normal zi "default to unfolded -"autocmd InsertEnter * let w:last_fdm=&foldmethod | setlocal foldmethod=manual -"autocmd InsertLeave * let &l:foldmethod=w:last_fdm - "" "" Colors/ Highlights "" @@ -231,31 +245,6 @@ endfunction command! Invbg call ReverseBackground() noremap :Invbg -function! s:RunShellCommand(cmdline) - let isfirst = 1 - let words = [] - for word in split(a:cmdline) - if isfirst - let isfirst = 0 " don't change first word (shell command) - else - if word[0] =~ '\v[%#<]' - let word = expand(word) - endif - let word = shellescape(word, 1) - endif - call add(words, word) - endfor - let expanded_cmdline = join(words) - botright new - setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap - call setline(1, 'You entered: ' . a:cmdline) - call setline(2, 'Expanded to: ' . expanded_cmdline) - call append(line('$'), substitute(getline(2), '.', '=', 'g')) - silent execute '$read !'. expanded_cmdline - 1 -endfunction -command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand() - " "Text formatting " @@ -270,17 +259,13 @@ set expandtab " " Maps " -"inoremap -" Map ✠ (U+2720) to , so we have mapped to ✠ in iTerm2 and -" ✠ mapped back to in Vim. -"imap ✠ " easy align vmap (EasyAlign) " easy motion -map / (easymotion-sn) -omap / (easymotion-tn) +map // (easymotion-sn) +omap // (easymotion-tn) map l (easymotion-lineforward) map j (easymotion-j) map k (easymotion-k) @@ -303,12 +288,7 @@ nnoremap k nnoremap h nnoremap l -map - -"imap -"imap -"imap -"imap +"map nnoremap :cn nnoremap :cp @@ -324,20 +304,7 @@ map p :set paste! set mouse=a set ttymouse=xterm2 -"always center the screen -"nmap n n zz -"nmap N N zz -map zo zO "open full level all the time - -" resize current buffer by +/- 5 -nnoremap :vertical resize +3 -nnoremap :resize +3 -nnoremap :resize -3 -nnoremap :vertical resize -3 -"nnoremap hc :set cursorline! -"nnoremap hn :set nu! nnoremap d :set hlsearch! -" autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif " changes the cd to the directory of the current file except for /tmp/* nnoremap ,cd :cd %:p:h:pwd inoremap =InsertTabWrapper() @@ -348,6 +315,10 @@ inoremap =InsertTabWrapper() " Plugin settings " +" ctrl-space +" +let g:ctrlspace_default_mapping_key ='' + " NERDTree let g:NERDTreeMinimalUI = 1 let g:NERDTreeChDirMode=1 "2 would update the cwd anytime i change the root @@ -364,15 +335,6 @@ augroup end map m :NERDTreeToggle map n :NERDTreeFind -" CtrlP -let g:ctrlp_map = '' -let g:ctrlp_cmd = 'CtrlP' -let g:ctrlp_working_path_mode = 0 -let g:ctrlp_match_window_reversed = 0 -let g:ctrlp_extensions = ['tag'] -let g:ctrlp_custom_ignore = '\.git$' -map :CtrlPBuffer - " vim-rspec "let g:rspec_command = "!zeus rspec {spec}" "let g:rspec_command = "!zeus rescue rspec -f d -c {spec}" @@ -393,9 +355,6 @@ let g:netrw_sort_options = 'i' autocmd User Rails let b:surround_{char2nr('-')} = "<% \r %>" " displays <% %> correctly :set cpoptions+=$ " puts a $ marker for the end of words/lines in cw/c$ commands -" coffeescript.vim -"au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable - " vim-powerline.vim let g:Powerline_symbols='skwp' diff --git a/zsh.local b/zsh.local index fc464e3..9497651 100644 --- a/zsh.local +++ b/zsh.local @@ -10,13 +10,14 @@ export ZEUSSOCK=/tmp/zeus.sock export EDITOR='vim' export SHELL=/bin/zsh export GREP_OPTIONS='--color=auto -n' GREP_COLOR='7;35' +stty -ixon export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 export PATH="$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH" # Fix tmux vim color alias tmux="TERM=screen-256color-bce tmux" -LESSPIPE=`which src-hilite-lesspipe.sh` +export LESSPIPE=`which src-hilite-lesspipe.sh` export LESSOPEN="| ${LESSPIPE} %s" export LESS='-RNf' export WORK_PATHS=$HOME/wplace/bigwhale/codebases:$HOME/wplace/bigwhale