-
Notifications
You must be signed in to change notification settings - Fork 3
/
.vimrc
424 lines (326 loc) · 9.75 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
" vim:foldmethod=marker
" {{{ Plugins
call plug#begin()
" Plug 'bling/vim-airline'
" let g:airline_powerline_fonts=1
" let g:airline_detect_spell=0
Plug 'itchyny/lightline.vim'
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'component': {
\ 'readonly': '%{&readonly?"":""}',
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'relativepath', 'modified' ] ]
\ },
\ 'inactive': {
\ 'left': [ [ 'relativepath' ] ]
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
" Mirror vim status bar theme to tmux
Plug 'edkolev/tmuxline.vim'
Plug 'christoomey/vim-tmux-navigator'
" extended % matching for HTML, LaTeX, and many more languages
Plug 'vim-scripts/matchit.zip'
Plug 'easymotion/vim-easymotion'
" Colorschemes
Plug 'NLKNguyen/papercolor-theme'
Plug 'joshdick/onedark.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'jdkanani/vim-material-theme'
Plug 'morhetz/gruvbox'
Plug 'chriskempson/base16-vim'
Plug 'lifepillar/vim-solarized8'
Plug 'romainl/flattened'
"{{{ ctrlp: File navigation
" Plug 'ctrlpvim/ctrlp.vim'
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'}
Plug 'junegunn/fzf.vim'
"
" I'm almost always using vim with git anyway...
"
" let g:ctrlp_use_caching = 0
" let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -oc --exclude-standard']
" let g:ctrlp_working_path_mode = ''
"}}}
Plug 'tpope/vim-vinegar'
" Surround text
Plug 'tpope/vim-surround'
" Commenting/uncommenting code
Plug 'tomtom/tcomment_vim'
" Git integration
Plug 'tpope/vim-fugitive'
Plug 'int3/vim-extradite'
" LESS Syntax highlighting, indent, and autocompletion
Plug 'groenewege/vim-less', { 'for': 'less' }
" Misc functions needed by other plugins
Plug 'xolox/vim-misc'
" Run Async Shell Commands in Vim 8.0 and Output to Quickfix Window
Plug 'skywind3000/asyncrun.vim'
" Highlight yanked area
Plug 'machakann/vim-highlightedyank'
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
"{{{ syntastic: Syntax check for several languages
" Plug 'scrooloose/syntastic', { 'for': 'python' }
" let g:syntastic_always_populate_loc_list = 1
"
" let g:syntastic_python_python_exec = '/usr/bin/python3'
" let g:syntastic_python_checkers = ['python', 'flake8']
"}}}
"{{{ Ale
Plug 'w0rp/ale'
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 0
let g:ale_lint_on_enter = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_delay = 200
let g:ale_open_list = 1
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
"}}}
Plug 'Konfekt/FastFold'
let g:fastfold_fold_command_suffixes =
\['x','X','a','A','o','O','c','C','r','R','m','M','i','n','N']
" vim org mode {{{
Plug 'jceb/vim-orgmode', { 'for': 'org' }
Plug 'tpope/vim-speeddating', { 'for': 'org' }
command Notes execute "e ~/Dropbox/notes"
command -nargs=1 NewNote execute "e ~/Dropbox/notes/<args>.org"
" }}}
" {{{ vimproc: Make it possible to execute programs within vim (requires compilation)
Plug 'Shougo/vimproc.vim', {
\ 'build' : {
\ 'windows' : 'tools\\update-dll-mingw',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'linux' : 'make',
\ 'unix' : 'gmake',
\ },
\ }
"}}}
Plug 'saltstack/salt-vim', { 'for': 'sls' }
"
" Python
"
" Better indentation for Python
Plug 'hynek/vim-python-pep8-indent', { 'for': 'python' }
" Python matchit support
Plug 'voithos/vim-python-matchit', { 'for': 'python' }
Plug 'davidhalter/jedi-vim'
let g:jedi#completions_command = ""
let g:jedi#popup_on_dot = 0
" Highlighting for restructured text
Plug 'Rykka/riv.vim', { 'for': 'rst' }
Plug 'hdima/python-syntax', { 'for': 'python' }
Plug 'SirVer/ultisnips'
Plug 'GutenYe/json5.vim'
"
" JavaScript
"
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
" Vim as a tool for writing
Plug 'reedes/vim-pencil'
Plug 'junegunn/goyo.vim'
" C64 development
Plug 'gryf/kickass-syntax-vim', { 'for': 'kickass' }
autocmd BufRead *.asm set filetype=kickass
" Breaking the habit of using Vim ineffectively
Plug 'takac/vim-hardtime'
let g:hardtime_default_on = 1 " Have hardtime be on by default for all buffers
let g:hardtime_maxcount = 5 " Allow 5 repetitions
let g:hardtime_allow_different_key = 1 " Allow jjjjjkkk
call plug#end()
filetype plugin indent on
" }}}
" Leaders {{{
let mapleader=" "
let maplocalleader="\\"
" }}}
" Key Mappings {{{
" Quick escape
inoremap jk <esc>
" nnoremap <leader>p :CtrlP<cr>
" nnoremap <leader>t :CtrlPTag<cr>
" nnoremap <leader>b :CtrlPBuffer<cr>
nnoremap <leader>p :Files<cr>
nnoremap <leader>t :Tags<cr>
nnoremap <leader>b :Buffers<cr>
nnoremap <leader>a :Ag
" Clear higlighting of words matching search
nnoremap <silent> <leader>cl :noh<cr>:call clearmatches()<cr>
" Rebuild ctags
:nnoremap <silent> <F12> :AsyncRun ctags .<cr>
" Shortcut to edit .vimrc
nnoremap <leader>ev :e $MYVIMRC<cr>
" JSON Formatting
nnoremap <leader>js :%!python -m json.tool<cr>
" Browse directory of file in current buffer
nnoremap <leader>ex :Explore<cr>
" Search with ag
" nnoremap <leader>a :Ag ""<left>
" Switch between dark and light background
nnoremap <leader>B :<c-u>exe "colors" (g:colors_name =~# "dark"
\ ? substitute(g:colors_name, 'dark', 'light', '')
\ : substitute(g:colors_name, 'light', 'dark', '')
\ )<cr>
" Less awkward windows handling
nnoremap <leader>ws <C-w><C-s>
nnoremap <leader>wv <C-w><C-v>
nnoremap <C-h> <C-w><C-h>
nnoremap <C-j> <C-w><C-j>
nnoremap <C-k> <C-w><C-k>
nnoremap <C-l> <C-w><C-l>
" Poor mans clipboard on terminal linux
vnoremap <leader>y :w! /tmp/vimclipboardbuf<CR>
nnoremap <leader>v :r! cat /tmp/vimclipboardbuf<CR>
" }}}
" Options {{{
syntax on " Turn on syntax highlighting
set smartindent
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
set laststatus=2
set autowrite " Automatically save buffer
set incsearch
set scrolloff=3 " keep 3 lines when scrolling
set showcmd " display incomplete commands
set nobackup " do not keep a backup file
set nowritebackup
set noswapfile
set hlsearch " highlight searches
set showmatch " jump to matches when entering regexp
set ignorecase " ignore case when searching
set smartcase " no ignorecase if Uppercase char present
set encoding=utf-8
"
" Show relative line numbers, except for on the current line
"
set relativenumber
set number
"
" Easiear copy paste to system clipboard
"
set clipboard=unnamed
"
" Turn off error beeps and flashing
"
set noerrorbells visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
set backspace=indent,eol,start " make that backspace key work the way it should
"
" Patterns to ignore for ctrlp etc.
"
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*.so,*.o,*.pyc
set wildignore+=*/node_modules/*,*/bower_components/*,*/venv/*,*/Python34/*
"
" If compiler error refers to a file already open in a window,
" use that window instead of opening the file in the last active
" window.
"
set switchbuf=useopen
" }}}
" Python Settings {{{
augroup filetype_python
autocmd!
autocmd FileType python setlocal colorcolumn=80
" autocmd FileType python setlocal omnifunc=python3complete#Complete
" We don't need smartindent in python. Makes comments always go to
" the start of the line.
autocmd FileType python setlocal nosmartindent
" Show whitespace markers for python files so we detect tabs or
" trailing whitespaces
autocmd FileType python setlocal list
autocmd FileType python setlocal listchars=tab:▷◆,trail:◆
" Prevent Jedi from showing docstrings
autocmd FileType python setlocal completeopt-=preview
augroup END
" {{{ Functions for running tests in python
function! RunTests(args)
set makeprg=nosetests\ --with-terseout
exec "make! " . a:args
endfunction
function! RunFlake()
set makeprg=flake8
exec "make!"
endfunction
function! JumpToError()
if getqflist() != []
for error in getqflist()
if error['valid']
break
endif
endfor
let error_message = substitute(error['text'], '^ *', '', 'g')
silent cc!
if error['bufnr'] != 0
exec ":sbuffer " . error['bufnr']
endif
call RedBar()
echo error_message
else
call GreenBar()
echo "All tests passed"
endif
endfunction
function! RedBar()
hi RedBar ctermfg=white ctermbg=red guibg=red
echohl RedBar
echon repeat(" ",&columns - 1)
echohl None
endfunction
function! GreenBar()
hi GreenBar ctermfg=white ctermbg=green guibg=green
echohl GreenBar
echon repeat(" ",&columns - 1)
echohl None
endfunction"
nnoremap <leader>ra :wa<cr>:call RunTests("")<cr>:redraw<cr>:call JumpToError()<cr>
nnoremap <leader>rf :wa<cr>:call RunFlake()<cr>:redraw<cr>:call JumpToError()<cr>
" }}}
nnoremap <leader>rd :redraw!<cr>
" }}}
" Appearance {{{
"
" Only display trailing whitespaces when we're not in insert mode
"
augroup trailing
au!
au InsertEnter * :set listchars-=trail:◆
au InsertLeave * :set listchars+=trail:◆
augroup END
if has('gui_running')
set guioptions=-Mc
if has('win32') || has('win64')
set guifont=Source_Code_Pro_Medium:h10:cANSI
elseif has('macunix')
set guifont=Source\ Code\ Pro\ Medium:h16
endif
else
set termencoding=utf8
if !has('nvim')
set term=xterm
endif
" Clearing uses the current background color
set t_ut=
" Enable true colors
set termguicolors
" Italics mode
let &t_ZH="\e[3m"
let &t_AB="\e[48;5;%dm"
" Set forground color
let &t_AF="\e[38;5;%dm"
" Set foreground/background color RGB
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
set cursorline
highlight! link MatchParen StatusLine
colorscheme base16-gruvbox-dark-hard
" }}}