/
vimrc
executable file
·305 lines (244 loc) · 8.51 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
" vim: set foldmethod=marker foldlevel=0:
" set t_Co=256
colorscheme base16-solarized
set background=light
" Disable h and l
" nnoremap l <nop>
" nnoremap h <nop>
" Disable j and k
" nnoremap j <nop>
" nnoremap k <nop>
" ============================================================================
" PLUGINS {{{
" ============================================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'altercation/vim-colors-solarized'
Plugin 'gmarik/Vundle.vim'
Plugin 'chriskempson/base16-vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
" File system browsing with '-' hotkey
Plugin 'tpope/vim-vinegar'
Plugin 'scrooloose/nerdtree'
Plugin 'junegunn/goyo.vim'
Plugin 'mhinz/vim-startify'
Plugin 'bling/vim-airline'
Plugin 'kristijanhusak/vim-multiple-cursors'
Plugin 'scrooloose/syntastic'
Plugin 'godlygeek/tabular'
Plugin 'gregsexton/MatchTag'
Plugin 'docunext/closetag.vim'
" ctrlp
Plugin 'kien/ctrlp.vim'
" Autocompletion for braces, parenthesis, quotes, etc.
Plugin 'Raimondi/delimitMate'
" Javascript and Node
Plugin 'pangloss/vim-javascript'
Plugin 'jshint/jshint'
Plugin 'maksimr/vim-jsbeautify'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'digitaltoad/vim-jade'
" Latex
Plugin 'lervag/vimtex'
" Neocomplete
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
" UltiSnips
Plugin 'SirVer/ultisnips'
" Jinja2
Plugin 'Glench/Vim-Jinja2-Syntax'
" Ruby
Plugin 'vim-ruby/vim-ruby'
" ReactJS
Plugin 'mxw/vim-jsx'
call vundle#end()
filetype plugin indent on
" }}}
" ============================================================================
" BASIC OPTIONS {{{
" ============================================================================
syntax enable
set backspace=2
set top " The width of a TAB is set to 4.
set shiftwidth=4 " Number of spaces for a TAB
set softtabstop=4 " Number of spaces in TAB when editing
set expandtab " Expand TABs to spaces
set number " Show line numbers
set clipboard=unnamed " Share with system clipboard
set nrformats= " Don't use octal scheme for [num]<C-a> and <C-x>"
set display+=lastline " On long lines, always display them partially
" Disable backup and swap files
set nobackup
set nowritebackup
set noswapfile
" Return cursor to previous position on load
autocmd BufReadPost * normal `"
" Trim whitespace on save
autocmd BufWritePre * %s/\s\+$//e
" .ejs syntax
" au BufNewFile,BufRead *.ejs set filetype=html
" Set ruby index to be 2 spaces
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2
set encoding=utf-8
set guifont=Liberation\ Mono\ for\ Powerline:h14
" zsh completion menu on ex
set wildmenu
set wildmode=full
" }}}
" ============================================================================
" KEYBINDS {{{
" ============================================================================
" Leader mappings
let mapleader = "\<Space>"
nnoremap <Leader>w :w<CR>
nnoremap <Leader>g yyp
nnoremap <Leader>o o<Esc>
nnoremap <Leader>O O<Esc>
nnoremap <Leader>q :q<CR>
" Insert at end of line
nnoremap <Leader>; <S-a>;<Esc>
nnoremap <Leader>, <S-a>,<Esc>
" Plugin hotkeys
nnoremap <Leader>1 :Goyo<CR>
nnoremap <Leader>3 :call JsBeautify()<CR>
nnoremap <Leader>4 :SyntasticToggleMode<CR>
nnoremap <Leader>0 :PluginInstall<CR>
" Open Up Tabularize on command line
nnoremap <Leader>t :Tabularize/
" Call :UltiSnipsEdit to edit the current
" snippets file for the current extension.
nnoremap <Leader>use :UltiSnipsEdit<CR>
nnoremap <Leader>\\ <plug>(vimtex-compile-toggle)
nnoremap <Leader>c :SyntasticCheck<CR>
" Leader modify dotfiles
nnoremap <Leader>ev :e ~/.vimrc<CR>
nnoremap <Leader>eg :e ~/.gvimrc<CR>
nnoremap <Leader>ez :e ~/.zshrc<CR>
" Leader go to directory
nnoremap <Leader>er :e ~/Desktop/projects<CR>
nnoremap <Leader>el :e ~/Desktop/learn<CR>
nnoremap <Leader>ei :e ~/Desktop/interview-questions<CR>
nnoremap <Leader>ec :e ~/Desktop/projects/conf-main<CR>
nnoremap <Leader>esc :e ~/Dropbox/Spring2014/<CR>
" Split movement keybinds
nnoremap <Leader>j <C-w>j
nnoremap <Leader>k <C-w>k
" nnoremap <Leader>l <C-w>l
nnoremap <Leader>h <C-w>h
nnoremap <Leader>f <C-w>w
nnoremap <Leader>s <C-w>s
nnoremap <Leader>v <C-w>v
" Function comment
nnoremap <Leader>z o// ------------------------------<CR>------------------------------<Esc>O
" Buffer mappings
nnoremap H :bprevious<CR>
nnoremap L :bn<CR>
" Movement
nnoremap <D-j> 5jzz
nnoremap <D-k> 5kzz
" Close current buffer and move to next one
nnoremap <Leader>x :bn <BAR> bd #<CR>
inoremap {<CR> {<CR>}<C-o>O
" Insert a new line under without going into insert mod>
nmap <S-Enter> o<Esc>
" Use arrow keys to resize windows.
noremap <up> <C-W>+
noremap <down> <C-W>-
noremap <left> 3<C-W><
noremap <right> 3<C-W>>
" Date time insertions
" imap <Leader>;ds <C-R>=strftime("%Y-%m-%d %T")<CR>
" }}}
" ============================================================================
" SYNTASTIC {{{
" ============================================================================
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
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 = ['jshint']
let g:syntastic_javascript_checkers = ['jsxhint']
let g:syntastic_mode_map = { 'mode': 'passive' }
" }}}
" ============================================================================
" ============================================================================
" AIRLINE {{{
" ============================================================================
let g:airline_powerline_fonts = 1
" set laststatus=2
" List buffers on the top
let g:airline#extensions#tabline#enabled = 1
" Show just filename
let g:airline#extensions#tabline#fnamemod = ':t'
" }}}
" ============================================================================
" NERDTREE {{{
" ============================================================================
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
" }}}
" ============================================================================
" ULTISNIPS {{{
" ============================================================================
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" }}}
" ============================================================================
" CTRL-P {{{
" ============================================================================
" Setup some default ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn|DS_Store)|\_site\|node_modules)$',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$',
\}
" Use ag search. Must install from https://github.com/ggreer/the_silver_searcher.
" Makes Ctrl-P MUCH faster
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'
" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is
" in version control. It also supports works with .svn, .hg, .bzr.
let g:ctrlp_working_path_mode = 'r'
" }}}
" ============================================================================
" STARTIFY {{{
" ============================================================================
let g:startify_custom_header = [
\' Welcome to Vim, Keith!',
\' ']
" }}}
" ============================================================================
" AUTO-SAVE OPTIONS {{{
" ============================================================================
:au FocusLost * :wa
inoremap <Esc> <Esc>:w<CR>
:hi NonText guifg=bg
" }}}
" ============================================================================
" ============================================================================
" COMMENTARY {{{
" ============================================================================
" Neocomplete integration
autocmd FileType html setlocal commentstring=<!--\ %s\ -->
" }}}
" ============================================================================
" closetag {{{
" ============================================================================
" Source closetag script
au Filetype html,xml,xsl source ~/.vim/bundle/closetag.vim/plugin/closetag.vim
" }}}