-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
532 lines (466 loc) · 16.1 KB
/
Copy pathvimrc
File metadata and controls
532 lines (466 loc) · 16.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
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
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
if filereadable("/bin/zsh")
set shell=/bin/zsh
elseif filereadable("/bin/bash")
set shell=/bin/bash
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/gv.vim'
"""Comment supports
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-markdown'
"""Git supports
Plug 'tpope/vim-fugitive'
"""Date inc/sub (Alt-a/Alt-x)
Plug 'tpope/vim-speeddating'
"""Surround parentheses brackets, quotes, XML tags and more
Plug 'tpope/vim-surround'
"""Mapping simply short normal mode aliases
Plug 'tpope/vim-unimpaired'
"""Repeat for surround, speeddating, abolish, unimpaired, commentary
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-vinegar', { 'on': 'ToggleVExplorer' }
"""DB adapters
Plug 'tpope/vim-dadbod'
""""""Vim-scripts repos
"""Sniplets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
"""""Other repos
Plug 'mattn/webapi-vim'
""" Tests for most languages and test systems
Plug 'vim-test/vim-test'
"""Draw undo tree
Plug 'mbbill/undotree', { 'on': ['UndotreeToggle', 'UndotreeShow'] }
"""Status bar
Plug 'vim-airline/vim-airline'
"""Ack supports
Plug 'mileszs/ack.vim', { 'on': ['LAck', 'Ack'] }
"""""Color themes
Plug 'morhetz/gruvbox'
""" Docs on Shift-K
Plug 'thinca/vim-ref'
"""Seacher
Plug 'ctrlpvim/ctrlp.vim', { 'on': ['CtrlP', 'CtrlPBuffer']}
"""Align
Plug 'junegunn/vim-easy-align', { 'on': ['EasyAlign', '<Plug>(EasyAlign)'] }
""" Start page with sessions, last files and others
Plug 'mhinz/vim-startify'
""" Asynchronous Lint Engine
Plug 'dense-analysis/ale'
Plug 'mattn/gist-vim'
"""""" For Golang
Plug 'fatih/vim-go', { 'for': 'go', 'do': ':GoUpdateBinaries' }
"""""" For Python
Plug 'petobens/poet-v', { 'for': 'python' }
""" Asynchronous Language Server Protocol
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'andreypopp/asyncomplete-ale.vim'
""" Multilanguage debugger
Plug 'puremourning/vimspector'
""" Spellchecker for programmers
Plug 'psliwka/vim-dirtytalk', { 'do': ':DirtytalkUpdate' }
" Add plugins to &runtimepath
call plug#end()
"==================================VIM CONFIG==================================
if filereadable("/bin/zsh")
set shell=/bin/zsh
elseif filereadable("/bin/bash")
set shell=/bin/bash
endif
set spell! spelllang=ru_yo,en,programming
set helplang=en
set cursorline
set cursorcolumn
" Time to wait after ESC (default causes an annoying delay)
set timeoutlen=250
set smartcase
" подсвечивать поиск
set hlsearch
" show matches while typing
set incsearch
"" Fix for Russian world
set iskeyword=@,48-57,_,192-255
"" Number of visual spaces per TAB
set tabstop=4
"" Number of spaces in TAB when editing
set softtabstop=4
"" Tabs replaced on spaces
set expandtab
set smarttab
"" Show unprintable symbols with set list
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set showmatch " Show matching brackets.
set autoindent
" перенос по словам, а не по буквам
set linebreak
set dy=lastline
"" Show line number
set number
"" Wrap lines by 200 char
set textwidth=200
set colorcolumn=200
set shiftwidth=4
" round indent to multiple of 'shiftwidth'
set shiftround
set mouse=a
" Yanks go on clipboard instead
set clipboard+=unnamed
set completeopt=longest,menuone
set pumheight=15
set wildmode=list:longest,full
set wildignore+=.git,.svn
set wildignore-=deps
set wildoptions=fuzzy
set history=256
set undodir=~/.vim/undodir/
set undofile
set undolevels=1000
set undoreload=10000
""Backup
set backup
" set with '^=' prepends the directory name to the head of the list (check for exists)
" the '//' at the end of the directory name tells vim to use absolute path
set backupdir^=/tmp//,/var/tmp//
set directory^=/tmp//,/var/tmp//
" Required for operations modifying multiple buffers like rename.
set hidden
let g:vimspector_enable_mappings = 'HUMAN'
"" default vertical split file browser
let g:netrw_preview = 1
" Hit enter in the file browser to open the selected
" file with :vsplit to the right of the browser.
let g:netrw_browse_split = 4
let g:netrw_altv = 1
" Recursion delete directory
let g:netrw_localrmdir='rm -r'
" absolute width of netrw window
let g:netrw_winsize = -23
" do not display info on the top of window
let g:netrw_banner = 0
" tree-view
let g:netrw_liststyle = 3
let g:gutentags_exclude_project_root = [ '/usr/local', '/usr/lib' ]
""Add Russian keyboard for commands
set keymap=russian-jcukenwin
set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz
set iminsert=0
set imsearch=0
" DTL for erlydtl
au BufRead,BufNewFile *.{dtl,tmpl} set filetype=django
au BufRead,BufNewFile *{relx,rebar,sys}.config* set filetype=erlang
au BufRead,BufNewFile *.{appup,app} set filetype=erlang
au BufRead,BufNewFile *.{config,appup.src,app.src} set filetype=erlang
" Open file in last place
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
"Folds
set foldmethod=syntax
let g:markdown_fold_style = 'nested'
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh']
let g:markdown_syntax_conceal = 0
let g:tagbar_autofocus = 1
let g:ackprg = 'ag --nogroup --nocolor --column --ignore tags --ignore-dir "release" -U'
let g:ackhighlight = 1
let g:ale_open_list = 1
let g:ale_completion_enabled = 0
let g:ale_linters = {
\ 'go': ['golangci-lint'],
\ 'zsh': ['shellcheck'],
\ 'sh': ['shellcheck'],
\ 'bash': ['shellcheck'],
\ 'python': ['pyright', 'pyflakes', 'jedils', 'pyre'],
\ 'yaml': [],
\}
let g:ale_go_golangci_lint_package = 1
let g:ale_go_golangci_lint_options = '
\ --disable-all
\ --exclude-use-default
\ --tests=false
\ --enable=goconst
\ --enable=gocritic
\ --enable=gocyclo
\ --enable=goimports
\ --enable=gosec
\ --enable=gosimple
\ --enable=govet
\ --enable=ineffassign
\ --enable=interfacer
\ --enable=lll
\ --enable=misspell
\ --enable=nakedret
\ --enable=staticcheck
\ --enable=stylecheck
\ --enable=typecheck
\ --enable=unconvert
\ --enable=unparam
\ --enable=unused
\ --enable=varcheck
\ --enable=dupl
\ --enable=golint
\ --enable=errcheck
\ --enable=errorlint
\ --enable=revive
\ --enable=exportloopref'
let g:ale_c_parse_makefile = 1
let g:ale_c_parse_compile_commands = 1
let g:go_code_completion_enabled = 0
let g:go_auto_type_info = 0
let g:go_doc_keywordprg_enabled = 0
let g:go_imports_autosave = 0
let g:go_fmt_command = "goimports"
let g:go_fmt_options = {
\ 'goimports': '-l',
\ }
let g:go_gopls_enabled = 0
let g:go_gopls_deep_completion = 0
let g:go_fold_enable = ['import', 'varconst', 'package_comment']
let g:go_highlight_array_whitespace_error = 1
let g:go_highlight_string_spellcheck = 1
let g:go_highlight_format_strings = 1
let g:go_highlight_diagnostic_errors = 0
let g:go_highlight_diagnostic_warnings = 0
let g:go_def_mapping_enabled = 0
let g:snippets_dir = '~/.vim/plugged/vim-snippets/UltiSnips'
let g:snips_author = 'platinumthinker'
let g:my_email_addr = 'platinumthinker@gmail.com'
let g:startify_lists = [
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
\ { 'type': 'files', 'header': [' MRU '] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
"" Don't change dir for opening new file from start screen
let g:startify_change_to_dir = 0
let g:startify_custom_header = banner#VersionBanner()
let g:startify_files_number = 25
"=============================DELETE TRAILING SPACES===========================
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd FileType c,cpp,java,erlang,python autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :",
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no')
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
"================================ UUID ========================================
nnoremap <silent><leader>ig "=system('python -c "import uuid; print(uuid.uuid4(), end=\"\");"')<CR>P
"================================ Gist ========================================
let g:gist_detect_filetype = 1
let g:gist_show_privates = 1
"========================= Encode\Decode HTML =================================
function! HtmlEntities(line1, line2, action)
let search = @/
let range = 'silent ' . a:line1 . ',' . a:line2
if a:action == 0 " must convert & last
execute range . 'sno/</</eg'
execute range . 'sno/>/>/eg'
execute range . 'sno/&/&/eg'
execute range . 'sno/"/"/eg'
else " must convert & first
execute range . 'sno/&/&/eg'
execute range . 'sno/</</eg'
execute range . 'sno/>/>/eg'
execute range . 'sno/"/"/eg'
endif
nohl
let @/ = search
endfunction
command! -range -nargs=1 Entities call HtmlEntities(<line1>, <line2>, <args>)
noremap <silent> \h :Entities 0<CR>
noremap <silent> \H :Entities 1<CR>
"================================KEY BINDINGS==================================
inoremap jj <ESC>
"Open/close folds
nnoremap <Space> za
nmap <C-p> :CtrlP<CR>
nmap <leader>b :CtrlPBuffer<CR>
nmap <leader>g :LAck <cword><CR>
vmap <Enter> <Plug>(EasyAlign)
nnoremap <leader><space> :nohlsearch<CR> " turn off search highlight
""Edit vimrc
nnoremap <leader>ev :vsp $MYVIMRC<CR>
""Load vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>
nnoremap <leader>u :UndotreeToggle<CR>
nnoremap <leader>jj :%!python -m json.tool<CR>
nnoremap <leader>jx !%xmllint --format --recover -^M<CR>
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>tf :TestFile<CR>
nmap <silent> <leader>ta :TestSuite<CR>
nmap <silent> <leader>tl :TestLast<CR>
nmap <silent> <leader>tg :TestVisit<CR>
" Toggle netrw like NERDTree
function! ToggleVExplorer()
if exists("t:expl_buf_num")
let expl_win_num = bufwinnr(t:expl_buf_num)
if expl_win_num != -1
let cur_win_nr = winnr()
exec expl_win_num . 'wincmd w'
close
unlet t:expl_buf_num
else
unlet t:expl_buf_num
endif
else
exec '1wincmd w'
Vexplore
let t:expl_buf_num = bufnr("%")
endif
endfunction
map <silent> - :call ToggleVExplorer()<CR>
command! W :execute ':silent w !sudo tee % > /dev/null' | :edit!
"================================COLOR THEME UP================================
set termguicolors
syntax enable
set background=light
if !has('gui_running')
set t_Co=256
let g:gruvbox_italic = 1
endif
let g:gruvbox_contrast_light = 'hard'
colorscheme gruvbox
highlight SpellBad term=reverse ctermbg=226
highlight SpellRare term=reverse ctermbg=226
highlight lCursor guifg=NONE guibg=Cyan
"====================================CTRL_P====================================
let g:ctrlp_max_files = 10000
let g:ctrlp_max_depth = 10
let g:ctrlp_working_path_mode = 'rw'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|rebar|eunit)$',
\ 'file': '\v\.(beam|exe|so|dll|dump|core|class|o)$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS'
\ }
let g:Powerline_symbols = 'fancy'
"============================STATUS BAR SETTINGS (vim-airline)==================
set laststatus=2
let g:airline_experimental = 1
let g:airline_theme = 'gruvbox'
let g:airline_powerline_fonts = 1
let g:airline_detect_spell = 0
let g:airline_detect_spelllang = 0
let g:airline_skip_empty_sections = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#ctrlp#enabled = 1
" Hide fileformat
let g:airline_section_y = ''
let g:airline_section_z = '%p%% | %l/%L'
" function! BCloseCb(channel, exit_status)
" if a:exit_status == 0
" call RunBackgroundCommand()
" endif
" endfunction
function! RunBackgroundCommand()
let l:color_file = $HOME . '/.color'
let l:color = readfile(l:color_file, 1)[0]
if l:color == 'light'
set background=light
else
set background=dark
endif
" " call gruvbox#hls_toggle()
" let l:command = 'inotifywait -e close_write ' . l:color_file
" " " Launch the job.
" " " Notice that we're only capturing out, and not err here. This is because, for some reason, the callback
" " " will not actually get hit if we write err out to the same file. Not sure if I'm doing this wrong or?
" call job_start(l:command, {'exit_cb': 'BCloseCb', "in_io": "null", "out_io": "null", "err_io": "null"})
endfunction
if has("unix")
let s:uname = system("uname")
if s:uname != "Darwin\n" && has('job')
call RunBackgroundCommand()
endif
endif
if executable('clangd')
augroup lsp_clangd
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'allowlist': ['c', 'cpp', 'objc', 'objcpp'],
\ })
augroup end
endif
if executable('arduino-language-server')
augroup lsp_arduino_language_server
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'arduino-language-server',
\ 'cmd': {server_info->['arduino-language-server', '-cli-config', '~/.arduino15']},
\ 'allowlist': ['arduino'],
\ })
augroup end
endif
if executable('gopls')
"" Open test file
autocmd FileType go nmap <buffer> gT :e %:r_test.go<CR>
nmap <buffer> K <plug>(lsp-hover)
augroup lsp_gopls
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': {server_info->['gopls']},
\ 'allowlist': ['go'],
\ })
augroup end
endif
if executable('pyright-langserver')
augroup lsp_pyright
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'pyright-langserver',
\ 'cmd': {server_info->['pyright-langserver', '--stdio']},
\ 'allowlist': ['python'],
\ })
augroup end
endif
if executable('erlang_ls')
augroup lsp_erlang_ls
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'erlang-language-server',
\ 'cmd': {server_info->['erlang_ls']},
\ 'allowlist': ['erlang'],
\ })
augroup end
endif
if executable('clojure-lsp')
augroup lsp_clojure_lsp
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clojure-language-server',
\ 'cmd': {server_info->['clojure-lsp']},
\ 'allowlist': ['clojure'],
\ })
augroup end
endif
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gti <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
endfunction
augroup lsp_buffer_keys
autocmd!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup end