Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/indirect/dotfiles. strap.mikemcquaid.com
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385packadd chezmoi.vimruntime macros/matchit.vim " Enable matchit for textobj-rubyblocklet g:polyglot_disabled = ['autoindent']execute pathogen#infect()
set nocompatible " We're running Vim, not Vi!set laststatus=2 " Always show status at window bottomset encoding=utf-8 " Use UTF-8 internally, not latin1set wildmode=longest,list " Bash-like tab completion for exset history=10000 " Remember many ex commandsset noswapfile " No swap files, no swap file warningsset scrolloff=3 " Keep a few lines visible around cursorset showmatch " Flash matching brackets and parensset nrformats= " Zero-lead numbers are decimal, not octalset showcmd " Show partial commandsset noshowmode " Don't show default normal/insert messageset shm+=I " Don't show intro messageset number " Turn on line numbersset winheight=5set winminheight=5 " Never shrink splits below 5 linesset winheight=30 " Try for 30 line splits on focusset winwidth=15set winminwidth=15 " Never shrink splits below 15 columnsset winwidth=80 " Try for 80 column splits on focusset wildignore+=*/tmp/*,*.so,*.swp,*.zip " Ignore un-editable filesset nomodeline " Don't try to execute the entire file looking for modes
set backupdir=~/.vim/backup// " Backup files in case of crashesset directory=~/.vim/swap// " Swap files for saving atomically
set undofile " Save undo history across close/openset undodir=~/.vim/undo// " Where to save undo historiesset undolevels=1000 " How many undosset undoreload=10000 " Number of lines to save for undo
syntax on " Enable syntax highlightingfiletype on " Enable filetype detectionfiletype indent on " Enable filetype-specific indentingfiletype plugin on " Enable filetype-specific plugins
""""""""""""""""" COLOR SCHEME """""""""""""""""set background=dark
if &background == "light" " airline can't autodetect let g:airline_solarized_bg = 'light' " solarized doesn't detect gutter color highlight LineNr ctermfg=grey ctermbg=whiteelse " highlight LineNr ctermfg=10 ctermbg=0 " highlight LineNr ctermfg=10endif
if has("gui_running") set gcr=a:blinkon0 " Stop blinking the cursor ahhhhh set guifont=MenloNF-Regular:h14 colorscheme made-of-codeelse let g:solarized_termtrans = 1 colorscheme solarized
" Change cursor shape in different modes let &t_EI = "\033[2 q" " NORMAL █ let &t_SI = "\033[5 q" " INSERT | let &t_SR = "\033[3 q" " REPLACE _endif
if $COLORTERM ==# 'truecolor' set termguicolors
" Work around forced background color erase let &t_ut=''
" Correct RGB escape codes for vim inside tmux if !has('nvim') && $TERM ==# 'screen-256color' let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" endif
colorscheme made-of-code
" Light grey on dark grey line number gutter highlight LineNr ctermbg=16 ctermfg=10endif
let g:airline#extensions#tabline#enabled = 1let g:airline_powerline_fonts = 1let g:airline_theme = 'powerlineish'
let g:netrw_dirhistmax = 0let g:commentary_map_backslash = 0
let mapleader = " "let maplocalleader = " "" nnoremap <Space> :
" Leave insert mode on jkinoremap jk <Esc>
" mapping to make movements operate on 1 screen line in wrap modefunction! ScreenMovement(movement) if &wrap return "g" . a:movement else return a:movement endifendfunctiononoremap <silent> <expr> j ScreenMovement("j")onoremap <silent> <expr> k ScreenMovement("k")onoremap <silent> <expr> 0 ScreenMovement("0")onoremap <silent> <expr> ^ ScreenMovement("^")onoremap <silent> <expr> $ ScreenMovement("$")nnoremap <silent> <expr> j ScreenMovement("j")nnoremap <silent> <expr> k ScreenMovement("k")nnoremap <silent> <expr> 0 ScreenMovement("0")nnoremap <silent> <expr> ^ ScreenMovement("^")nnoremap <silent> <expr> $ ScreenMovement("$")
" Save on Return, but not inside quickfix windowsnnoremap <CR> :w<CR>augroup allow_cr_in_quickfix autocmd! autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>augroup END
" Remove search highlight and redraw screen on ^L" nnoremap <C-l> :<C-u>nohlsearch<CR><C-l>
nnoremap <Leader>ve :e $MYVIMRC<CR>augroup reload_vimrc autocmd! autocmd BufWritePost $MYVIMRC source $MYVIMRC autocmd BufWritePost $MYVIMRC AirlineRefreshaugroup END
" Force all .md files to be markdown, not modula2augroup markdown_filetype autocmd! autocmd BufNewFile,BufReadPost *.md set filetype=markdownaugroup END
" <Leader>p to paste from the OS X clipboard without paste indentnnoremap <Leader>p :read!pbpaste<CR>
" ,r to execute the current buffer as ruby, but only if unmappedfunction! RubyScratch() if &filetype ==# "" :set filetype=ruby :setlocal ts=2 sts=2 sw=2 endif :write !ruby --no-colorendfunctionif &filetype ==# "" nnoremap <Leader>r :call RubyScratch()<CR> " nnoremap <Leader>r :set filetype=ruby <bar> :setlocal ts=2 sts=2 sw=2 <bar> :write !ruby<CR>endif
" <Leader><Leader> to jump to the last edited filennoremap <Leader><Leader> <C-^>
" select previous paste with gVnoremap gV `[v`]
let g:ctrlp_use_caching = 0" let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'let g:ctrlp_prompt_mappings = { \ 'AcceptSelection("e")': ['<c-t>'], \ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'], \ }
let g:path_to_matcher = expand('<sfile>:p:h') . "/.bin/matcher"
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files . -co --exclude-standard']
let g:ctrlp_match_func = { 'match': 'GoodMatch' }
function! GoodMatch(items, str, limit, mmode, ispath, crfile, regex)
" Create a cache file if not yet exists let cachefile = ctrlp#utils#cachedir().'/matcher.cache' if !( filereadable(cachefile) && a:items == readfile(cachefile) ) call writefile(a:items, cachefile) endif if !filereadable(cachefile) return [] endif
" a:mmode is currently ignored. In the future, we should probably do " something about that. the matcher behaves like "full-line". let cmd = g:path_to_matcher.' --limit '.a:limit.' --manifest '.cachefile.' ' if !( exists('g:ctrlp_dotfiles') && g:ctrlp_dotfiles ) let cmd = cmd.'--no-dotfiles ' endif let cmd = cmd.a:str
return split(system(cmd), "\n")
endfunction
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)nmap ga <Plug>(EasyAlign)
cmap %% <C-R>=expand("%")<CR>" In visual mode, "." will, for each line, go into normal mode and execute the "."
" ===== Seeing Is Believing =====" Assumes you have a Ruby with SiB available in the PATH" If it doesn't work, you may need to `gem install seeing_is_believing`
" function! WithoutChangingCursor(fn)" let cursor_pos = getpos('.')" let wintop_pos = getpos('w0')" let old_lazyredraw = &lazyredraw" let old_scrolloff = &scrolloff" set lazyredraw
" call a:fn()
" call setpos('.', wintop_pos)" call setpos('.', cursor_pos)" redraw" let &lazyredraw = old_lazyredraw" let scrolloff = old_scrolloff" endfun
" function! SibAnnotateAll(scope)" call WithoutChangingCursor(function('execute', [a:scope . "!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-strategy chunk"]))" endfun
" function! SibAnnotateMarked(scope)" call WithoutChangingCursor(function('execute', [a:scope . "!seeing_is_believing --xmpfilter-style --timeout 12 --line-length 500 --number-of-captures 300 --alignment-strategy chunk"]))" endfun
" function! SibCleanAnnotations(scope)" call WithoutChangingCursor(function('execute', [a:scope . "!seeing_is_believing --clean"]))" endfun
" function! SibToggleMark()" let pos = getpos('.')" let line = getline(".")" if line =~ '^\s*$'" let line = '# => '" elseif line =~ '# =>'" let line = substitute(line, ' *# =>.*', '', '')" else" let line .= ' # => '" end" call setline('.', line)" call setpos('.', pos)" endfun
" Enable seeing-is-believing mappings only for Ruby" augroup seeingIsBelievingSettings " clear the settings if they already exist (so we don't run them twice) " autocmd! " autocmd FileType ruby nmap <buffer> <Leader>b :call SibAnnotateAll("%")<CR>; " autocmd FileType ruby nmap <buffer> <Leader>n :call SibAnnotateMarked("%")<CR>; " autocmd FileType ruby nmap <buffer> <Leader>v :call SibCleanAnnotations("%")<CR>; " autocmd FileType ruby nmap <buffer> <S-Enter> :call SibToggleMark()<CR>;
" autocmd FileType ruby vmap <buffer> <S-Enter> :call SibToggleMark()<CR>; " autocmd FileType ruby vmap <buffer> <Leader>b :call SibAnnotateAll("'<,'>")<CR>; " autocmd FileType ruby vmap <buffer> <Leader>n :call SibAnnotateMarked("'<,'>")<CR>; " autocmd FileType ruby vmap <buffer> <Leader>v :call SibCleanAnnotations("'<,'>")<CR>;" augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" OPEN FILES IN DIRECTORY OF CURRENT FILE""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""map <leader>e :edit %%map <leader>v :view %%
" Replace %/ with directory of current file (eg `:vs %/`)cmap %/ <C-R>=expand("%:p:h")."/"<CR>" Replace %% with current file (eg `:vs %%`)vnoremap . :norm.<CR>" Current file without extensioncnoremap %$ <C-R>=expand('%:t')<cr>
" Highlight colors in CSS fileslet g:colorizer_auto_filetype='css,scss,sass'
" Save buffers on swap or unfocusaugroup save_on_unfocus autocmd! autocmd BufLeave,FocusLost * silent! wallaugroup END
" Strip trailing whitespace on savefun! <SID>StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c)endfun
augroup strip_whitespace_on_save autocmd! autocmd FileType c,cpp,css,ruby,python,json,javascript,css,scss,html,haml,erb,bash,vim autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces() " or strip on save for any kind of file: " autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()augroup END
" Open all folds on file open"autocmd FileType * exe "normal zR"
" Open the current file in Marked 2nnoremap <leader>m :silent !open -a Marked\ 2.app '%:p'<cr>
" Search for selected text." http://vim.wikia.com/wiki/VimTip171let s:save_cpo = &cpo | set cpo&vimif !exists('g:VeryLiteral') let g:VeryLiteral = 0endiffunction! s:VSetSearch(cmd) let old_reg = getreg('"') let old_regtype = getregtype('"') normal! gvy if @@ =~? '^[0-9a-z,_]*$' || @@ =~? '^[0-9a-z ,_]*$' && g:VeryLiteral let @/ = @@ else let pat = escape(@@, a:cmd.'\') if g:VeryLiteral let pat = substitute(pat, '\n', '\\n', 'g') else let pat = substitute(pat, '^\_s\+', '\\s\\+', '') let pat = substitute(pat, '\_s\+$', '\\s\\*', '') let pat = substitute(pat, '\_s\+', '\\_s\\+', 'g') endif let @/ = '\V'.pat endif normal! gV call setreg('"', old_reg, old_regtype)endfunctionvnoremap <silent> * :<C-U>call <SID>VSetSearch('/')<CR>/<C-R>/<CR>vnoremap <silent> # :<C-U>call <SID>VSetSearch('?')<CR>?<C-R>/<CR>vmap <kMultiply> *nmap <silent> <Plug>VLToggle :let g:VeryLiteral = !g:VeryLiteral \\| echo "VeryLiteral " . (g:VeryLiteral ? "On" : "Off")<CR>if !hasmapto("<Plug>VLToggle") nmap <unique> <Leader>vl <Plug>VLToggleendiflet &cpo = s:save_cpo | unlet s:save_cpo
" Generate documentation tags automaticallysilent! helptags ALL
" Enable handlebars shortcutslet g:mustache_abbreviations = 1" Disable handlebars text objects (ie and ae conflict with vim-textobj-entire)let g:mustache_operators = 0
" store all project tags in a global directory instead of per-projectlet g:gutentags_cache_dir = expand('<sfile>:p:h') . "/.vim/tags/"
" set all .jsx files to be both JS and JSXautocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
" set all .jjdescription files to be JJ commit messagesautocmd BufNewFile,BufRead *.jjdescription set filetype=jjdescription
inoremap <M-o> <Esc>oinoremap <C-j> <Down>let g:ragtag_global_maps = 1
" Start interactive EasyAlign in visual mode (e.g. vipga)xmap ga <Plug>(EasyAlign)" Start interactive EasyAlign for a motion/text object (e.g. gaip)nmap ga <Plug>(EasyAlign)
nmap <leader>d :Dispatch
" Use FZF instead of CtrlPnmap <C-P> :FZF<CR>nmap <C-Y> :Buffers<CR>
nmap <leader>f :ALEFix<CR>