-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
313 lines (281 loc) · 7.67 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
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
scriptencoding utf-8
"
" .vimrc
"
" Author: Jair Trejo <[email protected]>
"
"
" Preamble
"
" Pathogen
call pathogen#infect()
" Not compatible with vi, cause it's 2012
set nocompatible
" Syntax coloring
syntax on
" Filetype specific plugins
filetype plugin on
" Indentation by filetype
filetype indent on
"
" Basic configuration
"
" Default encoding
set encoding=utf-8
" Backspace support
set backspace=indent,eol,start
" Window title changes to the file I'm editing
set title
" No backups are stored (I save all the time).
set nobackup
" No swap files are written, they tend to litter my projects
set noswapfile
" Relative line numbers (LN is displayed on the status bar)
set relativenumber
" Change to absolute line numbers when vim loses focus.
:au FocusLost * :set number
:au FocusGained * :set relativenumber
" Extraneous whitespace is displayed with special chars.
set list
set listchars=tab:▸\ ,trail:.,eol:\ ,nbsp:.
" Highlight column 80.
set cc=80
" Show a nice 'enter' char on wrapping lines.
set showbreak=↪
" Save on focus lost
au FocusLost * :wa
" Force 256 colors
set t_Co=256
" I like dark backgrounds.
set background=dark
" My prefered colorscheme
colorscheme Tomorrow-Night
" Nice vsplit separator
set fillchars+=vert:│
" Show matched parentheses
set showmatch
" Four space tabs
set et
set sw=4
set smarttab
" Line Return
" 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
" Scrolling
set scrolloff=3
" Command for editing over FTP.
let g:netrw_ftp_cmd="ftp -p"
"
" Search
"
" Sane regexes
nnoremap / /\v
vnoremap / /\v
" Case sensitive search, but ignores capitalization if whole search
" term uses the same case.
set ignorecase
set smartcase
" Incremental search
set incsearch
" Keep search matches in the middle of the window and pulse the line
" when moving to them.
nnoremap n nzzzv
nnoremap N Nzzzv
" highlight search ocurrences
set hlsearch
" De-highligt with Ctr+L
nnoremap <silent> <C-l> :nohl<CR><C-l>
"
" Wildmenu
"
set wildmode=list:full
set wildmenu
set wildignore+=*.pyc
set wildignore+=migrations
set wildignore+=env,virtualenv
set wildignore+=htmlcov
set wildignore+=node_modules,bower_components,build
set wildignore+=.hg,.git,.svn
set wildignore+=*.aux,*.out,*.toc
set wildignore+=*.jpg,*.png,*.gif
set wildignore+=TwitterKit.framework,TwitterCore.framework
"
" Status line
"
set laststatus=2
set rtp+=/Users/jair/.pyenv/versions/default/lib/python2.7/site-packages/powerline/bindings/vim
"
" Remaps
"
" Leader key remap
let mapleader = ";"
" Reselect text that was just pasted
map ,v V`]
" Select (charwise) the contents of the current line, excluding indentation.
nnoremap vv ^vg_
" Mappings for jumping to the begginning/end of a line
noremap H ^
noremap L g_
" D deletes to the end of the line.
nnoremap D d$
" j,k moves between 'screen lines' not 'file lines'.
noremap j gj
noremap k gk
noremap <Up> gk
noremap <Down> gj
" Easier use of tabs.
map <silent><Right> :tabnext<CR>
map <silent><Left> :tabprevious<CR>
map <silent><Up> :tabnew<CR>
map <silent><Down> :tabclose<CR>
" Remap para easy-motion.
let g:EasyMotion_leader_key = ','
" NERDTree.
map <F3> :NERDTreeToggle<CR>
" Tagbar.
map <F4> :TagbarToggle<CR>
" Yankring
map <F6> :YRShow<CR>
" CtrlP
let g:ctrlp_map = '<leader>t'
"
" Omnicompletion.
"
inoremap <Nul> <C-x><C-o>
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
set completeopt-=preview
"
" Filetype specific
"
" PHP
" Syntax highlighting for SQL & HTML inside PHP strings.
let php_sql_query=1
let php_htmlInStrings=1
" Python
" Syntax highlighting
let python_highlight_all = 1
" Run current file through python interpreter.
map <F5> :!python %<CR>
" Strips whitespace from files before saving.
autocmd BufWritePre *.py :%s/\s\+$//e
" Folding
let g:SimpylFold_docstring_preview = 1
" Jedi vim
let g:jedi#use_tabs_not_buffers = 1
" Django
" Commands for quickly setting django type.
nnoremap _dt :set ft=htmldjango<CR>
nnoremap _pd :set ft=python.django<CR>
" Set filetype when editing typical django files
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead forms.py setlocal filetype=python.django
" LaTeX
" For LaTeX files, doesn't try to break pasted lines, however long.
autocmd BufRead *\.tex,*\.txt,*\.mkd setlocal formatoptions=l
" For LaTeX files, breaks lines on breakat rather than
" the last char that fits on screen.
autocmd BufRead *\.tex,*\.txt,*\.mkd setlocal lbr
" Markdown
" Automatic > section continuations for Markdown.
autocmd BufRead *\.mkd,*\.md set ai formatoptions=tcroqn2 comments=n:>
" Mapping for setting markdown filetype (useful for scratchpad)
nnoremap _md :set ft=markdown<CR>
" Arduino
" Set filetype to arduino for pde files.
au BufNewFile,BufRead *.pde setf arduino
" Vagrant
" Set Vagrantfile's filetype to Ruby.
augroup ft_vagrant
au!
au BufRead,BufNewFile Vagrantfile set ft=ruby
augroup END
" HTML
" Prevent vim from reindenting previous line
autocmd FileType html setlocal indentkeys-=*<Return>
" Clojure
" Fireplace mappings
autocmd FileType clojure nnoremap <C-e> :Eval<CR>
autocmd FileType clojure nnoremap E :%Eval<CR>
" JSX
" All files
let g:jsx_ext_required = 0
" Removes horrible ^ characters from the status line of active buffers.
set fillchars+=stl:\ ,stlnc:\
" Clam mapping
nnoremap ! :Clam<space>
" Mapping for vimux
map ;p :VimuxPromptCommand<CR>
map ;; :VimuxRunLastCommand<CR>
" Disentangle the screen connundrum (stolen from Steve Losh):
nnoremap U :syntax sync fromstart<cr>:redraw!<cr>
" Remapping of ` and ' for easy '.
nnoremap ' `
nnoremap ` '
" Quickfix and location list navigation
map ]l :lnext<CR>
map [l :lprev<CR>
map ]q :cnext<CR>
map [q :cprev<CR>
" Only show cursorline in the current window and in normal mode.
augroup cline
au!
au WinLeave * set nocursorline
au WinEnter * set cursorline
au InsertEnter * set nocursorline
au InsertLeave * set cursorline
augroup END
" Trailing whitespace only shown when not in insert mode so I don't go insane.
augroup trailing
au!
au InsertEnter * :set listchars-=trail:.
au InsertLeave * :set listchars+=trail:.
augroup END
" Better looking error highlighting
highlight SpellBad term=underline gui=undercurl guisp=Orange
" Syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_html_checkers = []
" The silver searcher with ack.vim
let g:ackprg = 'ag --nogroup --nocolor --column'
" Goyo + Limelight
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" GVim
if has('gui_running')
" Font for gvim.
set guifont=Monaco\ for\ Powerline:h13
" Removes unwanted interface elements from gvim.
set guioptions-=T
set guioptions-=m
set guioptions-=F
set guioptions-=r
else
" Mouse support
set mouse=a
" Handle tmux $TERM quirks in vim
if $TERM =~ '^screen-256color'
map <Esc>OH <Home>
map! <Esc>OH <Home>
map <Esc>OF <End>
map! <Esc>OF <End>
endif
end