-
Notifications
You must be signed in to change notification settings - Fork 0
/
private_dot_vimrc
532 lines (444 loc) · 18.1 KB
/
private_dot_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
" Documentation
" - https://learnvimscriptthehardway.stevelosh.com/
set encoding=UTF-8
set incsearch
" Change cursor shape in different modes
"
" see https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
" Define Leader key (use space)
"
nnoremap <SPACE> <Nop>
let mapleader = "\<Space>"
function! AFWOpen()
let l:cfile = expand("<cfile>")
execute "silent !curl --max-time 1 -sX POST http://localhost:8080/actions -H 'Content-Type: application/json' -d'{\"name\": \"OPEN\", \"text\": \"" .. l:cfile .. "\"}'"
redraw!
endfunction
function! AFWYank()
let l:i = 0
let l:text = ""
let l:line = ""
for s in v:event.regcontents
let l:i += 1
let l:line = s
let l:line = substitute(l:line, '\', '\\\', "g") " Escape backslash (required for JSON)
let l:line = substitute(l:line, '\t', "\\\\t", "g") " Escape \t (required for JSON)
let l:line = substitute(l:line, '"', '\\"', "g") " Escape double quotes (required for JSON)
let l:line = substitute(l:line, "!", "\\\\\!", "g") " Escape exclamation mark (required by vim command)
let l:line = substitute(l:line, "'", "'\\\\''", "g") " Escape simple quotes (required for the curl -d arg)
let l:text = l:text . l:line
if l:i < len(v:event.regcontents)
let l:text .= "\\n"
endif
endfor
let l:action = '{"name": "COPY_TO_CLIPBOARD", "text": "' . l:text . '"}'
echom l:action
let l:command = "silent !curl --max-time 1 -sX POST http://localhost:8080/actions -H 'Content-Type: application/json' -d'" . l:action . "'"
execute l:command
redraw!
endfunction
nnoremap <silent> gx :call AFWOpen()<cr>
"vnoremap <silent> "+y :call Paste()<cr>
augroup AFW
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'y' | call AFWYank() | endif
augroup END
" Speed-up syntax Highlighting
"
" see https://vim.fandom.com/wiki/Speed_up_Syntax_Highlighting
augroup vimrc
autocmd!
autocmd BufWinEnter,Syntax * syn sync minlines=500 maxlines=500
augroup END
" Set backspace behavior
"
" see https://vi.stackexchange.com/questions/2162/why-doesnt-the-backspace-key-work-in-insert-mode#answer-2163
set backspace=indent,eol,start
" Do not miss to correctly configure your XFCE Keyboard settings.
" Repeat delay: 250
" Repeat speed: 35
"
" see https://www.johnhawthorn.com/2012/09/vi-escape-delays/
set timeout ttimeoutlen=50
" Custom shortcuts
"
" Tabs
" see http://vim.wikia.com/wiki/Cycle_through_buffers_including_hidden_buffers
" see http://vim.wikia.com/wiki/Vim_buffer_FAQ
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
nnoremap <C-w><C-w> :bp\|bd #<CR>
" Move lines
" see https://vim.fandom.com/wiki/Moving_lines_up_or_down
" nnoremap <A-j> :m.+1<CR>==
" nnoremap <A-k> :m.-2<CR>==
"inoremap <A-j> <Esc>:m.+1<CR>==gi FIXME: Do not work while entering 'ê'
"inoremap <A-k> <Esc>:m.-2<CR>==gi FIXME: Do not work while entering 'ê'
" vnoremap <A-j> :m'>+1<CR>gv=gv
" vnoremap <A-k> :m'<-2<CR>gv=gv
" nmap <leader>d <plug>(YCMHover)
" see :help lazyredraw
set lazyredraw
" see :help 'ttyfast'
set ttyfast
" see https://vi.stackexchange.com/questions/514/how-do-i-change-the-current-splits-width-and-height
set mouse=n
set ttymouse=xterm2
" see https://codeyarns.com/2011/07/29/vim-chart-of-color-names/
" see https://vim.fandom.com/wiki/Xterm256_color_names_for_console_Vim
set number
set colorcolumn=120
" see :help :filetype-overview
filetype indent plugin on
syntax on
" see https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"-----------------------------------------------------------------------------------------------------------------------
" vim-plug
"-----------------------------------------------------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
" Themes
Plug 'NLKNguyen/papercolor-theme'
Plug 'morhetz/gruvbox'
Plug 'tomasr/molokai'
Plug 'altercation/vim-colors-solarized'
Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'dracula/dracula-theme'
Plug 'chriskempson/base16-vim'
Plug 'jnurmine/Zenburn'
Plug 'gosukiwi/vim-atom-dark'
Plug 'jacoborus/tender.vim'
Plug 'sjl/badwolf'
Plug 'arcticicestudio/nord-vim'
Plug 'nanotech/jellybeans.vim'
Plug 'sindresorhus/hyper-snazzy'
Plug 'rakr/vim-one'
Plug 'mhartington/oceanic-next'
Plug 'ayu-theme/ayu-vim'
Plug 'ciaranm/inkpot'
Plug 'kyoz/purify'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'sainnhe/sonokai'
Plug 'cocopon/iceberg.vim'
Plug 'tomasiser/vim-code-dark'
Plug 'kaicataldo/material.vim', { 'branch': 'main' }
" File formats
Plug 'ekalinin/Dockerfile.vim'
Plug 'cespare/vim-toml'
Plug 'hashivim/vim-terraform'
Plug 'martinda/Jenkinsfile-vim-syntax'
"Plug 'plasticboy/vim-markdown'
Plug 'evidens/vim-twig'
" Languages
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'davidhalter/jedi-vim'
Plug 'shawncplus/phpcomplete.vim'
Plug 'rust-lang/rust.vim'
Plug 'arrufat/vala.vim'
" File explorer
Plug 'lambdalisue/fern.vim', {'branch': 'add-equal-mapping-on-trash'}
Plug 'lambdalisue/fern-git-status.vim'
Plug 'lambdalisue/fern-renderer-nerdfont.vim'
Plug 'lambdalisue/glyph-palette.vim'
Plug 'lambdalisue/nerdfont.vim'
Plug 'SirVer/ultisnips'
Plug 'airblade/vim-gitgutter'
Plug 'skywind3000/asyncrun.vim'
Plug 'chrisbra/unicode.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'embear/vim-localvimrc'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary!' }
Plug 'ludovicchabant/vim-gutentags'
Plug 'majutsushi/tagbar'
Plug 'ntpeters/vim-better-whitespace'
"Plug 'preservim/nerdtree'
" ropevim
" - pip3 install --user --uppgrade rope ropemode ropevim
" - set PYTHONPATH in in ~/.bashrc
" export PYTHONPATH=$PYTHONPATH:~/.local/lib/python3.8/site-packages
" Plug 'python-rope/ropevim'
"Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dadbod'
Plug 'kristijanhusak/vim-dadbod-ui'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'tommcdo/vim-fubitive'
Plug 'shumphrey/fugitive-gitlab.vim'
Plug 'ryanoasis/vim-devicons'
" To install YouCompleteMe execute the following commands
" cd ~/.vim/plugged/YouCompleteMe
" python3 install.py --all
Plug 'Valloric/YouCompleteMe'
Plug 'dense-analysis/ale'
Plug 'vim-utils/vim-man'
Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
call plug#end()
"-----------------------------------------------------------------------------------------------------------------------
" Themes
"
" Liked
" - codedark
" - default
" - gruvbox
" - iceberg
" - jellybeans
" - material
" - OceanicNext
" - palenight
" - PaperColor
" - ron
" - tender
"-----------------------------------------------------------------------------------------------------------------------
color codedark
set background=dark
" see https://github.com/lambdalisue/fern.vim/issues/342
" see https://stackoverflow.com/questions/15277241/changing-vim-gutter-color
highlight clear SignColumn
" Tab character behavior
"
" see https://hashrocket.com/blog/posts/cool-looking-tabs-in-vim
set tabstop=4 softtabstop=4 expandtab shiftwidth=4
set list
set listchars=tab:\│\ ,
" see https://vim.fandom.com/wiki/Xterm256_color_names_for_console_Vim
highlight SpecialKey ctermfg=236 ctermbg=234:w
"-----------------------------------------------------------------------------------------------------------------------
" ALE
"
" Python
" + fixers
" - pip3 install --user --upgrade autopep8
" - pip3 install --user --upgrade black
" - pip3 install --user --upgrade isort
" - pip3 install --user --upgrade reorder-python-imports
" - pip3 install --user --upgrade yapf
" + linters
" - pip3 install --user --upgrade bandit // Security checks
" - pip3 install --user --upgrade flake8 // Code style
" - pip3 install --user --upgrade mypy // Static typing checker
" - pip3 install --user --upgrade prospector // Wrapper for pylint,pep8,mccabe
" - pip3 install --user --upgrade pycodestyle // PEP 8 checker
" - pip3 install --user --upgrade pyflakes // Check errors but not code style (WARNING: prefer 'flake8')
" - pip3 install --user --upgrade pylama // Wrapper for pycodestyle,pydocstyle,pyflakes,mccabe,pylint,radon,
" // gjslint,eradicate,mypy
" - pip3 install --user --upgrade pylint // Powerful linter
" - pip3 install --user --upgrade pyre-check // Type checker
" - pip3 install --user --upgrade vulture // Dead code analyzer
"
" YAML
" + linters
" - pip3 install --user yamllint // Linter is enabled by default when installed
"
" https://github.com/w0rp/ale
" see https://github.com/dense-analysis/ale/issues/44#issuecomment-283252535
"-----------------------------------------------------------------------------------------------------------------------
let g:ale_fix_on_save = 1
let g:ale_fixers_explicit = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace' ],
\ 'python': ['autopep8', 'black', 'isort']
\}
let g:ale_linters_explicit = 0
let g:ale_linters = {
\ 'sh': ['shellcheck'],
\ 'python': ['flake8', 'mypy', 'pylint']
\}
let g:ale_sign_error = ' 𐄂'
let g:ale_sign_warning = ' ⚠'
let g:ale_echo_msg_format = '[%severity%] [%linter%] [%code%] %s '
let g:ale_python_bandit_use_config = 1
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
" nnoremap <silent> <C-k> <Plug>(ale_previous_wrap)
" nnoremap <silent> <C-j> <Plug>(ale_next_wrap)
"-----------------------------------------------------------------------------------------------------------------------
" Vim Better Whitespace
"
" https://github.com/ntpeters/vim-better-whitespace
"-----------------------------------------------------------------------------------------------------------------------
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
let g:strip_whitespace_confirm=0
let g:show_spaces_that_precede_tabs=1
"-----------------------------------------------------------------------------------------------------------------------
" Vim Dadbod
"
" https://github.com/tpope/vim-dadbod
" https://github.com/kristijanhusak/vim-dadbod-ui
"-----------------------------------------------------------------------------------------------------------------------
let g:db_ui_use_nerd_fonts=1
let g:dbs = {
\ 'gdc_db - writer (staging)': 'mysql://[email protected]:3306/gdc_db',
\ 'gdc_db - reader (staging)': 'mysql://[email protected]:3307/gdc_db',
\ }
"-----------------------------------------------------------------------------------------------------------------------
" Fern
"
" see https://github.com/lambdalisue/fern.vim
""-----------------------------------------------------------------------------------------------------------------------
" TODO: g:fern#default_exclude*
let g:fern#disable_viewer_auto_duplication = 1
let g:fern#disable_viewer_spinner = 1
let g:fern#drawer_width = 40
let g:fern#hide_cursor = 1
let g:fern#renderer = "nerdfont"
let g:fern_git_status#disable_ignored = 1
let g:fern_git_status#disable_untracked = 1
nnoremap <silent> <Leader>r :Fern . -drawer -reveal=%<CR>
function! s:init_fern() abort
map <nowait><buffer> d <Plug>(fern-action-remove=)y<CR><CR>
endfunction
augroup fern-custom
autocmd! *
autocmd FileType fern call s:init_fern()
augroup END
augroup my-glyph-palette
autocmd! *
autocmd FileType fern call glyph_palette#apply()
autocmd FileType nerdtree,startify call glyph_palette#apply()
augroup END
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * ++nested if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | set number! | exe 'Fern' argv()[0] '-drawer' '-stay' '-keep' | set number | endif
"-----------------------------------------------------------------------------------------------------------------------
" fzf.vim
"
" https://github.com/junegunn/fzf.vim
"-----------------------------------------------------------------------------------------------------------------------
"let $FZF_DEFAULT_COMMAND = 'rg -g ""'
nnoremap <c-g> :Rg<CR>
nnoremap <c-p> :Files<CR>
"nnoremap <SPACE>b :!buku -p -f4 | fzf -m --reverse --preview "buku -p {1}" --preview-window=wrap | cut -f2
"-----------------------------------------------------------------------------------------------------------------------
" ropevim
"
" https://github.com/python-rope/ropevim
"-----------------------------------------------------------------------------------------------------------------------
let g:ropevim_autoimport_modules = ["typing"]
"-----------------------------------------------------------------------------------------------------------------------
" vim-gitgutter
"
" see https://github.com/airblade/vim-gitgutter
"-----------------------------------------------------------------------------------------------------------------------
set updatetime=200
"-----------------------------------------------------------------------------------------------------------------------
" vim-gutentags
"
" see https://github.com/ludovicchabant/vim-gutentags
" see https://www.reddit.com/r/vim/comments/d77t6j/guide_how_to_setup_ctags_with_gutentags_properly/
" see https://robertbasic.com/tags/gutentags/
"-----------------------------------------------------------------------------------------------------------------------
let g:gutentags_cache_dir = expand('~/.cache/tags')
let g:gutentags_ctags_exclude = [
\ 'composer.lock',
\ 'Makefile',
\ 'node_modules',
\ 'public',
\ 'var',
\ '*vendor/*/test*', '*vendor/*/Test*',
\ '*vendor/*/fixture*', '*vendor/*/Fixture*',
\ '*.cache',
\ '*.css', '*.less', '*.sass', '*.scss',
\ '*.git', '*.svg', '*.hg',
\ '*.html',
\ '*.json',
\ '*.exe', '*.dll',
\ '*.gif', '*.jpg', '*.jpeg', '*.png', '*.svg',
\ '*.ini',
\ '*-lock.json',
\ '*.lock',
\ '*.md',
\ '*.min.*',
\ '*.mp3', '*.ogg', '*.flac',
\ '*.phar',
\ '*.pdf', '*.doc', '*.docx', '*.ppt', '*.pptx',
\ '*.pyc',
\ '*.rar', '*.zip', '*.tar', '*.tar.gz', '*.tar.xz', '*.tar.bz2',
\ '*.rst',
\ '*.sh',
\ '*.tmp',
\ '*.swp', '*.swo',
\ '*.xlf',
\ '*.xml',
\ ]
"-----------------------------------------------------------------------------------------------------------------------
" vim-jedi
"
" see https://github.com/davidhalter/jedi-vim
"-----------------------------------------------------------------------------------------------------------------------
let g:jedi#popup_on_dot = 0
set completeopt-=preview
"-----------------------------------------------------------------------------------------------------------------------
" Localvimrc
"
" https://github.com/embear/vim-localvimrc
"-----------------------------------------------------------------------------------------------------------------------
let g:localvimrc_whitelist = [
\$HOME + '/workspace/infra/',
\]
"-----------------------------------------------------------------------------------------------------------------------
" Shfmt
"
" see https://github.com/z0mbix/vim-shfmt
"-----------------------------------------------------------------------------------------------------------------------
let g:shfmt_extra_args = '-i 4'
"-----------------------------------------------------------------------------------------------------------------------
" Tagbar
"
" see https://majutsushi.github.io/tagbar/
"-----------------------------------------------------------------------------------------------------------------------
nmap <F8> :TagbarToggle<CR>
"-----------------------------------------------------------------------------------------------------------------------
" vim-airline
"
" see https://github.com/vim-airline/vim-airline
"-----------------------------------------------------------------------------------------------------------------------
let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_powerline_fonts = 1
let g:airline_theme = 'simple'
let g:WebDevIconsUnicodeGlyphDoubleWidth = 1
"-----------------------------------------------------------------------------------------------------------------------
" Vim Markdown
"
" see https://github.com/plasticboy/vim-markdown
"-----------------------------------------------------------------------------------------------------------------------
"let g:vim_markdown_folding_disabled = 1
"let g:vim_markdown_no_default_key_mappings = 1
"autocmd BufReadPost * :redraw
"-----------------------------------------------------------------------------------------------------------------------
" vim-terraform
"
" see http://hashivim.github.io/vim-terraform/
"-----------------------------------------------------------------------------------------------------------------------
let g:terraform_fmt_on_save=1
"-----------------------------------------------------------------------------------------------------------------------
" UltiSnips
"
" see https://github.com/sirver/ultisnips
"-----------------------------------------------------------------------------------------------------------------------
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsEditSplit="vertical"
"-----------------------------------------------------------------------------------------------------------------------
" YouCompleteMe
"
" see https://valloric.github.io/YouCompleteMe/
"-----------------------------------------------------------------------------------------------------------------------
let g:ycm_auto_hover = ''
let g:ycm_error_symbol = '𐄂'
let g:ycm_open_loclist_on_ycm_diags = 1
let g:ycm_warning_sym = '⚠'