-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
479 lines (361 loc) · 12.7 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
call plug#begin('~/.vim/plugged')
let g:plug_timeout = 120
let g:plug_retries = 4
Plug 'sheerun/vim-polyglot'
Plug 'Luxed/ayu-vim'
let ayucolor = 'mirage'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'sjl/badwolf'
Plug 'kyoz/purify', { 'rtp': 'vim' }
Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'NLKNguyen/papercolor-theme'
Plug 'jacoborus/tender.vim'
Plug 'mhartington/oceanic-next'
let g:oceanic_next_terminal_italic = 1
let g:oceanic_next_terminal_bold = 1
Plug 'kopischke/vim-stay'
Plug 'Yggdroot/indentLine'
let g:indentLine_enabled = 0
let g:indentLine_char = '┆'
let g:indentLine_first_char = '┆'
let g:indentLine_setColors = 0
let g:indentLine_showFirstIndentLevel = 1
Plug 'simnalamburt/vim-mundo'
Plug 'jlanzarotta/bufexplorer'
let g:bufExplorerDefaultHelp = 0
let g:bufExplorerDetailedHelp = 0
let g:bufExplorerFindActive = 0
let g:bufExplorerShowUnlisted = 0
Plug 'tpope/vim-git'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'luochen1990/rainbow'
let g:rainbow_active = 1
Plug 'Raimondi/delimitMate'
Plug 'sickill/vim-pasta'
Plug 'ConradIrwin/vim-bracketed-paste'
Plug 'airblade/vim-gitgutter'
let g:gitgutter_enabled = 1
Plug 'scrooloose/nerdtree'
let g:NERDTreeMouseMode = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeShowHidden = 1
let g:NERDTreeQuitOnOpen = 1
let g:NERDTreeIgnore = ['^node_modules$']
Plug 'preservim/tagbar'
Plug 'godlygeek/tabular'
Plug 'mg979/vim-visual-multi'
Plug 'junegunn/vim-easy-align'
Plug 'ntpeters/vim-better-whitespace'
let g:better_whitespace_enabled = 1
let g:strip_whitespace_on_save = 1
let g:show_spaces_that_precede_tabs = 1
let g:better_whitespace_skip_empty_lines = 1
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
let g:fzf_buffers_jump = 1
Plug 'airblade/vim-rooter'
Plug 'fatih/vim-go'
let g:go_doc_popup_window = 1
let g:go_doc_popup_border = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
let g:go_gopls_enabled = 1
let g:go_diagnostics_enabled = 0
let g:go_metalinter_enabled = []
let g:go_jump_to_error = 0
let g:go_auto_sameids = 0
let g:go_auto_type_info = 0
let g:go_info_mode = 'gopls'
let g:go_def_mode = 'gopls'
let g:go_imports_mode = 'gopls'
let g:go_fmt_autosave = 1
let g:go_fmt_command = 'goimports'
let g:go_snippet_engine = 'ultisnips'
let g:go_addtags_transform = 'snakecase'
let g:go_list_type = 'quickfix'
let g:go_list_autoclose = 1
let g:go_gocode_propose_source = 1
let g:go_gocode_unimported_packages = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_array_whitespace_error = 1
let g:go_highlight_chan_whitespace_error = 1
let g:go_highlight_types = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_variable_assignments = 1
let g:go_highlight_variable_declarations = 1
let g:go_highlight_format_strings = 1
let g:go_highlight_string_spellcheck = 1
let g:go_highlight_diagnostic_errors = 1
let g:go_highlight_diagnostic_warnings = 1
let g:go_highlight_trailing_whitespace_error = 1
let g:go_highlight_space_tab_error = 1
Plug 'maralla/completor.vim'
let g:completor_auto_trigger = 1
Plug 'ervandew/supertab'
let g:SuperTabDefaultCompletionType = 'context'
let g:SuperTabClosePreviewOnPopupClose = 1
let g:SuperTabRetainCompletionType = 2
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:SuperTabContextDefaultCompletionType = "<c-n>"
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc','&completefunc']
Plug 'AndrewRadev/linediff.vim'
Plug 'dense-analysis/ale'
let g:ale_set_balloons = 1
let g:ale_hover_to_preview = 1
let g:ale_open_list = 1
let g:ale_completion_enabled = 1
let g:ale_sign_column_always = 1
let g:ale_sign_warning = '⚠'
let g:ale_sign_error = '⤫'
let g:ale_linters = { 'rust': [ 'analyzer', 'cargo' ] }
let g:ale_fixers = { 'rust': [ 'rustfmt' ] }
let g:ale_rust_cargo_use_clippy = 1
"let g:ale_lint_on_enter = 0
"let g:ale_lint_on_text_changed = 'never'
Plug 'sebdah/vim-delve'
Plug 'vim-ruby/vim-ruby'
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
Plug 'davidhalter/jedi-vim'
Plug 'rust-lang/rust.vim'
let g:rustfmt_autosave = 1
Plug 'pangloss/vim-javascript'
Plug 'elzr/vim-json'
let g:vim_json_syntax_conceal = 0
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_fenced_languages = ['go=go', 'viml=vim', 'bash=sh']
Plug 'hashivim/vim-vagrant'
Plug 'hashivim/vim-terraform'
let g:terraform_align = 0
let g:terraform_fmt_on_save = 1
let g:terraform_fold_sections = 0
let g:terraform_remap_spacebar = 0
call plug#end()
set nocompatible
set modeline
nnoremap <Space> <Nop>
let mapleader = "\<Space>"
let maplocalleader = "\\"
set timeoutlen=1000
set ttimeoutlen=100
set guioptions-=T
set guioptions-=r
set guioptions-=L
set winaltkeys=no
set showcmd
set autoindent
set smartindent
set copyindent
set preserveindent
set shiftround
set virtualedit=block,onemore
set shiftwidth=2
set softtabstop=2
set tabstop=8
set expandtab
set smarttab
set nowrap
set nojoinspaces
set nofoldenable
set splitright
set splitbelow
set mouse+=a
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
if &term =~ '^screen'
set ttymouse=xterm2
endif
set t_fd=
set t_fe=
set t_Co=256
set term=xterm-256color
if has("termguicolors")
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
syntax enable
syntax sync fromstart
syntax sync minlines=250
set synmaxcol=4096
set background=dark
colorscheme purify
filetype plugin on
filetype indent on
set encoding=utf-8
set fileencodings=utf-8
set termencoding=utf-8
set textwidth=120
set history=128
set scrolloff=3
set shortmess+=c
set shortmess+=I
set belloff+=ctrlg
set viminfo=%,'50,\"1000,/50,:50,h,f0,n~/.vim/.viminfo
set formatoptions+=1
set formatoptions+=n
set formatoptions+=j
set showbreak=↪\
set fillchars+=vert:│
set listchars+=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:❯,precedes:❮
set completeopt+=menu,menuone,noselect,noinsert
set completeopt-=preview
set clipboard^=unnamed
set clipboard^=unnamedplus
set maxmempattern=20480
set iskeyword+=_,$,@,%,#
set wildmenu
set wildmode=list:longest,full
set wildignore+=.svn,.git
set wildignore+=*.bmp,*.gif,*.png,*.jpg,*.jpeg,*.woff,*.ttf,*.svg,*.eot
set wildignore+=*.o,*.obj,*.exe,*.dll
set wildignore+=*.sw?
set wildignore+=*.DS_Store
set signcolumn=yes
set lazyredraw
set linespace=0
set matchtime=5
set report=0
set nolist
set nonumber
set ignorecase
set infercase
set smartcase
set hidden
set autoread
set autochdir
set showmatch
set incsearch
set hlsearch
set ruler
set showmode
set backspace=indent,eol,start
set ttyfast
set ttyscroll=3
set noerrorbells
set nostartofline
set pastetoggle=<F5>
set undoreload=65535
set undofile
set backup
set updatetime=100
set viewoptions=cursor,folds,slash,unix
set spelllang=en_gb,en_us,en
set laststatus=2
set switchbuf=usetab
set statusline=
set statusline+=[%n]\ %<%F%{exists('g:loaded_fugitive')?fugitive#statusline():''}%M%R%H%W
set statusline+=\ %=%Y
set statusline+=\ %{toupper(strlen(&ff)?&ff:'none')}
set statusline+=\ %{toupper(strlen(&fenc)?&fenc:'none')}
set statusline+=\ %c,%l/%L\ %p%%
set statusline+=\ ~\ %{strftime(\"%d/%m/%Y\ %T\",getftime(expand(\"%:p\")))}
set undodir=~/.vim/undo//
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
set backupdir=~/.vim/backup//
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
set directory=~/.vim/swap//
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
function! SudoSaveAction()
let answer = confirm('Save with sudo?', "&Yes\n&No", 2)
if answer == 1
:execute ':silent w !sudo tee % >/dev/null' | :edit!
else
:execute ':silent w'
endif
redraw
endfunction
command W call SudoSaveAction()
command Wq :execute ':W' | :q
command WQ :Wq
command Jq :execute '%!jq . 2>/dev/null'
vnoremap r "_dP
nnoremap <silent> <leader>\| :vsplit<CR>
nnoremap <silent> <leader>- :split<CR>
nnoremap <silent> <leader><left> <C-w><C-h>
nnoremap <silent> <leader><right> <C-w><C-l>
nnoremap <silent> <leader><up> <C-w><C-k>
nnoremap <silent> <leader><down> <C-w><C-j>
nnoremap <silent> <C-b> :Buffers<CR>
nnoremap <silent> <C-f> :Rg<CR>
nnoremap <silent> <C-h> :History/<CR>
nnoremap <silent> <C-o> :Files<CR>
nnoremap <silent> <C-g> :GFiles<CR>
nnoremap <silent> <C-p> :FZF<CR>
nnoremap <silent> zj o<esc>k
nnoremap <silent> zk O<esc>j
nnoremap <silent> <F1> <nop>
nnoremap <silent> <F3> :GitGutterToggle<CR>
nnoremap <silent> <F2> :ToggleBufExplorer<CR>
nnoremap <silent> <F4> :set invspell spell?<CR><Bar>:echo "Spell check: " . strpart("OffOn", 3 * &spell, 3)<CR>
nnoremap <silent> <F5> :set invpaste paste?<CR><Bar>:echo "Paste mode: " . strpart("OffOn", 3 * &paste, 3)<CR>
nnoremap <silent> <F6> :IndentLinesToggle<CR>
nnoremap <silent> <F7> :MundoToggle<CR>
nnoremap <silent> <F8> :NERDTreeToggle<CR>
nnoremap <silent> <F9> :TagbarToggle<CR>
nnoremap <silent> <F10> :set invnumber number?<CR><Bar>:echo "Line numbers: " . strpart("OffOn", 3 * &number, 3)<CR>
nnoremap <silent> <F11> :set invlist list?<CR><Bar>:echo "Show invisible: " . strpart("OffOn", 3 * &list, 3)<CR>
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
nnoremap <C-LeftMouse> :ALEGoToDefinition<CR>
augroup configgroup
autocmd!
autocmd QuitPre * if empty(&buftype) | lclose | endif
" Disabled. Broken?
"autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * highlight clear SignColumn
" Disabled. Broken?
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd BufEnter * if &filetype == "" | setlocal filetype=text | endif
" Disabled. Broken?
"autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd BufRead,BufNewFile *.txt set filetype=text
autocmd BufRead,BufNewFile *.sls set filetype=yaml
autocmd BufRead,BufNewFile *.hcl set filetype=terraform
autocmd BufRead,BufNewFile *.gotmpl set filetype=gotexttmpl
" Disabled. Breaks editing Git commits.
"autocmd BufRead,BufNewFile COMMIT_EDITMSG set filetype=gitcommit
autocmd BufRead,BufNewFile *mutt-* setfiletype mail
autocmd FileType text setlocal formatoptions-=t textwidth=0
autocmd FileType mail DisableWhitespace
autocmd FileType mail colorscheme slate
autocmd FileType mail setlocal textwidth=75 noautoindent nolist nonumber noexpandtab digraph wrapmargin=0 shiftwidth=8 tabstop=8 softtabstop=8
autocmd FileType git,gitcommit,gitsendemail DisableWhitespace
autocmd FileType git,gitcommit,gitsendemail colorscheme slate
autocmd FileType git,gitcommit,gitsendemail setlocal textwidth=72 foldmethod=syntax foldlevel=1
autocmd FileType vim setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
autocmd FileType sh,bash setlocal formatoptions-=t expandtab shiftwidth=4 tabstop=8 softtabstop=4 commentstring=#\ %s
autocmd FileType rb,ruby setlocal formatoptions-=t expandtab textwidth=120 shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType py,python setlocal formatoptions-=t expandtab textwidth=80 shiftwidth=4 tabstop=8 softtabstop=4
autocmd FileType php setlocal formatoptions-=t expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType html,xhtml,xml,xslt setlocal formatoptions-=t expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType css setlocal formatoptions-=t expandtab shiftwidth=4 tabstop=4 softtabstop=4
autocmd FileType js,javascript setlocal formatoptions-=t expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType cpp,hpp setlocal formatoptions-=t noexpandtab cindent textwidth=80 shiftwidth=8 tabstop=8 softtabstop=8 commentstring=//\ %s
autocmd FileType c,h setlocal formatoptions-=t noexpandtab cindent textwidth=80 shiftwidth=8 tabstop=8 softtabstop=8 commentstring=/*\ %s
autocmd FileType go setlocal formatoptions-=t noexpandtab textwidth=120 shiftwidth=8 tabstop=8 softtabstop=8
autocmd FileType rs,rc setlocal formatoptions-=t expandtab textwidth=100 shiftwidth=4 tabstop=8 softtabstop=4
autocmd FileType make setlocal formatoptions-=t noexpandtab shiftwidth=8 softtabstop=0
autocmd FileType sql setlocal commentstring=--\ %s
autocmd FileType yml,yaml setlocal formatoptions-=t expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd FileType tf,hcl setlocal formatoptions-=t commentstring=#\ %s
autocmd FileType vim setlocal formatoptions-=t commentstring=\"\ %s
augroup END