|
set nocompatible "Don't need to keep compatibility with Vi |
|
|
|
set shell=/bin/bash "Set it for default Linux setup |
|
if has("unix") |
|
let s:uname = system("uname") |
|
if s:uname == "Darwin\n" |
|
set shell=/usr/local/bin/bash "I think I need this because I'm running ZSH actually... set it to homebrew version here 4.x |
|
endif |
|
endif |
|
|
|
filetype plugin indent on "enable detection, plugins and indenting in one step |
|
syntax on "Turn on syntax highlighting |
|
" set synmaxcol=8000 "Don't try to highlight lines longer than 8000 characters |
|
set showcmd "show incomplete cmds down the bottom |
|
set noshowmode "don't show current mode down the bottom (set showmode does the opposite) |
|
set showmatch "Set show matching parenthesis |
|
set noexrc "Don't use the local config |
|
set virtualedit=all "Allow the cursor to go in to 'invalid' places |
|
set incsearch "Find the next match as we type the search |
|
set hlsearch "Hilight searches by default |
|
set ignorecase "Ignore case when searching |
|
set smartcase " ...unless they contain at least one capital letter |
|
set shiftwidth=2 "Number of spaces to use in each autoindent step |
|
set shiftround "When at 3 spaces, and I hit > ... go to 4, not 5 |
|
set tabstop=2 "Two tab spaces |
|
set softtabstop=2 "Number of spaces to skip or insert when <BS>ing or <Tab>ing |
|
set expandtab "Spaces instead of tabs for better cross-editor compatibility |
|
set smarttab "Use shiftwidth and softtabstop to insert or delete (on <BS>) blanks |
|
set nowrap "No wrapping |
|
set copyindent "Copy the previous indentation on autoindenting |
|
set backspace=indent,eol,start "Allow backspacing over everything in insert mode |
|
set noerrorbells "Don't make noise |
|
set visualbell "Do blink the screen |
|
set wildmenu "Make tab completion act more like bash |
|
set wildmode=list:longest "Tab complete to longest common string, like bash |
|
" set mouse-=a "Disable mouse automatically entering visual mode |
|
set mouse=a "Enable mouse support in the terminal VIM and activate visual mode with dragging |
|
set bs=2 "This influences the behavior of the backspace option. See :help 'bs' for more details |
|
set number "Show line numbers |
|
set cmdheight=2 "Make the command line a little taller to hide 'press enter to viem more' text |
|
set ttyfast "Improves screen redraw |
|
set lazyredraw |
|
set splitbelow "New splits will be created below the current split |
|
set splitright "New splits will be created to the right of the current split |
|
set confirm "Ask to save changes |
|
set encoding=utf-8 "Set utf-8 encoding |
|
set pastetoggle=<F2> "Press F2 in insert mode to preserve tabs when pasting from clipboard into terminal |
|
set updatetime=750 "Should 'fix' git-gutter weird highlighting issues |
|
set notimeout ttimeout ttimeoutlen=10 "Quckly time out on keycodes, but never time out on mappings |
|
|
|
set t_Co=256 "256 colors support |
|
|
|
if has("unix") |
|
let s:uname = system("uname") |
|
if s:uname != "Darwin\n" |
|
let g:solarized_termcolors=16 |
|
endif |
|
endif |
|
|
|
set background=dark |
|
colorscheme solarized |
|
|
|
" Toggles the background from dark to light |
|
call togglebg#map("<F5>") |
|
|
|
set wildignore+=*/production_data/*,*/db/dumps/*,*/coverage/*,*/accredited_investor_questionnaires/*,*/accredited_verification_pdfs/*,*/HTML_DEMOS/*,*/docusign_docs/*,*/cookbooks/*,*/public/uploads/*,*/public/images/*,*/vim_sessions/*,*/node_modules/*,*/bower_components/*,*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux |
|
runtime macros/matchit.vim "Extend % for matching brackets, if/end, and more |
|
|
|
" autoread and autowrite http://albertomiorin.com/blog/2012/12/10/autoread-and-autowrite-in-vim/ |
|
augroup save |
|
au! |
|
au FocusLost * wall |
|
augroup END |
|
set nohidden |
|
set nobackup |
|
set noswapfile |
|
set nowritebackup |
|
set autoread |
|
set autowrite |
|
set autowriteall |
|
|
|
" persistent-undo |
|
set undodir=$HOME/.vim/undo |
|
set undofile |
|
|
|
" Resize splits when the window is resized |
|
au VimResized * :wincmd = |
|
|
|
let mapleader = "," "remap leader to ',' which is much easier than '\' |
|
let maplocalleader = "\\" "add a local leader of '\' |
|
|
|
if has("gui_macvim") |
|
set guifont=Monaco\ for\ Powerline:h12 |
|
endif |
|
|
|
" toggle hide numbers |
|
map <leader>1 :set nonumber! number?<CR> |
|
|
|
" Open NERDTree with [<leader>d] |
|
map <Leader>d :NERDTreeMirrorToggle<CR> |
|
" Show current file in the NERDTree hierarchy |
|
map <Leader>D :NERDTreeFind<CR> |
|
|
|
let NERDTreeMinimalUI=1 |
|
let NERDTreeDirArrows=1 |
|
let NERDTreeWinSize = 51 |
|
let NERDTreeShowLineNumbers=1 |
|
let g:nerdtree_tabs_focus_on_files=1 |
|
let g:nerdtree_tabs_open_on_console_startup=1 |
|
let g:nerdtree_tabs_smart_startup_focus=2 |
|
" list of file types I don't want to auto-open nerdtree for |
|
autocmd FileType vim,tmux,gitcommit,gitconfig,gitrebase let g:nerdtree_tabs_open_on_console_startup=0 |
|
autocmd BufNewFile,BufRead vundle let g:nerdtree_tabs_open_on_console_startup=0 |
|
|
|
" With tmux-plugins/vim-tmux-focus-events, vim will load up a file on focus so write the file when switching away |
|
let g:tmux_navigator_save_on_switch = 1 |
|
|
|
let g:eighties_bufname_additional_patterns = ['fugitiveblame','locationlist'] " Don't try to auto-resize a fugitive blame split to 80 chars |
|
|
|
let NERDSpaceDelims=1 " For nerdcommenter, add one space after comment char |
|
|
|
" swap current with next word |
|
nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>:noh<CR> |
|
|
|
|
|
" CodeClimate Bindings |
|
nmap <Leader>aa :CodeClimateAnalyzeProject<CR> |
|
nmap <Leader>ao :CodeClimateAnalyzeOpenFiles<CR> |
|
nmap <Leader>af :CodeClimateAnalyzeCurrentFile<CR> |
|
|
|
|
|
" CtrlP |
|
" -------------- |
|
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' " Exclude files from ctrl-p finder |
|
" let g:ctrlp_custom_ignore = { |
|
" \ 'dir': '\v[\/]\.(git|hg|svn)$', |
|
" \ 'file': '\v\.(exe|so|dll)$', |
|
" \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', |
|
" \ } |
|
let g:ctrlp_map = '<c-f>' " Change default mapping |
|
|
|
" allows opening a split from ctrlp with <c-i>, since using 'i' from NERDTree |
|
" is how to open a horizontal split there. Keep em the same. |
|
let g:ctrlp_prompt_mappings = { |
|
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>', '<c-i>'] |
|
\ } |
|
|
|
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp' |
|
if executable('ag') |
|
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden --follow --ignore .git -g ""' |
|
endif |
|
|
|
" Open splits from quickfix window like you can in ctrlp |
|
let g:qfenter_vopen_map = ['<C-v>'] |
|
let g:qfenter_hopen_map = ['<C-CR>', '<C-s>', '<C-x>', '<C-i>'] |
|
let g:qfenter_topen_map = ['<C-t>'] |
|
" let g:ctrlp_show_hidden = 1 |
|
|
|
" Find in project (async!) |
|
" let agrep_win_sp_mod = 'botright vert' |
|
" nnoremap <Leader><C-f> :Agrep -r <space>.<C-Left><Left> |
|
|
|
|
|
" Ack in Project. AckG matches file names in the project, regular Ack looks inside those files |
|
map <Leader><C-t> :AckG<space> |
|
" map <Leader><C-f> :Ack!<space> |
|
" map <Leader><C-f> :Ag<space> |
|
let g:ackprg = 'ag' |
|
|
|
" Split rightward so as not to displace a left NERDTree |
|
let g:ack_mappings = { |
|
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p', |
|
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J', |
|
\ '<cr>': ':NERDTreeMirrorToggle<CR><CR>:NERDTreeMirrorToggle<CR><C-W>l' } |
|
|
|
nnoremap <Leader><C-f> :tabnew <Bar> Ack!<Space> |
|
|
|
|
|
" Navigate quickfix of found items |
|
" look in ~/.vim/after/plugin/mystuff.vim - needed to override unimpaired |
|
|
|
|
|
" vimwiki |
|
let wiki0 = {} |
|
let wiki0.path = '~/vimwiki/' |
|
let wiki0.path_html = '~/vimwiki_html/' |
|
let wiki0.auto_toc = 1 |
|
|
|
let wiki1 = {} |
|
let wiki1.path = '~/vimwiki_headway/' |
|
let wiki1.path_html = '~/vimwiki_headway_html/' |
|
let wiki1.auto_toc = 1 |
|
|
|
" Run multiple wikis |
|
let g:vimwiki_list = [wiki0, wiki1] |
|
|
|
au BufRead,BufNewFile *.wiki set filetype=vimwiki |
|
|
|
" Open diary with \d |
|
:autocmd FileType vimwiki map <localleader>d :VimwikiMakeDiaryNote<CR>:Calendar<CR> |
|
|
|
au! BufRead ~/vimwiki_headway/index.wiki !cd ~/vimwiki_headway;git pull |
|
" au! BufWritePost ~/vimwiki_headway/* !cd ~/vimwiki_headway;git add -A;git commit -m "Auto commit + push.";git push |
|
|
|
" let g:vimwiki_folding='expr' |
|
|
|
|
|
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] |
|
" | | | | | | | | | | | |
|
" | | | | | | | | | | + current |
|
" | | | | | | | | | | column |
|
" | | | | | | | | | +-- current line |
|
" | | | | | | | | +-- current % into file |
|
" | | | | | | | +-- current syntax in |
|
" | | | | | | | square brackets |
|
" | | | | | | +-- current fileformat |
|
" | | | | | +-- number of lines |
|
" | | | | +-- preview flag in square brackets |
|
" | | | +-- help flag in square brackets |
|
" | | +-- readonly flag in square brackets |
|
" | +-- modified flag in square brackets |
|
" +-- full path to file in the buffer |
|
|
|
|
|
"SHOW INVISIBLES |
|
"--------------- |
|
"Shortcut to toggle `set list` which turns on and off the whitespace markers |
|
nmap <leader>il :set list!<CR> |
|
"Use the same symbols as TextMate for tabstops and EOLs |
|
set listchars=tab:▸\ ,eol:¬ |
|
|
|
let g:StripperIgnoreFileTypes = [] |
|
|
|
"Right margin settings for vim 7.2 or greater |
|
if version > 702 |
|
set colorcolumn=81 |
|
endif |
|
|
|
au BufNewFile,BufRead COMMIT_EDITMSG setlocal colorcolumn=51 |
|
|
|
|
|
" Better split management, kept in sync with tmux' mappings of (<prefix>| and <prefix>-) |
|
noremap <leader>- :sp<CR><C-w>j |
|
noremap <leader>\| :vsp<CR><C-w>l |
|
|
|
|
|
" Allow resizing splits with =/- for up/down and +/_ right/left (repeatable w/hold too) |
|
if bufwinnr(1) |
|
map = <C-W>+ |
|
map - <C-W>- |
|
map _ <C-W>> |
|
map + <C-W>< |
|
endif |
|
|
|
|
|
"TOGGLE RELATIVE NUMBERING |
|
"------------------------- |
|
function! NumberToggle() |
|
if(&relativenumber == 1) |
|
set norelativenumber |
|
set number |
|
else |
|
set relativenumber |
|
endif |
|
endfunc |
|
|
|
nnoremap <leader>l :call NumberToggle()<CR> |
|
|
|
let g:debugMode = 0 |
|
|
|
" reload current top window/tab of chrome |
|
map <leader>rr :ChromeReload<CR> |
|
let g:returnApp = "iTerm" |
|
|
|
|
|
" Indent guides turned on with <leader>ig |
|
let g:indent_guides_start_level=1 |
|
let g:indent_guides_guide_size=1 |
|
|
|
|
|
"Search and replace the word under the cursor with whatever you type in |
|
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/ |
|
|
|
"Search and replace only within a given selection. This DOES NOT replace all |
|
" instances on the line that the highlight is on, which is why it's awesome. |
|
vnoremap <Leader>S :s/\%V//g<Left><Left><Left> |
|
|
|
" Better search with insearch |
|
map / <Plug>(incsearch-forward) |
|
map ? <Plug>(incsearch-backward) |
|
map g/ <Plug>(incsearch-stay) |
|
|
|
|
|
" Allow for typing various quit cmds while accidentally capitalizing a letter |
|
command! -bar Q quit "Allow quitting using :Q |
|
command! -bar -bang Q quit<bang> "Allow quitting without saving using :Q! |
|
command! -bar QA qall "Quit all buffers |
|
command! -bar Qa qall "Quit all buffers |
|
command! -bar -bang QA qall<bang> "Allow quitting without saving using :Q! |
|
command! -bar -bang Qa qall<bang> "Allow quitting without saving using :Q! |
|
" NOTE - the above has nothing to do with the quit commands below |
|
|
|
|
|
" Make Q useful and avoid the confusing Ex mode. |
|
" Pressing Q with this mapping does nothing intentionally |
|
noremap Q <nop> |
|
|
|
" Close window. |
|
noremap QQ :q<CR> |
|
|
|
" close and write |
|
noremap WQ :wq<CR> |
|
|
|
" Close all. |
|
noremap QA :qa<CR> |
|
|
|
" Close, damn you! |
|
noremap Q! :q!<CR> |
|
|
|
|
|
"I never much liked the S command in normal mode. Substitutes the whole line after a motion. So we'll disable it here. |
|
nmap S <nop> |
|
|
|
|
|
" Session management |
|
" ----------------- |
|
" Create new session |
|
nmap SC :Obsess ~/.vim/sessions/ |
|
" Open the last saved session |
|
nmap SO :so ~/.vim/sessions/ |
|
nmap SQ :Obsess!<CR> |
|
|
|
|
|
" Save |
|
" Hit SS in insert or normal mode to save |
|
" noremap SS :w<CR>:SyntasticCheck<CR> |
|
" inoremap SS <Esc>:w<CR>:SyntasticCheck<CR> |
|
noremap SS :w<CR> |
|
inoremap SS <Esc>:w<CR> |
|
|
|
|
|
"Save the current file even if you don't have permission to do so |
|
map W!! :w !sudo tee % > /dev/null<CR> |
|
cmap w!! w !sudo tee % >/dev/null |
|
|
|
|
|
" This switches the cursor into a pipe when in insert mode tmux will only |
|
" forward escape sequences to the terminal if surrounded by a DCS sequence |
|
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users |
|
if has('nvim') |
|
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 |
|
else |
|
if exists('$TMUX') |
|
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" |
|
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" |
|
else |
|
let &t_SI = "\<Esc>]50;CursorShape=1\x7" |
|
let &t_EI = "\<Esc>]50;CursorShape=0\x7" |
|
endif |
|
endif |
|
|
|
|
|
if has("unix") |
|
let s:uname = system("uname") |
|
if s:uname == "Linux\n" |
|
" Remote Clipboard |
|
function! PropagatePasteBufferToOSX() |
|
let @n=getreg('"') |
|
|
|
call system('pbcopy-remote', @n) |
|
echo "done" |
|
endfunction |
|
|
|
function! PopulatePasteBufferFromOSX() |
|
let @" = system('pbpaste-remote') |
|
echo "done" |
|
endfunction |
|
|
|
nnoremap <leader>3 :call PopulatePasteBufferFromOSX()<cr> |
|
nnoremap <leader>2 :call PropagatePasteBufferToOSX()<cr> |
|
|
|
nnoremap yy yy:call PropagatePasteBufferToOSX()<cr> |
|
|
|
function! YRRunAfterMaps() |
|
nnoremap Y :<C-U>YRYankCount 'y$'<CR> <bar> :call PropagatePasteBufferToOSX()<CR> |
|
vnoremap y y:call PropagatePasteBufferToOSX()<CR> |
|
endfunction |
|
endif |
|
endif |
|
|
|
|
|
" Indent pastes properly |
|
nnoremap <leader>pi p`[v`]= |
|
|
|
|
|
"Update CTags |
|
nnoremap <silent> <leader>ct :!$(.git/hooks/ctags &)<cr> <bar> :redraw!<cr> |
|
|
|
" ExCTags window (requires http://ctags.sourceforge.net/) |
|
nmap <F8> :TagbarToggle<CR> |
|
let g:tagbar_left = 1 |
|
let g:tagbar_autofocus = 1 |
|
let g:tagbar_compact = 1 |
|
let g:tagbar_autoclose = 1 |
|
|
|
" open ctag in tab/vertical split |
|
map <leader><C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> |
|
map <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> |
|
|
|
" NOTE: Jump to previous file with <leader><C-^> |
|
|
|
|
|
" set text wrapping toggles |
|
nmap <silent> <leader><Leader>tw :set invwrap<CR>:set wrap?<CR> |
|
|
|
" Adjust viewports to the same size |
|
map <Leader>= <C-w>= |
|
|
|
|
|
|
|
"" Move by visual screen lines instead of file lines. (aka when navigating wrapped text) |
|
"" http://vim.wikia.com/wiki/Moving_by_screen_lines_instead_of_file_lines |
|
" TODO: Determine if this is still necessary |
|
noremap [A gk |
|
noremap [B gj |
|
inoremap [B <C-o>gj |
|
inoremap [A <C-o>gk |
|
|
|
" mapping to make movements operate on 1 screen line in wrap mode |
|
" TODO: See if pencil works fine with this commented out |
|
function! ScreenMovement(movement) |
|
if &wrap |
|
return "g" . a:movement |
|
else |
|
return a:movement |
|
endif |
|
endfunction |
|
onoremap <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("$") |
|
|
|
|
|
|
|
" Tab/shift-tab to indent/outdent in visual mode. |
|
vnoremap <Tab> >gv |
|
vnoremap <S-Tab> <gv |
|
" Keep selection when indenting/outdenting. |
|
vnoremap > >gv |
|
vnoremap < <gv |
|
|
|
|
|
|
|
"NOTES ON ARROW KEYS |
|
"http://od-eon.com/blogs/liviu/macos-vim-controlarrow-functionality/ |
|
"arrow keys, up=A, down=B, right=C and left=D |
|
"<C-Up> == <Esc>[A |
|
"END NOTES |
|
|
|
|
|
|
|
" TABS |
|
" ---- |
|
" Load up all buffers into tabs |
|
nmap <localleader>bt :tab sball<CR> |
|
|
|
" previous tab(shift-9), next tab (shift-0) |
|
nnoremap ( :tabp<CR> |
|
nnoremap ) :tabn<CR> |
|
|
|
|
|
" switch tab order with Ctrl+<left>/<right> |
|
map <Esc>[C :tabm +1<Esc> |
|
map <Esc>[D :tabm -1<Esc> |
|
|
|
|
|
function! MoveToPrevTab() |
|
"there is only one window |
|
if tabpagenr('$') == 1 && winnr('$') == 1 |
|
return |
|
endif |
|
"preparing new window |
|
let l:tab_nr = tabpagenr('$') |
|
let l:cur_buf = bufnr('%') |
|
if tabpagenr() != 1 |
|
close! |
|
if l:tab_nr == tabpagenr('$') |
|
tabprev |
|
endif |
|
sp |
|
else |
|
close! |
|
exe "0tabnew" |
|
endif |
|
"opening current buffer in new window |
|
exe "b".l:cur_buf |
|
endfunc |
|
|
|
function! MoveToNextTab() |
|
"there is only one window |
|
if tabpagenr('$') == 1 && winnr('$') == 1 |
|
return |
|
endif |
|
"preparing new window |
|
let l:tab_nr = tabpagenr('$') |
|
let l:cur_buf = bufnr('%') |
|
if tabpagenr() < tab_nr |
|
close! |
|
if l:tab_nr == tabpagenr('$') |
|
tabnext |
|
endif |
|
sp |
|
else |
|
close! |
|
tabnew |
|
endif |
|
"opening current buffer in new window |
|
exe "b".l:cur_buf |
|
endfunc |
|
|
|
" switch tab order with Ctrl+<up>/<down> |
|
map <Esc>[B :call MoveToNextTab()<CR> |
|
map <Esc>[A :call MoveToPrevTab()<CR> |
|
|
|
|
|
|
|
|
|
if has('nvim') |
|
" Use unnamed registers for clipboard |
|
set clipboard+=unnamedplus |
|
else |
|
" This allows you to share Vim's clipboard with OS X. |
|
set clipboard=unnamed |
|
endif |
|
|
|
|
|
|
|
" Alignment stuff |
|
"if exists(":Tabularize") |
|
nmap <Leader>a= :Tabularize /=<CR> |
|
vmap <Leader>a= :Tabularize /=<CR> |
|
nmap <Leader>a: :Tabularize /:\zs<CR> |
|
vmap <Leader>a: :Tabularize /:\zs<CR> |
|
|
|
|
|
" Triggers align of cucumber tables when you close it out with a | and have at |
|
" least two lines. Thanks tpope :) |
|
function! s:align() |
|
let p = '^\s*|\s.*\s|\s*$' |
|
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) |
|
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) |
|
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) |
|
Tabularize/|/l1 |
|
normal! 0 |
|
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) |
|
endif |
|
endfunction |
|
|
|
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a |
|
|
|
|
|
|
|
" Hashrocket mappings |
|
" ------------------ |
|
" inserts hashrocket in insert mode |
|
inoremap <c-l> => |
|
" converts visually selected hashrockets to 1.9 syntax |
|
vnoremap <c-l> :s/\:\([a-zA-Z_]*\)\s=>/\1\:/g<cr>:noh<cr> |
|
|
|
|
|
|
|
"fold settings |
|
" ------------ |
|
" toggle folding with za. |
|
" fold everything with zM |
|
" unfold everything with zR. |
|
" zm and zr can be used too |
|
" set foldmethod=syntax "fold based on syntax (except for haml below) |
|
" set foldnestmax=10 "deepest fold is 10 levels |
|
" set nofoldenable "dont fold by default |
|
autocmd BufNewFile,BufRead *.haml setl foldmethod=indent nofoldenable |
|
autocmd! FileType nofile setl foldmethod=indent nofoldenable |
|
set foldlevelstart=99 |
|
|
|
" Space to toggle folds. |
|
nnoremap <Space> za |
|
vnoremap <Space> za |
|
|
|
" Toggles folds being enabled for this vim session |
|
function! FoldToggle() |
|
if(&foldenable == 1) |
|
au WinEnter * set nofen |
|
au WinLeave * set nofen |
|
au BufEnter * set nofen |
|
au BufLeave * set nofen |
|
:set nofen |
|
else |
|
au WinEnter * set fen |
|
au WinLeave * set fen |
|
au BufEnter * set fen |
|
au BufLeave * set fen |
|
:set fen |
|
endif |
|
endfunc |
|
|
|
nnoremap <Leader>nf :call FoldToggle()<CR> |
|
|
|
|
|
" Buffrgator settings |
|
let g:buffergator_viewport_split_policy="B" |
|
let g:buffergator_split_size=10 |
|
let g:buffergator_suppress_keymaps=1 |
|
let g:buffergator_sort_regime = "mru" |
|
map <Leader>b :BuffergatorToggle<cr> |
|
|
|
" go to the 81th column |
|
noremap <leader>8 81\| |
|
|
|
" commands from insert mode |
|
inoremap II <Esc>I |
|
inoremap AA <Esc>A |
|
|
|
" Pull up the TODO And NOTE and FIXME definitions from the whole app |
|
let g:TagmaTasksPrefix = '<localleader><localleader>t' |
|
let g:TagmaTasksHeight = 10 |
|
map <Leader><Leader>tt :TagmaTasks * app/** config/** db/** doc/** features/** lib/** public/** spec/** test/** vendor/**<CR> |
|
|
|
|
|
" Coverage via Cadre/github.com/killphi/vim-legend |
|
let g:legend_active_auto = 0 |
|
let g:legend_hit_color = "ctermfg=64 cterm=bold gui=bold guifg=Green" |
|
let g:legend_ignored_sign = "◌" |
|
let g:legend_ignored_color = "ctermfg=234" |
|
let g:legend_mapping_toggle = '<Leader>cv' |
|
let g:legend_mapping_toggle_line = '<localleader>cv' |
|
|
|
|
|
" vim-rspec & cucumber test runner mappings <leader>T |
|
let VimuxHeight = "33" "this is percentage |
|
let VimuxOrientation = "h" |
|
let VimuxUseNearestPane = 1 |
|
|
|
function! DetermineSpecRunString(focus, coverage) |
|
let test_kind = (&filetype == 'cucumber' ? 'cucumber' : 'rspec') |
|
let coverage = (a:coverage == 'coverage' ? 'COVERAGE=true bundle exec ' : ' ') |
|
let focus = (a:focus == 'focus' ? ':' . line('.') : '') |
|
return 'clear; ' . coverage . test_kind . " " . expand('%') . focus |
|
endfunction |
|
|
|
function! RunCurrentSpec(focus, coverage) |
|
let spec_run_string = DetermineSpecRunString(a:focus, a:coverage) |
|
call VimuxRunCommand(spec_run_string) |
|
endfunction |
|
|
|
"""""""""" This is crazy, but keep it around in case...it does work |
|
" :autocmd FileType jasmine.javascript map <leader>t :call VimuxRunCommand('clear; npm test')<CR> |
|
" :autocmd FileType jasmine.javascript map <leader>T :s/it(/fit(<CR>:w<CR>:noh<CR>:call VimuxRunCommand('clear; npm test')<CR>:sleep 1<CR>:s/fit(/it(<CR>:sleep 500m<CR>:w<CR>:noh<CR> |
|
"""""""""" This is crazy, but keep it around in case...it does work |
|
|
|
let test#strategy = "vimux" |
|
let test#javascript#jasmine#executable = 'node_modules/.bin/babel-node ./node_modules/.bin/jasmine' |
|
autocmd FileType jasmine.javascript nmap <silent> <leader>T :TestNearest<CR> |
|
autocmd FileType jasmine.javascript nmap <silent> <leader>t :TestFile<CR> |
|
" :autocmd FileType jasmine.javascript nmap <silent> <leader>a :TestSuite<CR> |
|
autocmd FileType jasmine.javascript nmap <silent> <leader>l :TestLast<CR> |
|
" :autocmd FileType jasmine.javascript nmap <silent> <leader>g :TestVisit<CR> |
|
|
|
map <Leader>t :call RunCurrentSpec('all', '')<CR> |
|
map <Leader>C :call RunCurrentSpec('all', 'coverage')<CR> |
|
map <Leader>T :call RunCurrentSpec('focus', '')<CR> |
|
map <leader>u :call VimuxRunCommand('clear; cucumber --profile syntastic --dry-run ' . expand('%'))<CR> |
|
map <leader>U :call VimuxRunCommand('clear; cucumber --profile syntastic --dry-run ' . expand('%') . ':' . line('.'))<CR> |
|
|
|
" for rspec.vim (syntax highlighting enhancements for rspec) |
|
autocmd BufReadPost,BufNewFile *_spec.rb set syntax=rspec |
|
|
|
|
|
" ,q to toggle quickfix window (where you have stuff like GitGrep) |
|
" ,oq to open it back up (rare) |
|
nmap <silent> ,cq :cclose<CR> |
|
nmap <silent> ,co :copen<CR> |
|
|
|
|
|
" Set super tab to start completion with ctrl+j and move down the list with |
|
" more j's, move back with ctrl+k |
|
let g:SuperTabMappingForward = '<c-k>' |
|
let g:SuperTabMappingBackward = '<c-j>' |
|
|
|
" Toggle spellcheck with F6 (highlighted and underlined in stark WHITE) |
|
" ----------------- |
|
" z= - view spelling suggestions for a misspelled word |
|
" zg - add word to dictionary |
|
" zug - undo add word to dict |
|
hi SpellBad cterm=underline ctermfg=white |
|
nn <F6> :setlocal spell! spell?<CR> |
|
|
|
map <F11> "dyiw:call MacDict(@d)<CR> |
|
|
|
" YankRing plugin to manage yanked/deleted buffers |
|
nnoremap <silent> <F7> :YRShow<CR> |
|
let g:yankring_history_file = '.yankring-history' |
|
" let g:yankring_zap_keys = 'f F t T / ?' |
|
|
|
" STOP the help from being so... HELPFULL ;) |
|
inoremap <F1> <ESC> |
|
nnoremap <F1> <ESC> |
|
vnoremap <F1> <ESC> |
|
|
|
" Exit out of insert with jj |
|
inoremap jj <ESC> |
|
|
|
" Dig through the tree of undo possibilities for your current file |
|
nnoremap <F3> :GundoToggle<CR> |
|
let g:gundo_right = 1 |
|
let g:gundo_preview_bottom=1 |
|
let g:gundo_preview_height = 40 |
|
|
|
|
|
" Disable some built in commands I don't like |
|
" map K <Nop> |
|
|
|
|
|
" Ensures color scheme works for the gutter diff indicators |
|
highlight clear SignColumn "Show the gutter color the same as the number column color |
|
|
|
|
|
" Load up the vimrc_main file (this file) in vim to edit it |
|
nnoremap <Leader>ev :tabnew ~/.vim/vimrc_main<CR> :NERDTreeClose<CR> |
|
|
|
" Load up the ~/.tmux.conf file in vim to edit it |
|
nnoremap <Leader>et :tabnew ~/.tmux.conf<CR> |
|
|
|
" Automatically source this file after it's saved |
|
autocmd! BufWritePre vimrc_main :NERDTreeClose |
|
autocmd! BufWritePost vimrc_main source % |
|
|
|
"From Gary Bernhardt |
|
function! ShowRoutes() |
|
" Requires 'scratch' plugin |
|
:topleft 40 :split __Routes__ |
|
" Make sure Vim doesn't write __Routes__ as a file |
|
:set buftype=nofile |
|
" set a filetype so we can fold the output (to avoid the error / warning) |
|
:set filetype=nofile |
|
" Delete everything |
|
:normal 1GdG |
|
" Put routes output in buffer (NOTE: (2013-09-10) jonk => changed to " bin/rake) |
|
:0r! bin/rake -s routes |
|
" |
|
" Size window to number of lines (1 plus rake output length) |
|
" :exec ":normal " . line("$") . "_ " |
|
" |
|
" Move cursor to bottom |
|
:normal 1GG |
|
" Delete empty trailing line |
|
:normal dd |
|
" Expand all folds |
|
:normal zR |
|
endfunction |
|
map <leader>gR :call ShowRoutes()<cr> |
|
map <leader>gr :topleft 40 :split config/routes.rb<cr> |
|
map <leader>gg :topleft 40 :split Gemfile<cr> |
|
|
|
|
|
"SEARCH OPTIONS |
|
"-------------- |
|
" turn highlighting off after a search (and / or turn off highlights) |
|
noremap <silent> <leader><space> :noh<cr>:call clearmatches()<cr> |
|
|
|
" keeps cursor on star search highlight |
|
let g:indexed_search_dont_move=1 |
|
|
|
|
|
" http://vim.wikia.com/wiki/Make_search_results_appear_in_the_middle_of_the_screen |
|
nnoremap <silent> <F4> :call <SID>SearchMode()<CR> |
|
function! s:SearchMode() |
|
" if !exists('s:searchmode') || s:searchmode == 0 |
|
if !exists('s:searchmode') || s:searchmode == 2 |
|
echo 'Search next: scroll hit to middle if not on same page' |
|
nnoremap <silent> n n:call <SID>MaybeMiddle()<CR> |
|
nnoremap <silent> N N:call <SID>MaybeMiddle()<CR> |
|
let s:searchmode = 1 |
|
" elseif s:searchmode == 1 |
|
else |
|
echo 'Search next: scroll hit to middle' |
|
nnoremap n nzz |
|
nnoremap N Nzz |
|
let s:searchmode = 2 |
|
" else |
|
" echo 'Search next: normal' |
|
" nunmap n |
|
" nunmap N |
|
" let s:searchmode = 0 |
|
endif |
|
endfunction |
|
|
|
" If cursor is in first or last line of window, scroll to middle line. |
|
function! s:MaybeMiddle() |
|
if winline() == 1 || winline() == winheight(0) |
|
normal! zz |
|
endif |
|
endfunction |
|
|
|
augroup searchmode |
|
au! |
|
au BufRead * call s:SearchMode() |
|
augroup END |
|
|
|
|
|
" pretty up JSON data |
|
nnoremap <Leader>j !!python -m json.tool<CR> |
|
nnoremap <Leader>J :%!python -m json.tool<CR> |
|
vnoremap <Leader>j :!python -m json.tool<CR> |
|
|
|
" Easy filetype switching (good for commenting code in haml filters) |
|
nnoremap _md :set ft=markdown<CR> |
|
nnoremap _hm :set ft=haml<CR> |
|
nnoremap _eb :set ft=eruby<CR> |
|
nnoremap _js :set ft=javascript<CR> |
|
nnoremap _cs :set ft=coffee<CR> |
|
nnoremap _d :set ft=diff<CR> |
|
|
|
|
|
" Gist stuff for mattn/gist-vim |
|
let g:gist_clip_command = 'pbcopy' |
|
let g:gist_detect_filetype = 1 |
|
let g:gist_open_browser_after_post = 1 |
|
let g:gist_post_private = 1 |
|
|
|
|
|
|
|
" Make sure Vim returns to the same line when you reopen a file. |
|
augroup line_return |
|
au! |
|
au BufReadPost * |
|
\ if line("'\"") > 0 && line("'\"") <= line("$") | |
|
\ execute 'normal! g`"zvzz' | |
|
\ endif |
|
augroup END |
|
|
|
|
|
" DRAG IN VISUAL MODE |
|
" ------------------- |
|
" <m-j> and <m-k> to drag lines in any mode (m is alt/option) |
|
" this is the textmate move lines around thing that I used to do do with arrow |
|
" keys but less fragile because it works in tmux or not |
|
noremap ∆ :m+<CR> |
|
noremap ˚ :m-2<CR> |
|
inoremap ∆ <Esc>:m+<CR> |
|
inoremap ˚ <Esc>:m-2<CR> |
|
vnoremap ∆ :m'>+<CR>gv |
|
vnoremap ˚ :m-2<CR>gv |
|
|
|
" markdown |
|
map <localleader>m :MarkedOpen!<CR> |
|
let g:marked_app = "Marked" " Need to specify v1 of the app |
|
let g:vim_markdown_folding_disabled = 1 |
|
" let g:vim_markdown_conceal = 0 |
|
let g:vim_markdown_frontmatter = 1 |
|
" Syntax highlight code in markdown files |
|
let g:markdown_fenced_languages = ['javascript', 'js=javascript', 'json=javascript', 'ruby'] |
|
let g:vim_markdown_emphasis_multiline = 0 |
|
let g:vim_markdown_toc_autofit = 1 |
|
|
|
" Disable ]c for move to current header of vim-markdown |
|
nmap <Plug>Markdown_MoveToCurHeader <Plug>Markdown_MoveToCurHeader |
|
|
|
function! s:Toc() |
|
if &filetype == 'markdown' |
|
:normal SS |
|
endif |
|
endfunction |
|
autocmd VimEnter *.m* call s:Toc() |
|
autocmd BufReadPost *.m* call s:Toc() |
|
autocmd BufWinEnter *.m* call s:Toc() |
|
|
|
augroup ft_markdown |
|
au! |
|
|
|
au BufNewFile,BufRead *.m*down setlocal filetype=markdown foldlevel=1 |
|
|
|
" Use <localleader>1/2/3 to add headings. |
|
au Filetype markdown nnoremap <buffer> <localleader>1 mzI# <ESC> |
|
au Filetype markdown nnoremap <buffer> <localleader>2 mzI## <ESC> |
|
au Filetype markdown nnoremap <buffer> <localleader>3 mzI### <ESC> |
|
|
|
" au FileType markdown nnoremap <leader>al <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc> |
|
" |
|
" Create a Markdown-link structure for the current word or visual selection |
|
" with leader 3. Paste in the URL later. Or use leader 4 to insert the |
|
" current system clipboard as an URL. |
|
au FileType markdown nnoremap <Leader>al ciw[<C-r>"]()<Esc> |
|
au FileType markdown vnoremap <Leader>al c[<C-r>"]()<Esc> |
|
" au FileType markdown nnoremap <Leader>ai <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc> |
|
au FileType markdown vnoremap <Leader>ai <Esc>`<i[<Esc>`>la](<Esc>"*]pa)<Esc> |
|
|
|
" au FileType markdown nnoremap <Leader>ai ciw[<C-r>"](<Esc>"*pli)<Esc> |
|
" au FileType markdown vnoremap <Leader>ai c[<C-r>"](<Esc>"*]pa)<Esc> |
|
|
|
" Use formd to transfer markdown from inline [to reference](to reference) links and vice versa |
|
" see: http://drbunsen.github.com/formd/ |
|
au FileType markdown nmap <leader>fr :%! /usr/local/bin/formd/formd -r<CR> |
|
au FileType markdown nmap <leader>fi :%! /usr/local/bin/formd/formd -i<CR> |
|
|
|
" For some reason saving causes the Toc to go blank. Call it again to solve this for now. Then put cursor back. |
|
au FileType markdown noremap SS :w<CR>:Toc<CR><C-w>h |
|
au FileType markdown inoremap SS <Esc>:w<CR>:Toc<CR><C-w>h |
|
augroup END |
|
|
|
augroup textobj_quote |
|
autocmd! |
|
autocmd FileType markdown call textobj#quote#init({'educate': 0}) |
|
autocmd FileType html call textobj#quote#init({'educate': 0}) |
|
autocmd FileType textile call textobj#quote#init({'educate': 0}) |
|
autocmd FileType text call textobj#quote#init({'educate': 0}) |
|
autocmd FileType vimwiki call textobj#quote#init({'educate': 0}) |
|
augroup END |
|
|
|
let g:pencil#mode_indicators = {'hard': '✐ hard', 'soft': '✎ soft', 'off': '✎ off',} |
|
let g:airline_section_x = '%{PencilMode()}' |
|
let g:pencil#map#suspend_af = 'K' " default is no mapping |
|
|
|
augroup pencil |
|
autocmd! |
|
autocmd FileType markdown,md,vimwiki |
|
\ call pencil#init({'wrap': 'soft', 'textwidth': 80}) |
|
\ | call litecorrect#init() |
|
\ | call lexical#init() |
|
\ | call textobj#sentence#init() |
|
\ | setl spell spl=en_us |
|
\ | setl fdo+=search |
|
autocmd Filetype git,gitsendemail,*commit*,*COMMIT* |
|
\ call pencil#init({'wrap': 'soft', 'textwidth': 72}) |
|
\ | call litecorrect#init() |
|
\ | call lexical#init() |
|
\ | call textobj#sentence#init() |
|
\ | setl spell spl=en_us et sw=2 ts=2 noai |
|
autocmd Filetype html,xml call pencil#init({'wrap': 'soft'}) |
|
\ | call litecorrect#init() |
|
\ | setl spell spl=en_us et sw=2 ts=2 |
|
augroup END |
|
|
|
" Vimwiki override to not check spelling when launching |
|
autocmd FileType vimwiki setl nospell |
|
|
|
|
|
|
|
" Find what Syntax you're in |
|
" map <F9> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' |
|
" \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" |
|
" \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> |
|
|
|
|
|
" Fugitive |
|
set diffopt+=vertical |
|
nnoremap <leader>gd :Gdiff<cr> |
|
nnoremap <leader>gst :Gstatus<cr> |
|
nnoremap <leader>gw :Gwrite<cr> |
|
nnoremap <leader>ge :Gedit<cr> |
|
nnoremap <leader>gb :Gblame -w -M<cr> |
|
nnoremap <leader>gB :Gitv!<cr> |
|
nnoremap <leader>gco :Gread<cr> |
|
nnoremap <leader>gcm :Gcommit<cr> |
|
nnoremap <leader>glg :Glog<cr> |
|
|
|
|
|
" Numbers |
|
|
|
" Motion for numbers. Great for CSS. Lets you do things like this: |
|
" |
|
" margin-top: 200px; -> ciN -> margin-top: px; |
|
" ^ ^ |
|
" TODO: Handle floats. |
|
|
|
onoremap N :<c-u>call <SID>NumberTextObject(0)<cr> |
|
xnoremap N :<c-u>call <SID>NumberTextObject(0)<cr> |
|
onoremap aN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
xnoremap aN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
onoremap iN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
xnoremap iN :<c-u>call <SID>NumberTextObject(1)<cr> |
|
|
|
function! s:NumberTextObject(whole) |
|
normal! v |
|
|
|
while getline('.')[col('.')] =~# '\v[0-9]' |
|
normal! l |
|
endwhile |
|
|
|
if a:whole |
|
normal! o |
|
|
|
while col('.') > 1 && getline('.')[col('.') - 2] =~# '\v[0-9]' |
|
normal! h |
|
endwhile |
|
endif |
|
endfunction |
|
|
|
|
|
let g:airline#extensions#tabline#enabled = 0 |
|
let g:airline_powerline_fonts = 1 |
|
let g:airline_detect_iminsert = 1 |
|
|
|
" tmux plugin for vim-airline https://github.com/edkolev/tmuxline.vim |
|
let g:tmuxline_preset = 'full' |
|
|
|
|
|
let g:InteractiveReplace_map = 'X' |
|
|
|
|
|
"let g:signify_sign_color_guibg = '#032b36' |
|
let g:signify_sign_color_inherit_from_linenr = 1 |
|
let g:signify_sign_weight = 'NONE' |
|
let g:signify_update_on_bufenter = 1 |
|
|
|
|
|
" Reveal in Finder - opens finder to folder of the file that is currently open |
|
command! Rif execute '!open %:p:h' |
|
|
|
|
|
" -------------- SURROUND SETTINGS ------------------- |
|
" ,# Surround a word with #{ruby interpolation} |
|
vmap ,# c#{<C-R>"}<ESC> |
|
|
|
" ," Surround a word with "quotes" |
|
map ," ysiw" |
|
vmap ," c"<C-R>""<ESC> |
|
|
|
" ,' Surround a word with 'single quotes' |
|
map ,' ysiw' |
|
vmap ,' c'<C-R>"'<ESC> |
|
|
|
" ,) or ,( Surround a word with (parens) |
|
" The difference is in whether a space is put in |
|
map ,( ysiw( |
|
map ,) ysiw) |
|
vmap ,( c( <C-R>" )<ESC> |
|
vmap ,) c(<C-R>")<ESC> |
|
|
|
" ,[ Surround a word with [brackets] |
|
map ,] ysiw] |
|
map ,[ ysiw[ |
|
vmap ,[ c[ <C-R>" ]<ESC> |
|
vmap ,] c[<C-R>"]<ESC> |
|
|
|
" ,{ Surround a word with {braces} |
|
map ,} ysiw} |
|
map ,{ ysiw{ |
|
vmap ,} c{ <C-R>" }<ESC> |
|
vmap ,{ c{<C-R>"}<ESC> |
|
|
|
map ,` ysiw` |
|
" -------------- END SURROUND SETTINGS --------------- |
|
|
|
|
|
" TODO: (2016-11-05) jonk => experiment with this more |
|
" xmpfilter (need to: `gem install rcodetools` into each global gemset for each version of ruby that you want to use this with) |
|
" map <F11> <Plug>(xmpfilter-mark) |
|
" map <F12> <Plug>(xmpfilter-run) |
|
|
|
|
|
" slim template detection, the plugin didn't get me goin... FIXME |
|
" autocmd BufNewFile,BufRead *.slim set ft=slim |
|
|
|
au BufNewFile,BufRead *.js.erb setlocal filetype=javascript |
|
au BufNewFile,BufRead *.ejs set filetype=xml |
|
|
|
|
|
if has("unix") |
|
let s:uname = system("uname") |
|
if s:uname == "Darwin\n" |
|
" Do Mac stuff here |
|
|
|
" Dash |
|
"let g:dash_map = { |
|
" \ 'ruby' : 'rails' |
|
" \ } |
|
au BufNewFile,BufRead *.rb :DashKeywords rails ruby<cr> |
|
nmap <silent> <LocalLeader>d <Plug>DashSearch |
|
nmap <silent> <LocalLeader>D <Plug>DashGlobalSearch |
|
endif |
|
endif |
|
|
|
|
|
" quote, quotation, apostrophe, curly |
|
map <silent> <leader>qc <Plug>ReplaceWithCurly |
|
map <silent> <leader>qs <Plug>ReplaceWithStraight |
|
|
|
|
|
let g:mustache_abbreviations = 1 |
|
|
|
let g:syntastic_shell = '/bin/sh' |
|
let g:syntastic_mode_map = { 'mode': 'active' } |
|
let g:syntastic_ruby_checkers = ['mri', 'rubocop', 'haml_lint'] |
|
let g:syntastic_cucumber_cucumber_args="--profile syntastic" |
|
let g:syntastic_cucumber_cucumber_exe='bin/cucumber' |
|
let g:syntastic_ruby_rubocop_args = '--force-exclusion' |
|
" let g:syntastic_debug = 1 |
|
|
|
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'] |
|
if executable('node_modules/.bin/eslint') |
|
let g:syntastic_javascript_eslint_exec = 'node_modules/.bin/eslint' |
|
endif |
|
|
|
let g:syntastic_error_symbol = '❌' |
|
let g:syntastic_style_error_symbol = '⁉️' |
|
let g:syntastic_warning_symbol = '⚠️' |
|
let g:syntastic_style_warning_symbol = '💩' |
|
|
|
highlight link SyntasticErrorSign SignColumn |
|
highlight link SyntasticWarningSign SignColumn |
|
highlight link SyntasticStyleErrorSign SignColumn |
|
highlight link SyntasticStyleWarningSign SignColumn |
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
" OpenChangedFiles COMMAND |
|
" Open a split for each dirty (or new) file in git |
|
" |
|
" Shamelessly stolen from Gary Bernhardt: https://github.com/garybernhardt/dotfiles |
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
function! OpenChangedFiles() |
|
only " Close all windows, unless they're modified |
|
let modified_status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3') |
|
let added_status = system('git status -s | grep "^ \?\(??\)" | cut -d " " -f 2') |
|
let status = modified_status . added_status |
|
let filenames = split(status, "\n") |
|
if len(filenames) > 0 |
|
exec "edit " . filenames[0] |
|
for filename in filenames[1:] |
|
exec "tabedit " . filename |
|
endfor |
|
end |
|
endfunction |
|
command! OpenChangedFiles :call OpenChangedFiles() |
|
|
|
nnoremap ,em :NERDTreeMirrorToggle<CR>:OpenChangedFiles<CR>:NERDTreeMirrorToggle<CR> |
|
|
|
|
|
|
|
|
|
function! DoPrettyXML() |
|
" save the filetype so we can restore it later |
|
let l:origft = &ft |
|
set ft= |
|
" delete the xml header if it exists. This will |
|
" permit us to surround the document with fake tags |
|
" without creating invalid xml. |
|
1s/<?xml .*?>//e |
|
" insert fake tags around the entire document. |
|
" This will permit us to pretty-format excerpts of |
|
" XML that may contain multiple top-level elements. |
|
0put ='<PrettyXML>' |
|
$put ='</PrettyXML>' |
|
silent %!xmllint --format - |
|
" xmllint will insert an <?xml?> header. it's easy enough to delete |
|
" if you don't want it. |
|
" delete the fake tags |
|
2d |
|
$d |
|
" restore the 'normal' indentation, which is one extra level |
|
" too deep due to the extra tags we wrapped around the document. |
|
silent %< |
|
" back to home |
|
1 |
|
" restore the filetype |
|
exe "set ft=" . l:origft |
|
endfunction |
|
command! PrettyXML call DoPrettyXML() |
|
|
|
|
|
|
|
"autocmd VimEnter,BufNewFile,BufReadPost * silent! call HardMode() |
|
" nnoremap <leader>h <Esc>:call ToggleHardMode()<CR> |
|
|
|
|
|
" Easymotion |
|
let g:EasyMotion_startofline = 0 "keep cursor colum JK motion |
|
|
|
" change the default shading to something more readable with Solarized |
|
hi EasyMotionTarget guifg=red guibg=NONE ctermfg=red ctermbg=NONE |
|
hi EasyMotionTarget2First guifg=red guibg=NONE ctermfg=red ctermbg=NONE |
|
hi EasyMotionTarget2Second guifg=red guibg=NONE ctermfg=red ctermbg=NONE |
|
hi link EasyMotionShade Comment |
|
"let g:EasyMotion_do_shade = 0 |
|
|
|
|
|
|
|
set switchbuf=useopen,usetab "Attempt to edit currently open files instead of opening multiple buffers. FIXME: Not sure if this is working. |
|
|
|
|
|
|
|
" nmap <leader>h :%!html2haml --erb 2> /dev/null<CR>:set ft=haml<CR> |
|
" vmap <leader>h :!html2haml --erb 2> /dev/null<CR> |
|
|
|
|
|
" Insert a newline after each specified string (or before if use '!'). |
|
" If no arguments, use previous search. |
|
command! -bang -nargs=* -range LineBreakAt <line1>,<line2>call LineBreakAt('<bang>', <f-args>) |
|
function! LineBreakAt(bang, ...) range |
|
let save_search = @/ |
|
if empty(a:bang) |
|
let before = '' |
|
let after = '\ze.' |
|
let repl = '&\r' |
|
else |
|
let before = '.\zs' |
|
let after = '' |
|
let repl = '\r&' |
|
endif |
|
let pat_list = map(deepcopy(a:000), "escape(v:val, '/\\.*$^~[')") |
|
let find = empty(pat_list) ? @/ : join(pat_list, '\|') |
|
let find = before . '\%(' . find . '\)' . after |
|
" Example: 10,20s/\%(arg1\|arg2\|arg3\)\ze./&\r/ge |
|
execute a:firstline . ',' . a:lastline . 's/'. find . '/' . repl . '/ge' |
|
let @/ = save_search |
|
endfunction |
|
|
|
|
|
nmap <localleader>. :LineBreakAt! .<CR> |
|
nmap <localleader>, :LineBreakAt ,<CR> |
|
|
|
|
|
let g:rails_projections = { |
|
\ "config/projections.json": { |
|
\ "command": "projections" |
|
\ }, |
|
\ "app/serializers/*_serializer.rb": { |
|
\ "command": "serializer", |
|
\ "affinity": "model", |
|
\ "test": "spec/serializers/%s_spec.rb", |
|
\ "related": "app/models/%s.rb", |
|
\ "template": "class %SSerializer < ActiveModel::Serializer\nend" |
|
\ }, |
|
\ "app/services/*.rb": { |
|
\ "command": "service", |
|
\ "affinity": "model", |
|
\ "alternate": ["spec/services/%s_spec.rb", "unit/services/%s_spec.rb"], |
|
\ "template": "class %S\n\n def perform\n end\nend" |
|
\ }, |
|
\ "app/presenters/*_presenter.rb": { |
|
\ "command": "presenter", |
|
\ "affinity": "model", |
|
\ "alternate": ["spec/presenters/%s_presenter_spec.rb", "unit/presenters/%s_presenter_spec.rb"], |
|
\ "related": "app/models/%s.rb", |
|
\ "template": "class %SPresenter < SimpleDelegator\n def self.wrap(collection)\n collection.map{open} |object| new object {close}\n end\n\nend" |
|
\ }, |
|
\ "spec/presenters/*_presenter.rb": { |
|
\ "command": "specpresenter", |
|
\ "affinity": "presenter", |
|
\ "alternate": ["app/presenters/%s_presenter.rb"], |
|
\ "related": "app/models/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %SPresenter, type: :presenter do\n\nend" |
|
\ }, |
|
\ "features/cukes/*.feature": { |
|
\ "alternate": ["features/step_definitions/%s_steps.rb", "features/steps/%s_steps.rb"], |
|
\ }, |
|
\ "spec/factories/*s.rb": { |
|
\ "command": "factory", |
|
\ "affinity": "model", |
|
\ "related": "app/models/%s.rb", |
|
\ "template": "FactoryGirl.define do\n factory :%s do\n end\nend" |
|
\ }, |
|
\ "spec/controllers/*_controller_spec.rb": { |
|
\ "command": "speccontroller", |
|
\ "affinity": "controller", |
|
\ "related": "app/controllers/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %SController, type: :controller do\n\nend" |
|
\ }, |
|
\ "spec/serializers/*_serializer_spec.rb": { |
|
\ "command": "specserializer", |
|
\ "affinity": "serializer", |
|
\ "related": "app/serializers/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %SSerializer, type: :serializer do\n\nend" |
|
\ }, |
|
\ "spec/models/*_spec.rb": { |
|
\ "command": "spec", |
|
\ "affinity": "model", |
|
\ "related": "app/models/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %S, type: :model do\n\nend" |
|
\ }, |
|
\ "spec/services/*_spec.rb": { |
|
\ "command": "specservice", |
|
\ "affinity": "service", |
|
\ "related": "app/services/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %S do\n\nend" |
|
\ }, |
|
\ "spec/workers/*_spec.rb": { |
|
\ "command": "specworker", |
|
\ "affinity": "worker", |
|
\ "related": "app/workers/%s.rb", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe %S, type: :worker do\n\nend" |
|
\ }, |
|
\ "spec/features/*_spec.rb": { |
|
\ "command": "specfeature", |
|
\ "template": "require 'rails_helper'\n\nRSpec.feature '%S', type: :feature do\n\nend" |
|
\ }, |
|
\ "spec/helpers/*_helper_spec.rb": { |
|
\ "command": "spechelper", |
|
\ "related": "app/helpers/%_helper.rb", |
|
\ "affinity": "helper", |
|
\ "template": "require 'rails_helper'\n\nRSpec.describe ApplicationHelper, type: :helper do\n\nend" |
|
\ }, |
|
\ "lib/tasks/*.rake": { |
|
\ "command": "rake", |
|
\ "template": ["namespace :%s do\n desc '%s'\n task %s: :environment do\n\n end\nend"], |
|
\ }, |
|
\ "config/*.rb": { "command": "config" }, |
|
\ "spec/support/*.rb": { "command": "support" }, |
|
\ } |
|
|
|
let g:rails_gem_projections = { |
|
\ "carrierwave": { |
|
\ "app/uploaders/*_uploader.rb": { |
|
\ "command": "uploader", |
|
\ "template": "class %SUploader < CarrierWave::Uploader::Base\nend" |
|
\ } |
|
\ }, |
|
\ "resque": { |
|
\ "app/workers/*_job.rb": { |
|
\ "command": "worker", |
|
\ "template": "class %SJob\n\n \n@queue = :main\ndef self.perform\n end\nend" |
|
\ } |
|
\ }, |
|
\ } |
|
|
|
|
|
let g:projectionist_heuristics = { |
|
\ ".ember-cli": { |
|
\ "app/adapters/*.js": { |
|
\ "command": "adapter", |
|
\ "template": [ |
|
\ "\// export default DS.{capitalize}Adapter.extend();", |
|
\ ] |
|
\ }, |
|
\ "app/components/*.js": { |
|
\ "command": "component", |
|
\ "template": [ |
|
\ "import Ember from 'ember';", |
|
\ "", |
|
\ "export default Ember.Component.extend({", |
|
\ "", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "tests/unit/components/{}-test.js" |
|
\ }, |
|
\ "app/controllers/*.js": { |
|
\ "command": "controller", |
|
\ "template": [ |
|
\ "export default Ember.Controller.extend({", |
|
\ "", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "tests/unit/controllers/{}-test.js" |
|
\ }, |
|
\ "app/helpers/*.js": { |
|
\ "command": "helper", |
|
\ "template": [ |
|
\ "\// Please note that Handlebars helpers will only be found automatically by the", |
|
\ "\// resolver if their name contains a dash (reverse-word, translate-text, etc.)", |
|
\ "\// For more details: http://stefanpenner.github.io/ember-app-kit/guides/using-modules.html", |
|
\ "import Ember from 'ember';", |
|
\ "", |
|
\ "function {camelcase}(text) {", |
|
\ " if (!text) {open} return ''; {close}", |
|
\ " return text.htmlSafe();", |
|
\ "}", |
|
\ "", |
|
\ "export default Ember.Handlebars.makeBoundHelper({camelcase}, 'dependentKey');", |
|
\ ], |
|
\ "alternate": "tests/unit/helpers/{}-test.js" |
|
\ }, |
|
\ "app/models/*.js": { |
|
\ "command": "model", |
|
\ "template": [ |
|
\ "import DS from 'ember-data';", |
|
\ "", |
|
\ "var attr = DS.attr;", |
|
\ "\// hasMany = DS.hasMany;", |
|
\ "", |
|
\ "export default DS.Model.extend({", |
|
\ "", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "tests/unit/models/{}-test.js" |
|
\ }, |
|
\ "app/mixins/*.js": { |
|
\ "command": "mixin", |
|
\ "alternate": "tests/unit/mixins/{}-test.js" |
|
\ }, |
|
\ "app/serializers/*.js": { |
|
\ "command": "serializer", |
|
\ "alternate": "tests/unit/serializers/{}-test.js" |
|
\ }, |
|
\ "app/services/*.js": { |
|
\ "command": "service", |
|
\ "template": [ |
|
\ "import Ember from 'ember';", |
|
\ "", |
|
\ "export default Ember.Service.extend({", |
|
\ "", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "tests/unit/services/{}-test.js" |
|
\ }, |
|
\ "app/initializers/*.js": { "command": "initializer" }, |
|
\ "app/router.js": { |
|
\ "command": "router" |
|
\ }, |
|
\ "app/routes/*.js": { |
|
\ "command": "route", |
|
\ "template": [ |
|
\ "import Ember from 'ember';", |
|
\ "", |
|
\ "export default Ember.Route.extend({", |
|
\ " model: function() {", |
|
\ " ", |
|
\ " }", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "app/controllers/{}.js" |
|
\ }, |
|
\ "app/styles/*.sass": { |
|
\ "command": "style", |
|
\ "template": ["/* {}.sass */", ' '] |
|
\ }, |
|
\ "app/styles/*.css": { |
|
\ "command": "css", |
|
\ "template": ["/* {}.css */", ' '] |
|
\ }, |
|
\ "app/templates/*.hbs": { |
|
\ 'command': 'template', |
|
\ 'template': ["{open}{open}outlet{close}{close}", " "], |
|
\ 'alternate': "app/controllers/{}.js" |
|
\ }, |
|
\ "app/utils/*.js": { |
|
\ "command": "util" |
|
\ }, |
|
\ "app/views/*.js": { |
|
\ "command": "view", |
|
\ "template": [ |
|
\ "export default Ember.View.extend({", |
|
\ "", |
|
\ "});", |
|
\ ], |
|
\ "alternate": "tests/unit/views/{}-test.js" |
|
\ }, |
|
\ "bower.json": { "command": "bower" }, |
|
\ "package.json": { "command": "package" }, |
|
\ "README.md": { "command": "readme" } |
|
\ } |
|
\ } |
|
|
|
set formatoptions=1 |
|
set linebreak |
|
set breakat=\ ^I!@*-+;:,./?\(\[\{ |