2012-10-31 20:42:59 -07:00
|
|
|
" Leader
|
|
|
|
let mapleader = " "
|
|
|
|
|
2013-08-01 11:21:58 -07:00
|
|
|
set backspace=2 " Backspace deletes like most programs in insert mode
|
2011-01-13 17:54:08 -05:00
|
|
|
set nobackup
|
|
|
|
set nowritebackup
|
2012-10-15 15:36:51 -04:00
|
|
|
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
|
2011-01-13 17:54:08 -05:00
|
|
|
set history=50
|
|
|
|
set ruler " show the cursor position all the time
|
|
|
|
set showcmd " display incomplete commands
|
|
|
|
set incsearch " do incremental searching
|
|
|
|
set laststatus=2 " Always display the status line
|
2013-07-11 10:20:08 -04:00
|
|
|
set autowrite " Automatically :write before running commands
|
2011-01-13 17:54:08 -05:00
|
|
|
|
|
|
|
" Switch syntax highlighting on, when the terminal has colors
|
|
|
|
" Also switch on highlighting the last used search pattern.
|
|
|
|
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
|
|
|
|
syntax on
|
|
|
|
endif
|
|
|
|
|
2013-04-16 20:24:00 -04:00
|
|
|
if filereadable(expand("~/.vimrc.bundles"))
|
|
|
|
source ~/.vimrc.bundles
|
|
|
|
endif
|
2012-10-24 22:08:53 -07:00
|
|
|
|
2015-05-11 11:13:17 -04:00
|
|
|
" Load matchit.vim, but only if the user hasn't installed a newer version.
|
|
|
|
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
|
|
|
|
runtime! macros/matchit.vim
|
|
|
|
endif
|
|
|
|
|
2011-01-13 17:54:08 -05:00
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
augroup vimrcEx
|
2013-05-24 17:26:21 -04:00
|
|
|
autocmd!
|
2011-01-13 17:54:08 -05:00
|
|
|
|
|
|
|
" When editing a file, always jump to the last known cursor position.
|
2013-04-27 10:56:18 -04:00
|
|
|
" Don't do it for commit messages, when the position is invalid, or when
|
|
|
|
" inside an event handler (happens when dropping a file on gvim).
|
2011-01-13 17:54:08 -05:00
|
|
|
autocmd BufReadPost *
|
2013-04-27 10:56:18 -04:00
|
|
|
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
|
2011-01-13 17:54:08 -05:00
|
|
|
\ exe "normal g`\"" |
|
|
|
|
\ endif
|
2013-05-24 17:26:21 -04:00
|
|
|
|
|
|
|
" Set syntax highlighting for specific file types
|
|
|
|
autocmd BufRead,BufNewFile *.md set filetype=markdown
|
2015-11-03 12:48:21 -05:00
|
|
|
autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json
|
2017-08-06 10:33:48 -04:00
|
|
|
|
|
|
|
" ALE linting events
|
2017-08-07 20:36:01 -04:00
|
|
|
if g:has_async
|
|
|
|
set updatetime=1000
|
|
|
|
let g:ale_lint_on_text_changed = 0
|
|
|
|
autocmd CursorHold * call ale#Lint()
|
|
|
|
autocmd CursorHoldI * call ale#Lint()
|
|
|
|
autocmd InsertEnter * call ale#Lint()
|
|
|
|
autocmd InsertLeave * call ale#Lint()
|
|
|
|
else
|
|
|
|
echoerr "The thoughtbot dotfiles require NeoVim or Vim 8"
|
|
|
|
endif
|
2011-01-13 17:54:08 -05:00
|
|
|
augroup END
|
|
|
|
|
2016-02-15 08:54:08 +11:00
|
|
|
" When the type of shell script is /bin/sh, assume a POSIX-compatible
|
|
|
|
" shell for syntax highlighting purposes.
|
|
|
|
let g:is_posix = 1
|
|
|
|
|
2011-01-13 17:54:08 -05:00
|
|
|
" Softtabs, 2 spaces
|
|
|
|
set tabstop=2
|
|
|
|
set shiftwidth=2
|
2014-04-18 21:19:04 -04:00
|
|
|
set shiftround
|
2011-01-13 17:54:08 -05:00
|
|
|
set expandtab
|
|
|
|
|
|
|
|
" Display extra whitespace
|
2014-10-10 14:58:09 +02:00
|
|
|
set list listchars=tab:»·,trail:·,nbsp:·
|
2011-01-13 17:54:08 -05:00
|
|
|
|
2015-12-08 15:01:28 -08:00
|
|
|
" Use one space, not two, after punctuation.
|
|
|
|
set nojoinspaces
|
|
|
|
|
2013-06-19 09:54:10 -07:00
|
|
|
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
|
|
|
|
if executable('ag')
|
|
|
|
" Use Ag over Grep
|
2013-06-24 09:55:32 -07:00
|
|
|
set grepprg=ag\ --nogroup\ --nocolor
|
2013-06-19 09:54:10 -07:00
|
|
|
|
|
|
|
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
|
2017-12-18 22:39:38 -05:00
|
|
|
let g:ctrlp_user_command = 'ag --literal --files-with-matches --nocolor --hidden -g "" %s'
|
2013-08-23 17:28:03 -04:00
|
|
|
|
|
|
|
" ag is fast enough that CtrlP doesn't need to cache
|
|
|
|
let g:ctrlp_use_caching = 0
|
2016-07-22 13:17:32 -04:00
|
|
|
|
|
|
|
if !exists(":Ag")
|
|
|
|
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
|
|
|
|
nnoremap \ :Ag<SPACE>
|
|
|
|
endif
|
2011-01-13 17:54:08 -05:00
|
|
|
endif
|
|
|
|
|
2014-04-02 11:40:18 -04:00
|
|
|
" Make it obvious where 80 characters is
|
|
|
|
set textwidth=80
|
|
|
|
set colorcolumn=+1
|
|
|
|
|
2011-01-13 17:54:08 -05:00
|
|
|
" Numbers
|
|
|
|
set number
|
|
|
|
set numberwidth=5
|
|
|
|
|
2012-10-20 18:03:00 -07:00
|
|
|
" Tab completion
|
2012-10-29 21:00:52 -07:00
|
|
|
" will insert tab at beginning of line,
|
|
|
|
" will use completion if not at beginning
|
2011-01-13 17:54:08 -05:00
|
|
|
set wildmode=list:longest,list:full
|
2012-10-29 21:00:52 -07:00
|
|
|
function! InsertTabWrapper()
|
|
|
|
let col = col('.') - 1
|
|
|
|
if !col || getline('.')[col - 1] !~ '\k'
|
2018-01-04 21:00:22 -05:00
|
|
|
return "\<Tab>"
|
2012-10-29 21:00:52 -07:00
|
|
|
else
|
2018-01-04 21:00:22 -05:00
|
|
|
return "\<C-p>"
|
2012-10-29 21:00:52 -07:00
|
|
|
endif
|
|
|
|
endfunction
|
2018-01-04 21:00:22 -05:00
|
|
|
inoremap <Tab> <C-r>=InsertTabWrapper()<CR>
|
|
|
|
inoremap <S-Tab> <C-n>
|
2011-01-13 17:54:08 -05:00
|
|
|
|
2012-10-31 20:36:15 -07:00
|
|
|
" Switch between the last two files
|
2018-01-04 21:00:22 -05:00
|
|
|
nnoremap <Leader><Leader> <C-^>
|
2011-01-13 17:54:08 -05:00
|
|
|
|
|
|
|
" Get off my lawn
|
|
|
|
nnoremap <Left> :echoe "Use h"<CR>
|
|
|
|
nnoremap <Right> :echoe "Use l"<CR>
|
|
|
|
nnoremap <Up> :echoe "Use k"<CR>
|
|
|
|
nnoremap <Down> :echoe "Use j"<CR>
|
|
|
|
|
2016-02-11 22:03:38 -05:00
|
|
|
" vim-test mappings
|
|
|
|
nnoremap <silent> <Leader>t :TestFile<CR>
|
|
|
|
nnoremap <silent> <Leader>s :TestNearest<CR>
|
|
|
|
nnoremap <silent> <Leader>l :TestLast<CR>
|
|
|
|
nnoremap <silent> <Leader>a :TestSuite<CR>
|
2017-06-19 12:53:17 -05:00
|
|
|
nnoremap <silent> <Leader>gt :TestVisit<CR>
|
2013-04-12 11:45:16 -04:00
|
|
|
|
2014-02-10 23:28:28 -08:00
|
|
|
" Run commands that require an interactive shell
|
2018-01-04 21:00:22 -05:00
|
|
|
nnoremap <Leader>r :RunInInteractiveShell<Space>
|
2014-02-10 23:28:28 -08:00
|
|
|
|
2011-01-13 17:54:08 -05:00
|
|
|
" Treat <li> and <p> tags like the block tags they are
|
|
|
|
let g:html_indent_tags = 'li\|p'
|
|
|
|
|
2013-04-05 13:24:50 -04:00
|
|
|
" Open new split panes to right and bottom, which feels more natural
|
|
|
|
set splitbelow
|
|
|
|
set splitright
|
|
|
|
|
2013-05-14 11:21:00 -06:00
|
|
|
" Quicker window movement
|
|
|
|
nnoremap <C-j> <C-w>j
|
|
|
|
nnoremap <C-k> <C-w>k
|
|
|
|
nnoremap <C-h> <C-w>h
|
|
|
|
nnoremap <C-l> <C-w>l
|
|
|
|
|
2017-08-06 10:33:48 -04:00
|
|
|
" Move between linting errors
|
|
|
|
nnoremap ]r :ALENextWrap<CR>
|
|
|
|
nnoremap [r :ALEPreviousWrap<CR>
|
2013-04-05 11:33:14 -04:00
|
|
|
|
2014-07-16 14:59:22 -07:00
|
|
|
" Set spellfile to location that is guaranteed to exist, can be symlinked to
|
|
|
|
" Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
|
|
|
|
set spellfile=$HOME/.vim-spell-en.utf-8.add
|
|
|
|
|
2015-03-18 10:24:55 +00:00
|
|
|
" Autocomplete with dictionary words when spell check is on
|
|
|
|
set complete+=kspell
|
|
|
|
|
2014-08-29 17:03:30 -04:00
|
|
|
" Always use vertical diffs
|
|
|
|
set diffopt+=vertical
|
|
|
|
|
2013-04-02 08:17:23 -07:00
|
|
|
" Local config
|
|
|
|
if filereadable($HOME . "/.vimrc.local")
|
|
|
|
source ~/.vimrc.local
|
|
|
|
endif
|