This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
454 lines (376 loc) · 13.3 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
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
" vim: tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
" Basic Vim Configuration File
" Initially done for NeoVim
" A lot is shamelessly taken from Steve Francia's Spf13-Vim
" Initial Setup {{{
" Leaders {{{
" Setting up the leader and localleader
let mapleader = "\<Space>"
let maplocalleader = "_"
" }}}
" Putting configuration here as some plugins depend on it
set ignorecase
set smartcase
" }}}
" NeoBundle setup {{{
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
" Start NeoBundle
call neobundle#begin(expand('~/.vim/bundle'))
NeoBundleFetch 'Shougo/neobundle.vim'
" }}}
" Plugins {{{
" A list of plugins by tpope
NeoBundle 'tpope/vim-sensible'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-abolish'
NeoBundle 'tpope/vim-unimpaired'
NeoBundle 'tpope/vim-commentary'
NeoBundle 'tpope/vim-vinegar'
NeoBundle 'tpope/vim-scriptease'
NeoBundle 'tpope/vim-sleuth'
NeoBundle 'tpope/vim-markdown'
NeoBundle 'gkz/vim-ls'
" Vim TMUX navigator
NeoBundle 'christoomey/vim-tmux-navigator'
" Vim Airline and Vim Bufferline
NeoBundle 'bling/vim-airline'
NeoBundle 'bling/vim-bufferline'
" Solarized color scheme
NeoBundle 'altercation/vim-colors-solarized'
" Deal with syntax files once and for all
NeoBundle 'sheerun/vim-polyglot'
" Racket support
NeoBundle 'wlangstroth/vim-racket'
" Signify changes with vcs
NeoBundle 'mhinz/vim-signify'
" Plugins By Shougo
" NeoBundle 'Shougo/neocomplcache.vim'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" Unite quickfix source
NeoBundle 'osyo-manga/unite-quickfix'
" Add neco-ghc
NeoBundle 'eagletmt/neco-ghc'
NeoBundle 'eagletmt/ghcmod-vim'
" YouCompleteMe
NeoBundle 'Valloric/YouCompleteMe', {
\ 'build' : {
\ 'mac' : './install.sh'
\ },
\ }
" UndoTree
NeoBundle 'mbbill/undotree'
" Tabular
NeoBundle 'godlygeek/tabular'
" Latex Support
NeoBundle 'LaTeX-Box-Team/LaTeX-Box'
" Goyo and Limelight
NeoBundle 'junegunn/goyo.vim'
NeoBundle 'junegunn/limelight.vim'
" Syntastic
NeoBundle 'scrooloose/syntastic'
" Adding support for unicode
NeoBundle 'chrisbra/unicode.vim'
" Y U NO COMMIT plugin
NeoBundle 'esneider/YUNOcommit.vim'
"JSX Plugin
NeoBundle 'mxw/vim-jsx'
" }}}
" NeoBundle End {{{
call neobundle#end()
" Set that just to be safe
filetype plugin indent on
" Check for uninstalled bundles
NeoBundleCheck
" }}}
" Global Key Maps {{{
" jk is esc, always
inoremap jk <esc>
" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" Turn of the highlight for the search
nmap <silent> <leader>/ :set invhlsearch<CR>
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Allow using the repeat operator with a visual selection (!)
" http://stackoverflow.com/a/8064607/127816
vnoremap . :normal .<CR>
" }}}
" General {{{
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history (default is 20)
set spell " Spell checking on
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" Setting up the directories {{{
set backup
if has('persistent_undo')
set undofile
set undolevels=1000
set undoreload=10000
endif
" }}}
" }}}
" Setting up Vim UI {{{
" Set default background to dark
set background=dark
" Ensure that the background is set properly
if filereadable(expand("~/.vimrc.background"))
source ~/.vimrc.background
endif
" Fixing the colorscheme {{{
function! s:fix_color_scheme()
highlight clear SignColumn
highlight clear LineNr
" Fixing the color of the omnicomplete window
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
endfunction
augroup FixingColorScheme
autocmd!
autocmd ColorScheme * call <SID>fix_color_scheme()
augroup END
" }}}
" Setting up solarized color scheme" {{{
if filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized
endif
" }}}
set tabpagemax=15
set cursorline
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
endif
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=%{fugitive#statusline()} " Git Hotness
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
set backspace=indent,eol,start " Backspace for dummies
set linespace=0 " No extra spaces between rows
set nu " Line numbers on
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
set foldenable " Auto fold code
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
" }}}
" Displaying Text {{{
set nowrap
set nojoinspaces
set splitright
set splitbelow
set pastetoggle=<F12>
" }}}
" Configuration {{{
" Fugitive {{{
if isdirectory(expand("~/.vim/bundle/vim-fugitive/"))
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
" Mnemonic _i_nteractive
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gg :SignifyToggle<CR>
endif
" }}}
" YouCompleteMe {{{
let g:acp_enableAtStartup = 0
" Use proper completion function for haskell
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
let g:ycm_semantic_triggers = {'haskell' : ['.']}
" }}}
" UndoTree {{{
if isdirectory(expand("~/.vim/bundle/undotree/"))
nnoremap <Leader>u :UndotreeToggle<CR>
" If undotree is opened, it is likely one wants to interact with it.
let g:undotree_SetFocusWhenToggle=1
endif
" }}}
" vim-airine {{{
if isdirectory(expand("~/.vim/bundle/vim-airline/"))
if !exists('g:airline_theme')
let g:airline_theme = 'solarized'
endif
" Use the default set of separators with a few customizations
let g:airline_left_sep=''
let g:airline_right_sep=''
endif
" }}}
" Syntastic {{{
let g:syntastic_haskell_checkers=[]
" }}}
" Latex-Box {{{
let g:LatexBox_viewer = "open"
augroup my_latex
autocmd!
autocmd FileType tex nnoremap <silent> <LocalLeader>ls :silent
\ !/Applications/Skim.app/Contents/SharedSupport/displayline
\ <C-R>=line('.')<CR> "<C-R>=LatexBox_GetOutputFile()<CR>"
\ "%:p" <CR>:redraw!<CR>
autocmd FileType tex set textwidth=79
augroup END
" }}}
" Goyo and Limelight {{{
" Setting up default limelight
let g:limelight_conceal_ctermfg = 'Grey'
let g:limelight_conceal_guifg = 'DarkGrey'
let g:limelight_default_coefficient = 0.7
" Setting up the distraction free writing
function! s:goyo_enter()
" Go to the beginning of the line --- prevents usually shifted screen
normal ^
Limelight
endfunction
function! s:goyo_leave()
Limelight!
endfunction
autocmd! User GoyoEnter
autocmd! User GoyoLeave
autocmd User GoyoEnter call <SID>goyo_enter()
autocmd User GoyoLeave call <SID>goyo_leave()
let g:goyo_width = 100
nnoremap <Leader>, :Goyo<CR>
" }}}
" ghcmod.vim {{{
let g:ghcmod_open_quickfix_function = 'GhcModQuickFix'
function! GhcModQuickFix()
:Unite -no-empty -no-quit -direction=botright quickfix -wrap
endfunction
function! GhcModBufWritePost()
if !exists("b:ghcmod_disable") && !exists("g:ghcmod_disable")
if exists("b:ghcmod_lint_only") || exists("g:ghcmod_lint_only")
:GhcModLint
else
:GhcModCheckAndLintAsync
endif
endif
endfunction
" Automatically check haskell files
autocmd BufWritePost *.hs call GhcModBufWritePost()
" }}}
" Markdown {{{
augroup markdown
autocmd!
" Adding support for Marked.app
autocmd FileType markdown :nnoremap <Leader>m :silent !open -a Marked\ 2 '%:p'<CR>:redraw!<CR>
" autocmd FileType markdown set wrap linebreak nolist
autocmd FileType markdown set wrap linebreak
" Add additional row below the row -- still not shure how to solve this
" one
" autocmd FileType markdown :nnoremap <Leader>h yypVr-<CR>
" autocmd FileType markdown :nnoremap <Leader>H yypVr=<CR>
" Adding shortcuts for underlying
if has("gui_running")
autocmd FileType markdown let &showbreak='↳'
else
autocmd FileType markdown let &showbreak='↳ '
endif
augroup END
" }}}
" }}}
" GUI Settings {{{
" GVIM- (here instead of .gvimrc)
if has('gui_running')
set guioptions-=T " Remove the toolbar
set lines=40 " 40 lines of text instead of 24
if !exists("g:spf13_no_big_font")
if has("gui_running")
set guifont=Andale\ Mono\ Regular:h12,Menlo\ Regular:h11,Consolas\ Regular:h12,Courier\ New\ Regular:h14
endif
endif
else
if &term == 'xterm' || &term == 'screen'
set t_Co=256 " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
endif
"set term=builtin_ansi " Make arrow and other keys work
endif
" }}}
" Initialize directories {{{
function! InitializeDirectories()
let parent = $HOME
let prefix = 'vim'
let dir_list = {
\ 'backup': 'backupdir',
\ 'views': 'viewdir',
\ 'swap': 'directory' }
if has('persistent_undo')
let dir_list['undo'] = 'undodir'
endif
" To specify a different directory in which to place the vimbackup,
" vimviews, vimundo, and vimswap files/directories, add the following to
" your .vimrc.before.local file:
" let g:spf13_consolidated_directory = <full path to desired directory>
" eg: let g:spf13_consolidated_directory = $HOME . '/.vim/'
if exists('g:spf13_consolidated_directory')
let common_dir = g:spf13_consolidated_directory . prefix
else
let common_dir = parent . '/.' . prefix
endif
for [dirname, settingname] in items(dir_list)
let directory = common_dir . dirname . '/'
if exists("*mkdir")
if !isdirectory(directory)
call mkdir(directory)
endif
endif
if !isdirectory(directory)
echo "Warning: Unable to create backup directory: " . directory
echo "Try: mkdir -p " . directory
else
let directory = substitute(directory, " ", "\\\\ ", "g")
exec "set " . settingname . "=" . directory
endif
endfor
endfunction
call InitializeDirectories()
" }}}