forked from make-github-pseudonymous-again/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
439 lines (388 loc) · 13.1 KB
/
.vimrc
File metadata and controls
439 lines (388 loc) · 13.1 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
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
set nocompatible " be iMproved, be safe
" http://stackoverflow.com/questions/5845557/in-a-vimrc-is-set-nocompatible-completely-useless
" install vim-plug
" https://github.com/junegunn/vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" ## BINDINGS ##
" fugitive.vim: a Git wrapper so awesome, it should be illegal
Plug 'tpope/vim-fugitive'
" ## INTERFACE ##
" Pseudo-command-line (experimental)
Plug 'junegunn/vim-pseudocl'
" Go to Terminal or File manager (maybe not be so useful)
" Plug 'justinmk/vim-gtfo'
" ## FIXES ##
" Find-N-Replace helper free of regular expressions
Plug 'junegunn/vim-fnr'
" enable repeating supported plugin maps with "."
Plug 'tpope/vim-repeat'
" Heuristically set buffer options (auto indentation)
Plug 'tpope/vim-sleuth'
" ## VISUAL ##
" one colorscheme pack to rule them all!
Plug 'flazz/vim-colorschemes'
" Vim plugin that displays tags in a window, ordered by scope
" Lean & mean status/tabline for vim that's light as air.
" Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' }
" should be loaded before vim-airline but does not work :(
Plug 'vim-airline/vim-airline'
" A collection of themes for vim-airline
Plug 'vim-airline/vim-airline-themes'
" Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks.
Plug 'airblade/vim-gitgutter'
" Plug 'mhinz/vim-signify' " possible alternative
" A tree explorer plugin for vim.
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Preview colours in source code while editing
Plug 'ap/vim-css-color', { 'for': 'css' }
" causes all trailing whitespace characters (spaces and tabs) to be highlighted
Plug 'ntpeters/vim-better-whitespace'
" A Vim plugin for visually displaying indent levels in code: <leader>ig
Plug 'nathanaelkane/vim-indent-guides'
" A git commit browser
Plug 'junegunn/gv.vim'
" The ultimate undo history visualizer
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
" Peekaboo extends " and @ in normal mode and <CTRL-R> in insert mode so you can see the contents of the registers.
Plug 'junegunn/vim-peekaboo'
" Rainbow parentheses!
Plug 'junegunn/rainbow_parentheses.vim'
" Distraction-free writing in Vim
Plug 'junegunn/goyo.vim'
" Hyperfocus-writing in Vim
Plug 'junegunn/limelight.vim'
" Vim plugin for the Perl module / CLI script 'ack'
Plug 'mileszs/ack.vim'
" ## COMPLETION ##
" allows you to use <Tab> for all your insert completion needs
Plug 'ervandew/supertab'
" Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
Plug 'Raimondi/delimitMate'
" Emoji in Vim
Plug 'junegunn/vim-emoji'
" ## LANGUAGE SUPPORT ##
" Syntax checking hacks for vim
Plug 'vim-syntastic/syntastic'
" Provide easy code formatting in Vim by integrating existing code formatters.
Plug 'Chiel92/vim-autoformat'
" plug-in which provides support for expanding abbreviations similar to emmet
Plug 'mattn/emmet-vim'
" Generate JSDoc to your JavaScript code
Plug 'heavenshell/vim-jsdoc'
" Go development plugin for Vim
Plug 'fatih/vim-go'
" tern is a JavaScript code analyzer for deep, cross-editor language support
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
" Enhanced javascript syntax file for Vim
Plug 'jelera/vim-javascript-syntax'
" Vastly improved Javascript indentation and syntax support in Vim
Plug 'pangloss/vim-javascript'
" A code-completion engine for Vim
" Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clang-completer' }
" Compiling requires too much memory, fails every time
" A modern vim plugin for editing LaTeX files
Plug 'lervag/vimtex'
" A vim plugin for writing Latex quickly
Plug 'brennier/quicktex'
" Official Vimperator syntax highlighting file.
Plug 'vimperator/vimperator.vim'
" Vim syntax for TOML
Plug 'https://github.com/cespare/vim-toml'
" ## MOTIONS ##
" search and jump to a single character with <leader><leader>s<char>
Plug 'easymotion/vim-easymotion'
" ## SELECTION ##
" True Sublime Text style multiple selections for Vim
Plug 'terryma/vim-multiple-cursors'
" ## SHORTCUTS ##
" pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
" use CTRL-A/CTRL-X to increment dates, times, and more
Plug 'tpope/vim-speeddating'
" quoting/parenthesizing made simple
Plug 'tpope/vim-surround'
" intensely orgasmic commenting
Plug 'scrooloose/nerdcommenter'
" A Vim alignment plugin
Plug 'junegunn/vim-easy-align', { 'on': ['<Plug>(EasyAlign)', 'EasyAlign'] }
" A vim plugin that simplifies the transition between multiline and single-line code
Plug 'AndrewRadev/splitjoin.vim'
" ## FUZZY FINDER ## ( Used a lot!!! )
" A command-line fuzzy finder written in Go
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all --no-update-rc' }
" bundle of fzf-based commands and mappings
Plug 'junegunn/fzf.vim'
Plug 'nhooyr/fasd.vim'
call plug#end()
" Use hidden buffers. Allows to change buffer without saving.
set hidden
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamedplus
" Enhance command-line completion
set wildmenu
" Allow cursor keys in insert mode
set esckeys
" Allow backspace in insert mode
set backspace=indent,eol,start
" Optimize for fast terminal connections
set ttyfast
" Add the g flag to search/replace by default
" From vim.wikia.com:
" > Using :set gdefault creates confusion because then %s/// is global,
" > whereas %s///g is not (that is, g reverses its meaning)
set gdefault
" Use UTF-8 without BOM
set encoding=utf-8 nobomb
" Change mapleader
let mapleader=","
" Centralize backups, swapfiles and undo history (// for full paths)
set backupdir=~/.vim/backups//
set directory=~/.vim/swaps//
if has("persistent_undo")
set undodir=~/.vim/undo//
set undofile
endif
" Don’t create backups when editing files in certain directories
set backupskip=/tmp/*,/private/tmp/*
" Respect modeline in files
set modeline
set modelines=4
" Do not enable per-directory .vimrc files
" set exrc
" and disable unsafe commands in them (just in case)
set secure
" Enable line numbers
set number
" Do not highlight current line and do not use relative line numbers (SLOW)
" see https://github.com/xolox/vim-easytags/issues/88
set nocursorline
if exists("&relativenumber")
set norelativenumber
"au BufReadPost * set relativenumber
endif
" Make tabs as wide as four spaces
set tabstop=4
set shiftwidth=4
" Show “invisible” characters
set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
set list
" Highlight searches
set hlsearch
" Ignore case of searches
set ignorecase
" Highlight dynamically as pattern is typed
set incsearch
" Always show status line
set laststatus=2
" Enable mouse in all modes
set mouse=a
" Disable error bells
set noerrorbells
" Don’t reset cursor to start of line when moving around.
set nostartofline
" Show the cursor position
set ruler
" Automatically cut long lines
set tw=79
" Adds a guide for maximum length of lines
set colorcolumn=79
" Don’t show the intro message when starting Vim
set shortmess=atI
" Show the current mode
set showmode
" Show the filename in the window titlebar
set title
" Show the (partial) command as it’s being typed
set showcmd
" Start scrolling three lines before the horizontal window border
set scrolloff=3
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Automatic commands
if has("autocmd")
" Enable file type detection
filetype on
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setlocal filetype=json syntax=javascript
" Treat .md files as Markdown
autocmd BufNewFile,BufRead *.md setlocal filetype=markdown
" Treat .sage files as .py
autocmd BufNewFile,BufRead *.sage setlocal filetype=python syntax=python softtabstop=4 shiftwidth=4 expandtab
endif
" Set colors
set t_Co=256
syntax on
set background=dark
" Use Hybrid, to use ~/.Xresources uncomment next line
" let g:hybrid_use_Xresources = 1
silent! colorscheme hybrid
"silent! colorscheme seoul256
" Replace search with easymotion multi char search
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
" These `n` & `N` mappings are options. You do not have to map `n` & `N` to EasyMotion.
" Without these mappings, `n` & `N` works fine. (These mappings just provide
" different highlight method and have some other features )
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
" open a new buffer
noremap <silent> <leader>e :enew<CR>
" Strip trailing whitespace (w)
noremap <silent> <leader>w :StripWhitespace<CR>
autocmd FileType javascript,python,c,cpp,java,html,css,ruby autocmd BufWritePre <buffer> StripWhitespace
" airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" <cr> expands {_} to {<cr><indent>_<cr>}
let g:delimitMate_expand_cr = 1
" Experimentally integrate YouCompleteMe with vim-multiple-cursors, otherwise
" the numerous Cursor events cause great slowness
" (https://github.com/kristijanhusak/vim-multiple-cursors/issues/4)
" function! Multiple_cursors_before()
" let s:old_ycm_whitelist = g:ycm_filetype_whitelist
" let g:ycm_filetype_whitelist = {}
" endfunction
" function! Multiple_cursors_after()
" let g:ycm_filetype_whitelist = s:old_ycm_whitelist
" endfunction
" 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_javascript_eslint_exec = 'eslint_d'
"toggle syntastic on a per buffer basis
function! SyntasticToggle()
if !exists('b:syntastic_disabled')
let b:syntastic_disabled = 0
endif
if !b:syntastic_disabled
let b:syntastic_mode = "passive"
SyntasticReset
let b:syntastic_disabled = 1
else
SyntasticCheck
let b:syntastic_mode = "active"
let b:syntastic_disabled = 0
endif
echo 'Syntastic ' . ['enabled', 'disabled'][b:syntastic_disabled]
endfunction
" Shortcut for toggling syntastic
command! SyntasticToggle call SyntasticToggle()
nn <silent> <leader>s :SyntasticToggle<cr>
" Shortcut for formatting code
nn <silent> <leader>x :Autoformat<cr>
" clean up gvim interface
if has('gui_running')
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
set lines=60 columns=108 linespace=0
set guifont=LiterationMonoPowerline\ Nerd\ Font\ 12
endif
" goyo + limelight config
let g:goyo_width=90
let g:limelight_paragraph_span = 1
let g:limelight_priority = -1
function! s:goyo_enter()
if has('gui_running')
set fullscreen
set background=light
set linespace=7
elseif exists('$TMUX')
silent !tmux set status off
endif
" hi NonText ctermfg=101
Limelight
endfunction
function! s:goyo_leave()
if has('gui_running')
set nofullscreen
set background=dark
set linespace=0
elseif exists('$TMUX')
silent !tmux set status on
endif
Limelight!
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
nnoremap <Leader>g :Goyo<CR>
" map c-p to fzf
nn <silent> <leader>f :Files<cr>
nn <silent> <leader>b :Buffers<cr>
nn <silent> <leader>o :History<cr>
nn <silent> <leader>q :Ag<cr>
let $FZF_DEFAULT_COMMAND= 'ag --hidden --ignore .git --ignore node_modules -g ""'
let g:fzf_files_options = '--preview "begin; coderay {}; or cat {}; end 2>/dev/null | head -'.&lines.'"'
" use ag instead of ack if available
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
"ack.vim shortcut
nn <silent> <leader>a :Ack<cr>
" undotree config
let g:undotree_WindowLayout = 2
nnoremap <silent> U :UndotreeToggle<cr>
" search for last function def and call jsdoc
nmap <silent> <leader>j ?function<cr>:noh<cr><Plug>(jsdoc)
" noh shortcut
nn <silent> <leader>d :noh<cr>
" shorter window moves
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" buffer cycling shortcuts
nn <silent> <leader>n :bn<cr>
nn <silent> <leader>p :bp<cr>
nn <silent> <leader>l :bd<cr>
" Capitalize words and regions easily
" from http://vim.wikia.com/wiki/Capitalize_words_and_regions_easily
if (&tildeop)
nmap gcw guw~l
nmap gcW guW~l
nmap gciw guiw~l
nmap gciW guiW~l
nmap gcis guis~l
nmap gc$ gu$~l
nmap gcgc guu~l
nmap gcc guu~l
vmap gc gu~l
else
nmap gcw guw~h
nmap gcW guW~h
nmap gciw guiw~h
nmap gciW guiW~h
nmap gcis guis~h
nmap gc$ gu$~h
nmap gcgc guu~h
nmap gcc guu~h
vmap gc gu~h
endif
" Email completion using abook and fzf
function! s:iea_handler(lines)
exec ':normal a' . join(a:lines,', ')
endfunction
command! InsertEmailAddresses call fzf#run({'source': 'notmuch-abook export -f email -s name', 'sink*': function('<sid>iea_handler'), 'options': '-m'})
nn <silent> <leader>v :InsertEmailAddress<cr>
" vimtex + surround = magic
augroup latexSurround
autocmd!
autocmd FileType tex,plaintex call s:latexSurround()
augroup END
function! s:latexSurround()
let b:surround_{char2nr("e")}
\ = "\\begin{\1environment: \1}\n\t\r\n\\end{\1\1}"
let b:surround_{char2nr("c")} = "\\\1command: \1{\r}"
" vim-surround: q for `foo' and Q for ``foo''
let b:surround_{char2nr('q')} = "`\r'"
let b:surround_{char2nr('Q')} = "``\r''"
endfunction