Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
391 lines (311 loc) · 10.6 KB
/
Copy pathvimrc
File metadata and controls
391 lines (311 loc) · 10.6 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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
" vimrc
" Author: Aliou Diallo <aliou@aliou.me>
" Source: https://github.com/aliou/dotvim/blob/master/vimrc
" Init -------------------------------------------------------------------- {{{
set nocompatible
filetype off
" }}}
" Vundle ---------------------------------------------------------------- {{{
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'sjl/clam.vim'
Bundle 'sjl/gundo.vim'
Bundle 'kien/ctrlp.vim'
Bundle 'bling/vim-airline'
Bundle 'tpope/vim-surround'
Bundle 'scrooloose/nerdtree'
Bundle 'tomtom/tcomment_vim'
Bundle 'tpope/vim-obsession'
Bundle 'scrooloose/syntastic'
Bundle 'sheerun/vim-polyglot'
" Colors
Bundle 'sjl/badwolf'
Bundle 'tomasr/molokai'
Bundle 'godlygeek/csapprox'
Bundle 'nanotech/jellybeans.vim'
Bundle 'chriskempson/base16-vim'
syntax on
filetype indent plugin on
" }}}
" Basic options ----------------------------------------------------------- {{{
let mapleader = "," " <Leader> key.
set autoread " Update modified files outside of VIM.
set cursorline " Highlight current line.
set textwidth=80 " Character limit.
set colorcolumn=+1 " Highlight character limit.
set hidden " Allow buffers to be in the background without saving.
set laststatus=2 " Show status bar.
set cmdheight=2 " Status line height.
set noshowmode " Hide current mode.
set number " Show line number.
set showcmd " Show current command.
set list " Show invisible characters.
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮ " Invisible character list.
set ruler " Show line and column in status bar.
set background=dark "
set t_Co=256 " Use 256 colors.
set scrolloff=999 " Keep the cursor centered in the screen
set showbreak=↪ " The character to put to show a line has been wrapped
set showmatch " Highlight matching braces
set matchtime=5 "
set vb t_vb= " SHUT THE FUCK UP.
set novisualbell " SHUT THE FUCK UP.
set encoding=utf-8 " Character encoding.
set shortmess=filtoOA " Short message.
set report=0 " Report all changes.
set notimeout " Timeout on key codes.
set ttimeout
set ttimeoutlen=10
set bs=indent,eol,start " Backspace over everything in insert mode.
" }}}
" Backups ----------------------------------------------------------------- {{{
set backup " Enable backups for Gundo (AKA Lifesaver).
set undofile " Save the file.
set noswapfile " HOW ABOUT FUCK YOU.
set undodir=~/.vim/tmp/undo// " Undodir
set backupdir=~/.vim/tmp/backup// " Backupdir.
set directory=~/.vim/tmp/swap// " Swapfile.
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
" }}}
" Search ------------------------------------------------------------------ {{{
set hlsearch " Highlight results
set ignorecase " Ignore casing of searches
set incsearch " Start showing results as you type
set smartcase " Be smart about case sensitivity when searching
set nostartofline " Don't go back to the start of the line.
set gdefault " Substitution is global by default. g to toggle.
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' " Match git conflict shit.
" Visual search. Stolen from @sjl.
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
" }}}
" Tabs -------------------------------------------------------------------- {{{
set autoindent " Copy indentation for new line.
set smartindent " Autoindent.
set shiftwidth=2 " Number of spaces for indent.
set tabstop=2
set expandtab
" }}}
" Wildmenu completion ----------------------------------------------------{{{
set wildmenu " Comandline completion.
set wildmode=list:longest,full " Show a list and match the longest first.
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.out " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set whichwrap+=<,>,h,l,[,] " Wrap chars.
" }}}
" Map --------------------------------------------------------------------- {{{
" Qwerty keyboard.
nnoremap ; :
vnoremap ; :
" Out of insert mode.
inoremap jj <ESC>
inoremap kk <ESC>
" Word wrapping.
noremap j gj
noremap k gk
noremap gj j
noremap gk k
" Stay in visual mode when identing.
vnoremap > >gv
vnoremap < <gv
" Stay in middle of window.
" nnoremap n nzzzv
" nnoremap N Nzzzv
noremap <Leader>a ggVG " Select all file.
" Splits.
nnoremap <silent> ss :split<CR><C-W>j
nnoremap <silent> vv :vsplit<CR><C-W>l
nnoremap <silent> // :nohlsearch<CR> " Remove search highligts.
nnoremap <leader>qq :cclose<CR> " Close quickfix window.
nnoremap <Leader><Leader> <C-^> " Switch to alternate file.
nnoremap <silent> <Leader>w :bp<CR> " Previous tab. (AZERTY)
nnoremap <silent> <Leader>z :bp<CR> " Previous tab. (QWERTY)
nnoremap <silent> <Leader>x :bn<CR> " Next tab.
nnoremap * *<c-o> " Don't go to next match.
nnoremap <silent> <leader>d :cd %:p:h<cr> " cd into current file directory.
nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w " Split current line.
" Magic.
nnoremap / /\v
vnoremap / /\v
nnoremap ? ?\v
vnoremap ? ?\v
" Resize splits.
if bufwinnr(1)
noremap + <C-W>+
noremap - <C-W>-
endif
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
" Open help in vertical split.
cnoremap vhelp vert bo help
" Open tag in right vertical split.
nnoremap <c-\> <c-w>v<c-w><c-l><c-]><c-w><c-h>
" Tabs
nnoremap T :tabnew<cr>
nnoremap H :tabprev<cr>
nnoremap L :tabnext<cr>
" Search for visual block.
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
" SHUT THE FUCK UP.
nnoremap Q <NOP>
" Quick file opening.
nnoremap <leader>lv :tabedit $MYLOCALVIMRC<cr>
nnoremap <leader>gv :tabedit $MYVIMRC<cr>
" Fold maps.
nnoremap <leader>f mfggvGzO`f
nnoremap <Space> za
command! SS set spell!
command! TMC set list! number!
" }}}
" <Fx> Maps {{{
inoremap <F2> <ESC>:NERDTreeToggle<CR>
nnoremap <F2> :NERDTreeToggle<CR>
inoremap <F3> <ESC>:w<CR>:! clear ; echo '\#use "%";;' \| ocaml<cr>
nnoremap <F3> :w<cr>:! clear ; echo '\#use "%";;' \| ocaml<cr>
inoremap <F4> <ESC>:set paste!<CR>i
nnoremap <F4> :set paste!<CR>
inoremap <F5> <ESC>:GundoToggle<CR>
nnoremap <F5> :GundoToggle<CR>
" Remap W to w and Q to q so vim shuts the fuck up.
command W w
command Q q
" }}}
" autocmd ----------------------------------------------------------------- {{{
" Files ------------------------------------------------------------- {{{
augroup someshit
autocmd!
autocmd FileType make setlocal ts=4 sts=4 sw=4 noexpandtab
autocmd BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru}
\ set ft=ruby
autocmd BufRead,BufNewFile *.{md,markdown,mdown} set ft=markdown
autocmd Filetype markdown setlocal spell
autocmd Filetype markdown setlocal textwidth=90000
autocmd filetype gitcommit setlocal textwidth=72
autocmd filetype gitcommit setlocal spell
autocmd BufNewFile,BufRead *.json set filetype=json
autocmd FileType * autocmd InsertLeave * silent! wa
augroup END
augroup dennisritchie
autocmd BufWritePost *.c,*.cpp,*.h,*.hh,*.hpp
\ silent! !ctags -R --exclude=*.so* .
autocmd FileType c,cpp
\ nnoremap <localleader>k :silent Clam man <C-r><C-w><CR>gg:set ft=man<CR>
augroup END
" }}}
" Interface --------------------------------------------------------- {{{
augroup position
autocmd!
" Restore cursor position.
autocmd BufReadPost *
\ if &filetype !~ '^git\c' &&
\ line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Resize splits when window is resized.
autocmd VimResized * :wincmd =
augroup END
" }}}
" Folds -------------------------------------------------------------- {{{
" Unfold whole file.
set foldlevelstart=1
augroup filtypes
autocmd!
autocmd FileType c,cpp,cs,javascript setlocal foldmethod=marker foldmarker={,}
autocmd Filetype less,css setlocal foldmethod=marker foldmarker={,}
autocmd Filetype vim setlocal foldmethod=marker
autocmd FileType html setlocal foldmethod=indent
autocmd FileType ruby setlocal foldmethod=syntax
autocmd Filetype ocaml setlocal foldmethod=expr foldexpr=OMLetFoldLevel(v:lnum)
augroup END
" }}}
" }}}
" Plugin config ---------------------------------------------------------- {{{
" Clam {{{
" Maps ! to Clam or ClamVisual depending on the mode.
nnoremap ! :Clam<space>
vnoremap ! :ClamVisual<space>
" }}}
" CtrlP {{{
nnoremap <Leader>t :CtrlP<cr>
" Uses the current working directory as root folder.
let g:ctrlp_cmd = 'CtrlPCurWD'
" Additional mapping for tag search
nnoremap <Leader>y :CtrlPTag<cr>
" Additional mapping for buffer search
nnoremap <leader>b :CtrlPBuffer<cr>
" Change the listing order of the files in the match window.
let g:ctrlp_match_window_reversed = 0
" The maximum number of files to scan, set to 0 for no limit: >
let g:ctrlp_max_files = 200
" Ignore these specific files and folders..
let g:ctrlp_custom_ignore = {
\ 'dir': '\v([\/]\.(git|hg|svn)|view|tmp|node_modules|venv|_site)$',
\ 'file': '\v\.(o|exe|netrwhist)|tags$',
\ }
let g:ctrlp_extensions = ['tag']
" }}}
" Syntastic {{{
" Syntax check on opening and saving buffers.
let g:syntastic_check_on_open=1
" Uses the sign interface to mark syntax errors.
let g:syntastic_enable_signs=1
" Don't check syntax for these filetypes.
let g:syntastic_mode_map = { "mode": "active",
\ "active_filetypes": [],
\ "passive_filetypes": ['html', 'css'] }
" Customize warning and error gutter symbols.
let g:syntastic_warning_symbol='⚠'
let g:syntastic_error_symbol='✗'
" }}}
" tComment {{{
" Comment current line or selection.
map <Leader>c <C-_><C-_>
" }}}
" NERDTree {{{
let NERDTreeWinPos = "left"
let NERDTreeIgnore = ['\~$', '*.o']
" }}}
" Ocaml Fold {{{
augroup ocaml
autocmd!
autocmd FileType ocaml let g:ocaml_folding = 1
augroup END
" }}}
" Airline {{{
let g:airline_theme="bubblegum"
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.whitespace = 'Ξ'
let g:airline_symbols.paste = 'ρ'
let g:airline#extensions#whitespace#trailing_format = '[%s]'
let g:airline#extensions#whitespace#mixed_indent_format = '[%s]'
" }}}
" }}}
" Local shit ------------------------------------------------------------- {{{
" Source local file if it exists.
if filereadable(glob("~/.vimrc.local"))
let $MYLOCALVIMRC="~/.vimrc.local"
source $MYLOCALVIMRC
endif
" }}}