-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
287 lines (227 loc) · 8.62 KB
/
vimrc
File metadata and controls
287 lines (227 loc) · 8.62 KB
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
" Configuration file for vim
set modelines=0 " CVE-2007-2438
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
"set backspace=2 " more powerful backspacing
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup
" pathogen
call pathogen#infect()
" autoreload vimrc
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END " }
" map leader to ,
let mapleader = ","
" use line numbers
set number
" use wildmenu
set wildmenu
" yank to clipboard
set clipboard=unnamed
" dealing with backups
set backupdir=~/.vim-tmp,~/tmp,/var/tmp,$HOME/Local\ Settings/Temp
" If you prefer the Omni-Completion tip window to close when a selection is
" made, these lines close it on movement in insert mode or when leaving
" insert mode
autocmd CursorMovedI * if pumvisible() == 0|silent! pclose|endif
autocmd InsertLeave * if pumvisible() == 0|silent! pclose|endif
" dealing with whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" trim whitespace
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre *.rb,*.edn,*.clj,*.xml,*.html,*.html.mustache,*.css,*.scss,*.less,*.json,*.js,*.coffee,*.sql,*.vim :call TrimWhiteSpace()
" Ruby, edn, sh
autocmd BufNewFile,BufRead *.rb,*.edn setl expandtab sw=2 ts=2 sts=2
autocmd BufNewFile,BufRead * if &ft == 'sh' | setl expandtab ts=2 sw=2 | endif
" web syntax: xml, html, css, scss, less, js, coffee
autocmd BufNewFile,BufRead *.xml,*.html,*.html.mustache,*.css,*.scss,*.less,*.js,*.json,*.coffee,*.sql,*.vim set ts=2 sts=2 sw=2 smarttab expandtab
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent " nofoldenable
" markdown
au BufRead,BufNewFile *.md setl textwidth=80
" Powerline
set nocompatible " Disable vi-compatibility
set laststatus=2 " Always show the statusline
set encoding=utf-8 " Necessary to show Unicode glyphs
set t_Co=256
let g:Powerline_symbols = 'fancy'
"set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
" useful key bindings
set timeout timeoutlen=500
imap jj <Esc>
imap JJ <Esc>
nnoremap <BS> :noh<return><BS>
nnoremap <Leader>s :sp<return>
nnoremap <Leader>v :vsp<return>
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
autocmd BufNewFile,BufRead *.tex set ts=2 sts=2 sw=2 tw=80 smarttab expandtab wrap linebreak nolist
autocmd FileType tex imap <Leader>i <Plug>Tex_InsertItemOnThisLine
" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press <C-n> you will automatically cycle through
" all the figure labels. Very useful!
""" trouble with this is that it should only be used in latex mode since
""" statements like else: (in python) get tokenized
"set iskeyword+=:
let g:Tex_ViewRule_pdf = 'open -a Preview.app'
set conceallevel=2
let g:tex_conceal= 'adgms'
hi Conceal ctermbg=Black
" 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
" open and close quickfix window
nnoremap <Leader>qo :copen<CR>
nnoremap <Leader>qc :cclose<CR>
" paredit for edn
au BufNewFile,BufRead *.edn set filetype=clojure
au FileType clojure call PareditInitBuffer()
" " rainbow parentheses
" au VimEnter * RainbowParenthesesToggle
" au Syntax * RainbowParenthesesLoadRound
" au Syntax * RainbowParenthesesLoadSquare
" au Syntax * RainbowParenthesesLoadBraces
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" Shortcut to open git page
nmap <leader>o :OpenGithubFile<CR>
vmap <leader>o :OpenGithubFile<CR>
" Use the same symbols as TextMate for tabstops and EOLs
"set listchars=tab:▸\ ,eol:¬
" vim-markdown
let g:vim_markdown_folding_disabled=1
" nerdtree
map <C-n> :NERDTreeToggle<CR>
" ctrp and extensions
let g:ctrlp_extensions = ['funky', 'yankring', 'cmdline', 'menu']
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|target'
nnoremap <Leader>m :CtrlPModified<CR>
nnoremap <Leader>M :CtrlPBranch<CR>
" funky
nnoremap <Leader>fu :CtrlPFunky<Cr>
nnoremap <Leader>fU :execute 'CtrlPFunky ' . expand('<cword>')<CR>
" " redl
" nnoremap <Leader>rr :Repl<CR>
" nnoremap <Leader>rh :ReplHere<CR>
" nnoremap <Leader>rq :Req<CR>
" " fugitive helpers
" nnoremap <Leader>gb :Gblame<CR>
" nnoremap <Leader>gd :Gdiff<CR>
" nnoremap <Leader>gg :Ggrep
" nnoremap <Leader>gG :execute 'Ggrep ' . expand('<cword>')<CR>
" nnoremap <Leader>gl :Glog<CR>
" nnoremap <Leader>gL :Glog --<CR>
" nnoremap <Leader>gm :Gmove
" nnoremap <Leader>gM :Gmove!
" nnoremap <Leader>gp :Git push<CR>
" nnoremap <Leader>gP :Git push -f<CR>
" nnoremap <Leader>gr :Gremove<CR>
" nnoremap <Leader>gR :Gremove!<CR>
" nnoremap <Leader>gs :Gstatus<CR>
" ag helpers
nnoremap <Leader>a :Ag
nnoremap <Leader>A :execute 'Ag ' . expand('<cword>')<CR>
" vim calc
nnoremap <Leader>c :Calc<CR>
" bufkill
nnoremap <Leader>bk :BD<CR>
" sudo save from buffer
cmap w!! %!sudo tee > /dev/null %
" vim-python-test-runner
nnoremap<Leader>da :DjangoTestApp<CR>
nnoremap<Leader>df :DjangoTestFile<CR>
nnoremap<Leader>dc :DjangoTestClass<CR>
nnoremap<Leader>dm :DjangoTestMethod<CR>
nnoremap<Leader>nf :NosetestFile<CR>
nnoremap<Leader>nc :NosetestClass<CR>
nnoremap<Leader>nm :NosetestMethod<CR>
nnoremap<Leader>rt :RerunLastTests<CR>
" jedi
let g:jedi#use_splits_not_buffers = "top"
" python mode: run PymodeLint
nnoremap<Leader>pl :PymodeLint<CR>
" vim-markdown-preview: use grip
let vim_markdown_preview_github=1
" jshint-vim: remove highlighting
let g:JSHintHighlightErrorLine = 1
" undotree
nnoremap <Leader>u :UndotreeToggle<CR>
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1