-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
240 lines (201 loc) · 7.22 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
" Be vim, don't pretend to be vi. Setting early as it has side effects.
set nocompatible
""""""""""""""""""
" Vundle
" https://github.com/VundleVim/Vundle.vim
filetype on " Required so vi on OS X doesn't exit with an exit code of 1
filetype off " Required for Vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
" Define bundles via Github repos
Plugin 'airblade/vim-gitgutter'
Plugin 'altercation/vim-colors-solarized'
Plugin 'christoomey/vim-run-interactive'
Plugin 'danro/rename.vim'
Plugin 'godlygeek/tabular' " required for and must come before vim-markdown
Plugin 'reedes/vim-pencil'
Plugin 'kana/vim-textobj-user'
Plugin 'kchmck/vim-coffee-script'
Plugin 'kien/ctrlp.vim'
Plugin 'mxw/vim-jsx'
Plugin 'nelstrom/vim-textobj-rubyblock'
Plugin 'pangloss/vim-javascript'
Plugin 'pbrisbin/vim-mkdir'
Plugin 'plasticboy/vim-markdown'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'slim-template/vim-slim'
Plugin 'thoughtbot/vim-rspec'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-surround'
Plugin 'vim-pandoc/vim-pandoc'
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'vim-ruby/vim-ruby'
Plugin 'vim-scripts/ctags.vim'
Plugin 'vim-scripts/fountain.vim'
Plugin 'vim-scripts/matchit.zip'
Plugin 'vim-scripts/tComment'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'kballard/vim-swift'
Plugin 'junegunn/vim-easy-align'
call vundle#end()
filetype plugin indent on
""""""""""""""""""
" Global variables
set autowrite " Automatically :write before running commands
set background=dark
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set colorcolumn=+1
set expandtab
set history=50
set incsearch " highlight while searching
set laststatus=2 " Always display the status line
set list listchars=tab:»·,trail:· " Display extra whitespace
set number " Show line numbers
set numberwidth=4 " Make room for up to 4 digits
set ruler " show the cursor position all the time
set shiftwidth=2
set shiftround
set showcmd " display incomplete commands
set splitbelow " Open new horizontal split panes below current one
set splitright " Open new vertical split panes to right of the current one
set noswapfile
set tabstop=2 " Softtabs, 2 spaces
set textwidth=80 " Make it obvious where 80 characters is
set nowritebackup
set foldlevelstart=99 " Start with nothing folded
set guifont=Menlo-Regular:h17 " fit two 80-char buffers on half the screen
silent! colorscheme solarized
""""""""""""""""""
" Key mappings
let mapleader = " " "Leader
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags -R .<CR>
" Switch between the last two files
nnoremap <leader><leader> <c-^>
" vim-rspec mappings
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>s :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
" Run commands that require an interactive shell
nnoremap <Leader>r :RunInInteractiveShell<space>
" 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
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
""""""""""""""""""
" Ctags
" Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
:set tags^=./.git/tags " for fugitive
""""""""""""""""""
" vim-pencil
let g:pencil#conceallevel = 0 " Don't hide things
""""""""""""""""""
" vim-markdown
let g:vim_markdown_frontmatter = 1 " Highlight YAML front matter as used by Jekyll
let g:vim_markdown_no_extensions_in_markdown = 1
""""""""""""""""""
" vim-pandoc
" do syntax highlighting for these languages
let g:pandoc#syntax#codeblocks#embeds#langs = ['javascript', 'ruby', 'sh', 'yaml', 'javascript', 'html', 'vim', 'coffee', 'json', 'diff']
" do no folding by default
let g:pandoc#folding#level = 99
""""""""""""""""
" Syntastic
let g:syntastic_check_on_open=0 " don't check syntax on open (it's slow)
let g:syntastic_check_on_wq = 0 " don't check syntax on quit (who cares?)
" only check on save
" ignore angular-specific attributes
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
" Treat js files as React files (for the sake of Ponton)
let g:jsx_ext_required = 0
" Use haml-lint to check haml (https://github.com/sds/haml-lint)
let g:syntastic_haml_checkers = ['haml_lint']
" use ruby interpreter and rubocop to check ruby syntax
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
" Use Swift defaults
let g:syntastic_swift_swiftlint_use_defaults = 1
let g:syntastic_swift_checkers = ['swiftlint', 'swiftpm']
""""""""""""""""
" Git-gutter
let g:gitgutter_realtime = 500 " Update git gutter more quickly
let g:gitgutter_sign_column_always = 1
let g:gitgutter_highlight_lines = 0
"""""""""""""""""
" Contol-P
let g:ctrlp_working_path_mode = 'r' " start from repo or current dir
"""""""""""""""""
" Silver Searcher
" https://github.com/ggreer/the_silver_searcher
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor " Use in place of grep
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
"""""""""""""""""
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
inoremap <S-Tab> <c-n>
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" 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).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
augroup filetypes
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.prawn set filetype=ruby
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.fountain set filetype=fountain
" Enable spellchecking for Markdown
autocmd FileType pandoc,markdown setlocal spell
" Automatically wrap at 80 characters for text files
autocmd FileType pandoc,markdown,fountain setlocal textwidth=80
" Strip trailing whitespace
autocmd FileType c,cpp,java,php,ruby,javascript autocmd BufWritePre <buffer> %s/\s\+$//e
augroup END
" augroup pencil
" autocmd!
" autocmd FileType pandoc call pencil#init()
" autocmd FileType markdown call pencil#init()
" autocmd FileType text call pencil#init()
" autocmd FileType fountain call pencil#init({'wrap': 'soft'})
" augroup END
augroup autosave
" Auto save when leaving buffer
autocmd BufLeave,FocusLost * silent! wall
augroup END
" Local config
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif