-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
583 lines (494 loc) · 20.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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
" .vimrc {
" vim: set sw=4 ts=4 sts=4 et foldmarker={,} foldlevel=1 foldmethod=marker nospell:
" }
" Environment {
silent function! OSX()
return has('macunix')
endfunction
silent function! LINUX()
return has('unix') && !has('macunix') && !has('win32unix')
endfunction
" }
" Plugins {
set nocompatible
filetype off
" Set the runtime path to include Plug and initialize
call plug#begin('~/.vim/plugged')
" Performance?
" Plug 'metakirby5/codi.vim'
Plug 'joshdick/onedark.vim'
Plug 'itchyny/lightline.vim'
Plug 'sheerun/vim-polyglot'
" Plug 'jby/tmux.vim'
Plug 'tpope/vim-git'
Plug 'tacahiroy/ctrlp-funky'
Plug 'kristijanhusak/vim-multiple-cursors'
" SLOW?
" Plug 'nathanaelkane/vim-indent-guides'
Plug 'mhinz/vim-signify'
" Plug 'klen/python-mode', { 'branch': 'develop' }
Plug 'szw/vim-ctrlspace'
" Plug 'elixir-lang/vim-elixir'
" Performance?
" Plug 'dhruvasagar/vim-table-mode'
" Plug 'chrisbra/csv.vim'
" Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
" https://github.com/ctrlpvim/ctrlp.vim
Plug 'ctrlpvim/ctrlp.vim'
" Search local vimrc files (".lvimrc") in the tree (root dir up to current dir) and load them.
" https://github.com/embear/vim-localvimrc
Plug 'embear/vim-localvimrc'
" This is an EditorConfig plugin for Vim.
" https://github.com/editorconfig/editorconfig-vim
Plug 'editorconfig/editorconfig-vim'
" Numbers.vim is a plugin for intelligently toggling line numbers.
" https://github.com/myusuf3/numbers.vim
" SLOW?
" Plug 'myusuf3/numbers.vim'
" A tree explorer plugin for vim.
" https://github.com/scrooloose/nerdtree
Plug 'scrooloose/nerdtree'
" Commentary.vim: comment stuff out
" https://github.com/tpope/vim-commentary
Plug 'tpope/vim-commentary'
" Vim plugin for the Perl module / CLI script 'ack' (ag)
" https://github.com/mileszs/ack.vim
Plug 'mileszs/ack.vim'
" A plugin of NERDTree showing git status flags.
" https://github.com/Xuyuanp/nerdtree-git-plugin
Plug 'Xuyuanp/nerdtree-git-plugin'
" Plug 'scrooloose/syntastic'
Plug 'benekastah/neomake'
Plug 'tpope/vim-fugitive'
" Plug 'majutsushi/tagbar'
" Plug 'pangloss/vim-javascript'
" Plug 'cakebaker/scss-syntax.vim'
" Plug 'tpope/vim-haml'
" Plug 'styled-components/vim-styled-components'
" Plug 'digitaltoad/vim-jade'
" Plug 'fatih/vim-go'
" Set colornum based on mode
" Plug 'Shougo/deoplete.vim'
" Plug 'Valloric/YouCompleteMe', {'do': './install.py'}`
" Distraction-free writing in Vim.
" Plug 'junegunn/goyo.vim'
" Plug 'junegunn/vim-emoji'
" Plug 'wesQ3/vim-windowswap'
call plug#end()
filetype plugin indent on
" }
" General {
" Disable some keys {
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
nnoremap Q <nop>
noremap <space> <nop>
sunmap <space>
" }
" Behavior {
" set t_Co=256 " Number of colors
scriptencoding utf-8 " Specify the character encoding used in the script.
set fileformats=unix,dos,mac " This gives the end-of-line (<EOL>) formats that will be tried when starting to edit
let mapleader = "\<Space>" " To define a mapping which uses the mapleader variable, the special string <Leader> can be used.
set shell=/bin/sh
set shortmess+=filmnrxoOtTI " 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 nospell " Spell checking off
set hidden " Allow buffer switching without saving
set backspace=indent,eol,start " Backspace for dummies
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set grepprg=ag\ --nogroup\ --nocolor " Program to use for the |:grep| command.
set timeout timeoutlen=1000 ttimeoutlen=100
set clipboard=
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
syntax enable
set nofoldenable
" set foldlevelstart=0
" Backups
set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" Initialize directories {
" Copy from https://github.com/spf13/spf13-vim/blob/3.0/.vimrc#L1041
function! InitializeDirectories()
let prefix = 'vim'
let common_dir = $HOME . '/.vim/.' . prefix
let dir_list = {
\ 'backup': 'backupdir',
\ 'views': 'viewdir',
\ 'swap': 'directory' }
if has('persistent_undo')
let dir_list['undo'] = 'undodir'
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()
" }
" }
" UI {
syntax on
if has('termguicolors') " set true colors
set t_8f=[38;2;%lu;%lu;%lum
set t_8b=[48;2;%lu;%lu;%lum
set termguicolors
endif
colorscheme onedark
set nowrap " Do not wrap long lines
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
set showbreak=↪ " String to put at the start of lines that have been wrapped.
set cursorline " Highlight current line
set tabpagemax=15 " Only show 15 tabs
set cmdheight=2 " Number of screen lines to use for the command-line.
set ruler " Show the ruler (N/A: vim-lightline)
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids (N/A: vim-lightline)
set showcmd " Show partial commands in status line and Selected characters/lines in visual mode
set showmatch " Show matching brackets/parenthesis
set linespace=0 " No extra spaces between rows (only gui)
set number " Line numbers on
set winminheight=0 " Windows can be 0 line high
set scrolljump=1 " Lines to scroll when cursor leaves screen
set scrolloff=5 " Minimum lines to keep above and below cursor
set sidescroll=1 " The minimal number of columns to scroll horizontally.
set sidescrolloff=15 " Columns on horizonal scroll
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
set laststatus=2
set noshowmode " Display the current mode (N/A: vim-lightline)
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 list " Useful to see the difference between tabs and spaces and for trailing blanks.
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
set mouse="" " Disable mouse
set noerrorbells " Disable Ring the bell (beep or screen flash) for error messages.
set novisualbell " Disable visual bell
" }
" Keys {
" Wrapped lines goes down/up to next row, rather than next line in file.
" noremap j gj
" noremap k gk
" Visual Search {
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSelection('gv')<CR>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
" }
" Paste
vmap <Leader>y "*y
nmap <Leader>p "*p
nmap <Leader>P "*P
vmap <Leader>p "*p
vmap <Leader>P "*P
" Code folding options
nmap <Leader>f0 :set foldlevel=0<CR>
nmap <Leader>f1 :set foldlevel=1<CR>
nmap <Leader>f2 :set foldlevel=2<CR>
nmap <Leader>f3 :set foldlevel=3<CR>
nmap <Leader>f4 :set foldlevel=4<CR>
nmap <Leader>f5 :set foldlevel=5<CR>
nmap <Leader>f6 :set foldlevel=6<CR>
nmap <Leader>f7 :set foldlevel=7<CR>
nmap <Leader>f8 :set foldlevel=8<CR>
nmap <Leader>f9 :set foldlevel=9<CR>
" Quick save
nmap <leader>w :w!<CR>
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
" Disable highlight when <leader><CR> is pressed
map <silent> <Leader><CR> :noh<CR>
" Close the current buffer
map <Leader>bd :Bclose<CR>
" Close all the buffers
map <Leader>ba :1,1000 bd!<CR>
" Switch CWD to the directory of the open buffer
map <Leader>cd :cd %:p:h<CR>:pwd<CR>
" Pressing ,ss will toggle and untoggle spell checking
map <Leader>ss :setlocal spell!<CR>
" Quickly open a buffer for scripbble
map <Leader>q :e ~/buffer<CR>
" Stop that stupid window from popping up
map q: :q
" }
" Tabs {
set showtabline=2
if exists("+showtabline")
function! TabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let bufnr = buflist[winnr - 1]
let s .= ' '
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.', '', '')
endif
else
let file = fnamemodify(file, ':p:t')
endif
if file == ''
let file = '[No Name]'
endif
let s .= file
if getbufvar(bufnr, "&modified")
let s .= ' ±'
endif
let s .= ' '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
return s
endfunction
set tabline=%!TabLine()
endif
" }
" Windows, Panes, Tabs and Splits {
" Switch Tab
set <F16>=t
map <F16> :tabnext<CR>
map! t <Esc>:tabnext<CR>
" Switch Split
set <F17>=s
map <F17> :wincmd w<CR>
map! <F17> <Esc>:wincmd w<CR>
" }
" }
" lightline {
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
" }
" CtrlP {
let g:ctrlp_regexp = 1
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$',
\ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' }
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ },
\ 'fallback': 'ag %s --nocolor -l -g ""'
\ }
" CtrlP extensions
let g:ctrlp_extensions = ['funky']
nnoremap <silent> <leader>o :CtrlP<CR>
nnoremap <silent> <leader>fu :CtrlPFunky<CR>
" }
" Commentary {
nmap <leader>cc <plug>CommentaryLine
vmap <leader>cc <plug>Commentary
" }
" NerdTree {
nmap <leader>nt :NERDTreeToggle<CR>
vmap <leader>nf :NERDTreeFind<CR>
nmap <leader>nf :NERDTreeFind<CR>
let g:NERDTreeShowBookmarks = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeWinSize = 26
let g:NERDTreeMapActivateNode = "za"
let g:NERDTreeChDirMode = 0
let g:NERDTreeQuitOnOpen = 1
let g:NERDTreeShowHidden = 1
let g:NERDTreeKeepTreeInNewTab=1
let g:NERDTreeIgnore = ['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$', '__pycache__', '.ropeproject', '.vagrant']
" }
" Ack {
noremap <C-f> :Ack<space>
let g:ackprg = 'ag --nogroup --nocolor --column --smart-case'
" }
" Local Vimrc {
let g:localvimrc_whitelist = '/Users/pricco/projects/.*'
let g:localvimrc_sandbox = 0
" }
" Neomake {
let g:neomake_open_list=1
nnoremap <leader>l :Neomake<CR>
autocmd! BufWritePost * Neomake
" g:neomake_error_sign* *g:neomake_warning_sign*
" silent! if emoji#available()
" let g:neomake_error_sign = {
" \ 'text': emoji#for('warning'),
" \ }
" endif
" let g:neomake_error_sign = {'text': '🔴'}
" let g:neomake_warning_sign = {'text': '⚠️'}
" }
" PythonMode {
let g:pymode = 1
let g:pymode_trim_whitespaces = 0
let g:pymode_options_colorcolumn = 0
let g:pymode_options_max_line_length = 79
let g:pymode_indent = 1
let g:pymode_folding = 1
let g:pymode_motion = 0
let g:pymode_doc = 0
let g:pymode_virtualenv = 0
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_run = 0
let g:pymode_lint = 0
let g:pymode_rope = 0
let g:pymode_syntax = 1
let g:pymode_syntax_slow_sync = 1
let g:pymode_syntax_all = 1
autocmd FileType python let &colorcolumn=join(range(80,999),",")
" }
" Indent Guides {
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_default_mapping = 0
let g:indent_guides_auto_colors = 0
let g:indent_guides_guide_size = 1
let g:indent_guides_start_level = 2
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
nmap <silent> <Leader>ig <Plug>IndentGuidesToggle
highlight IndentGuidesOdd ctermbg=0
highlight IndentGuidesEven ctermbg=0
" highlight NonText ctermfg=8 guifg=8
" }
" EasyMotion {
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
nmap s <Plug>(easymotion-s2)
nmap t <Plug>(easymotion-t2)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
" }
" Multiple Cursors {
let g:multi_cursor_next_key = '<C-n>'
let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
let g:multi_cursor_start_key = '<C-n>'
" }
" Tagbar {
nnoremap <silent> <Leader>tt :TagbarToggle<CR>
let g:tagbar_compact = 2
let g:tagbar_autofocus = 1
" If using go please install the gotags program using the following
" go install github.com/jstemmer/gotags
" And make sure gotags is in your path
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [ 'p:package', 'i:imports:1', 'c:constants', 'v:variables',
\ 't:types', 'n:interfaces', 'w:fields', 'e:embedded', 'm:methods',
\ 'r:constructor', 'f:functions' ],
\ 'sro' : '.',
\ 'kind2scope' : { 't' : 'ctype', 'n' : 'ntype' },
\ 'scope2kind' : { 'ctype' : 't', 'ntype' : 'n' },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" }
" Fugitive {
nnoremap <silent> <leader>gs :Git status<CR>
nnoremap <silent> <leader>gd :Git diff<CR>
nnoremap <silent> <leader>gc :Git commit<CR>
nnoremap <silent> <leader>gb :Git blame<CR>
nnoremap <silent> <leader>gl :Git log<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Git read<CR>
nnoremap <silent> <leader>gw :Git write<CR>
nnoremap <silent> <leader>ge :Git edit<CR>
" Mnemonic _i_nteractive
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gg :SignifyToggle<CR>
" }
" Signify {
let g:signify_sign_add = '+'
let g:signify_sign_delete_first_line = '-'
let g:signify_sign_change = '!'
let g:signify_sign_changedelete = '!'
let g:signify_sign_show_count = 0
" silent! if emoji#available()
" let g:signify_sign_add = emoji#for('small_blue_diamond')
" let g:signify_sign_delete_first_line = emoji#for('small_orange_diamond')
" let g:signify_sign_change = emoji#for('small_orange_diamond')
" let g:signify_sign_changedelete = emoji#for('collision')
" endif
" }
" Dash {
nmap <silent> <leader>d <Plug>DashSearch
" }
" Deoplete {
let g:deoplete#enable_at_startup = 0
" }
" Numbers {
let g:numbers_exclude = ['tagbar', 'gundo', 'minibufexpl', 'nerdtree']
" }
" WindowSwap {
let g:windowswap_map_keys = 0 "prevent default bindings
" nnoremap <silent> <leader>yw :call WindowSwap#MarkWindowSwap()<CR>
" nnoremap <silent> <leader>pw :call WindowSwap#DoWindowSwap()<CR>
nnoremap <silent> <leader>mw :call WindowSwap#EasyWindowSwap()<CR>
" }