-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
380 lines (332 loc) · 12.9 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
set nocompatible
function! LoadIf(cond, ...)
let l:opts = get(a:000, 0, {})
return a:cond ? l:opts : extend(l:opts, {'on': [], 'for': [] })
endfunction
call plug#begin(has('win32') ? '~/vimfiles/bundle' : '~/.vim/bundle')
let has_async = has('timers') && ((has('job') && has('channel')) || has('nvim'))
let has_nvim_lsp = has('nvim')
" Workaround for vim/vim#3117
try | exec 'pythonx' 'pass' | catch | endtry
" Let's start from this
Plug 'tpope/vim-sensible'
" Check that (n)vim is capablle of running neovim remote plugins
" and load shims if necessary
let has_nvim_rpc=has('nvim') || (version >= 800 && has('python3'))
Plug 'roxma/nvim-yarp', LoadIf(has_nvim_rpc && !has('nvim'))
Plug 'roxma/vim-hug-neovim-rpc', LoadIf(has_nvim_rpc && !has('nvim'))
" Look and feel
Plug 'vim-scripts/xterm16.vim'
Plug 'nanotech/jellybeans.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'vim-scripts/let-modeline.vim'
Plug 'jlanzarotta/bufexplorer', LoadIf(!executable('fzf'))
" Behavior/General
Plug 'easymotion/vim-easymotion'
Plug 'jiangmiao/auto-pairs'
Plug 'sjl/gundo.vim'
Plug 'tomtom/tcomment_vim' " gc{motion}, gc<count>c{motion}, gcc
Plug 'tpope/vim-surround'
if executable('fzf')
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
else
Plug 'ctrlpvim/ctrlp.vim'
endif
" Behavior/Integration
Plug 'SirVer/ultisnips', LoadIf(has('python3'))
Plug 'honza/vim-snippets'
Plug 'mattn/emmet-vim'
Plug 'vim-syntastic/syntastic', LoadIf(!has_async)
Plug 'dense-analysis/ale', LoadIf(has_async)
Plug 'sbdchd/neoformat'
Plug 'editorconfig/editorconfig-vim'
Plug 'jamessan/vim-gnupg'
" Version Control
"Plug 'http://repo.or.cz/r/vcscommand.git' " p4/hg/etc...
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
" Language Server
Plug 'neovim/nvim-lspconfig', LoadIf(has_nvim_lsp)
Plug 'p00f/clangd_extensions.nvim', LoadIf(has_nvim_lsp)
Plug 'deoplete-plugins/deoplete-lsp', LoadIf(has_nvim_lsp)
Plug 'ojroques/nvim-lspfuzzy', LoadIf(has_nvim_lsp)
Plug 'autozimu/LanguageClient-neovim', LoadIf(!has_nvim_lsp, {
\ 'branch': 'next',
\ 'do': (has('win32') ? 'powershell.exe -ExecutionPolicy Bypass -File install.ps1'
\ : 'bash install.sh')
\ })
" Completion
let deoplete_opts = has('nvim') ? { 'do': ':UpdateRemotePlugins' } : {}
Plug 'Shougo/deoplete.nvim', LoadIf(has_nvim_rpc, deoplete_opts)
unlet deoplete_opts
" Languages
Plug 'nvim-treesitter/nvim-treesitter', LoadIf(has('nvim'), { 'do': ':TSUpdate' })
Plug 'PProvost/vim-ps1'
"Plug 'adelarsq/neofsharp.vim'
"Plug 'fsharp/vim-fsharp', {'for': 'fsharp'}
"Plug 'othree/yajs.vim'
"Plug 'othree/xml.vim'
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}
Plug 'rust-lang/rust.vim'
Plug 'habamax/vim-asciidoctor'
unlet has_async
unlet has_nvim_lsp
unlet has_nvim_rpc
call plug#end()
set encoding=utf-8
set fileencodings=utf-8,cp1251,koi8-r,default
set showcmd " display incomplete commands
set tabstop=4
set shiftwidth=4 " 4 characters for indenting
set expandtab
set number " line numbers
set foldmethod=syntax
set foldlevel=8
set scrolljump=5
set scrolloff=5 " 5 lines bevore and after the current line when scrolling
set ignorecase " ignore case
set smartcase " but don't ignore it, when search string contains uppercase letters
set hidden " allow switching buffers, which have unsaved changes
set signcolumn=yes " Always show sign column
set showmatch " showmatch: Show the matching bracket for the last ')'?
set novisualbell " visual bell instead of beeping
set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions
set completeopt=menuone,noselect
set confirm
" airline already displays mode
set noshowmode
set nofixeol
set updatetime=300
"-------------------------------------------------------------------------------
" Load configuration files specific for Vim or Neovim
"-------------------------------------------------------------------------------
let s:dotfiles = fnamemodify(resolve(expand('<script>:p')), ':h')
let s:extraconf = has('nvim') ? 'init-extra.lua' : 'init-extra.vim'
exec 'source' s:dotfiles .. '/vim/' .. s:extraconf
"-------------------------------------------------------------------------------
" Look and Theme settings
"-------------------------------------------------------------------------------
let s:theme='jellybeans'
set background=dark
"let xterm16_brightness='high'
let xterm16_colormap='soft'
let xterm16bg_Normal='none'
let g:solarized_termcolors=256
"let g:solarized_termtrans=1
" Transparent background for Jellybeans
let g:jellybeans_overrides = {
\ 'background': { 'ctermbg': 'none', '256ctermbg': 'none' }
\}
if has('nvim') && has('termguicolors') && $COLORTERM ==# 'truecolor'
set termguicolors
let g:jellybeans_overrides['background']['guibg'] = 'none'
endif
" check if we are not running in powershell or cmd text mode
if !has('win32') || has('gui_running')
set t_Co=256
exec 'colo' s:theme
endif
function! InitGVim()
set guioptions=agim
set columns=120
set lines=40
if has('gui_win32')
set encoding=utf-8
set renderoptions=type:directx
set guifont=Fira_Code:h11
elseif has('nvim')
" GuiFont! Liberation Mono:h11
GuiFont! Fira Code:h11
" Show text tabline and popups in nvim-qt
GuiTabline 0
GuiPopupmenu 0
else
set guifont=Liberation\ Mono\ 11
endif
exec 'colo' s:theme
endfunction
" Workaround for https://github.com/equalsraf/neovim-qt/issues/94
" this requires adding 'doautocmd GUIEnter' into ginit.vim
if has('gui_running')
call InitGVim()
else
autocmd GUIEnter * call InitGVim()
endif
"-------------------------------------------------------------------------------
" highlight paired brackets
"-------------------------------------------------------------------------------
highlight MatchParen ctermbg=blue guibg=lightyellow
"-------------------------------------------------------------------------------
" Keybindings
"-------------------------------------------------------------------------------
" imap {<CR> {<CR>}<Esc>O
" comma always followed by a space
inoremap , ,<Space>
" " autocomplete parenthesis, (brackets) and braces
" inoremap ( ()<Left>
" inoremap [ []<Left>
" inoremap { {}<Left>
" vnoremap ( s()<Esc>P<Right>%
" vnoremap [ s[]<Esc>P<Right>%
" vnoremap { s{}<Esc>P<Right>%
" vnoremap ) s( )<Esc><Left>P<Right><Right>%
" vnoremap ] s[ ]<Esc><Left>P<Right><Right>%
" vnoremap } s{ }<Esc><Left>P<Right><Right>%
" " autocomplete quotes (visual and select mode)
" xnoremap ' s''<Esc>P<Right>
" xnoremap " s""<Esc>P<Right>
" xnoremap ` s``<Esc>P<Right>
"-------------------------------------------------------------------------------
" The current directory is the directory of the file in the current window.
"-------------------------------------------------------------------------------
"if has("autocmd")
" autocmd BufEnter * :lchdir %:p:h
"endif
"-------------------------------------------------------------------------------
" SPELLCHECK CONFIGURATION
"-------------------------------------------------------------------------------
if version >= 700
set spelllang=ru,en
set nospell
endif
"===============================================================================
" CONFIGURATIONS FOR SPECIFIC FILE TYPES
"===============================================================================
"
let g:GPGDefaultRecipients=["4F071603387A382A"]
" vim -b : edit binary using xxd-format!
augroup Binary
au!
au BufReadPre *.bin,*.swf,*.abc let &bin=1
au BufReadPost *.bin,*.swf,*.abc if &bin | %!xxd
au BufReadPost *.bin,*.swf,*.abc set ft=xxd | endif
au BufWritePre *.bin,*.swf,*.abc if &bin | %!xxd -r
au BufWritePre *.bin,*.swf,*.abc endif
au BufWritePost *.bin,*.swf,*.abc if &bin | %!xxd
au BufWritePost *.bin,*.swf,*.abc set nomod | endif
augroup END
" Fix auto-added EOL in PHP files.
autocmd BufNewFile *.inc setlocal filetype=php
autocmd BufReadPre *.inc setlocal filetype=php
autocmd FileType php setlocal noeol binary fileformat=dos
" lisp/scheme syntax hilighting
let g:lisp_rainbow = 1
"===============================================================================
" VARIOUS PLUGIN CONFIGURATIONS
"===============================================================================
"-------------------------------------------------------------------------------
" Snippets
"-------------------------------------------------------------------------------
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
"-------------------------------------------------------------------------------
" Language servers and plugins
"-------------------------------------------------------------------------------
let g:ale_disable_lsp = 1
let g:ale_pattern_options_enabled = 1
let g:ale_pattern_options = {
\ '\.\(c\|cpp\|h\|hpp\)$': {'ale_enabled': 0},
\ '\.rs$': {'ale_enabled': 0}
\ }
let g:ale_linter_aliases = {
\ 'asciidoctor': ['asciidoc'],
\ }
"-------------------------------------------------------------------------------
" Neoformat
"-------------------------------------------------------------------------------
let g:neoformat_enabled_javascript = ['prettier']
let g:neoformat_enabled_typescript = ['prettier']
nnoremap <silent> <A-S-F> :Neoformat<CR>
"-------------------------------------------------------------------------------
" EditorConfig
"-------------------------------------------------------------------------------
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
"-------------------------------------------------------------------------------
" deoplete
"-------------------------------------------------------------------------------
let g:deoplete#enable_at_startup = 1
let g:python3_host_prog = '/usr/bin/python3'
"-------------------------------------------------------------------------------
" netrw
"-------------------------------------------------------------------------------
let g:netrw_liststyle = 3 "tree
"let g:netrw_altv=&spr
let g:netrw_browse_split=0
let g:netrw_preview=1
let g:netrw_winsize=-25
autocmd StdinReadPre * let s:std_in=1
" Disabled as it bugs nvim-qt
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | Ex . | endif
"-------------------------------------------------------------------------------
" Airline
"-------------------------------------------------------------------------------
let g:airline_symbols_ascii = 1
let g:airline#extensions#branch#vcs_priority = ['git']
let g:airline#extensions#branch#vcs_checks = []
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
"-------------------------------------------------------------------------------
" CtrlP
"-------------------------------------------------------------------------------
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_root_markers = ['Makefile', '*.spec']
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|\.hg|\.svn|node_modules)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'cd %s && git ls-files . -co --exclude-standard'],
\ 2: ['.hg', 'hg --cwd %s locate -I .'],
\ }
\ }
" if executable('rg')
" let g:ctrlp_user_command = 'rg --files %s'
" let g:ctrlp_use_caching = 0
" let g:ctrlp_use_buffer = 'et'
" endif
"-------------------------------------------------------------------------------
" FZF
"-------------------------------------------------------------------------------
if executable('fzf') && executable('rg')
set grepprg=rg\ --vimgrep
let $FZF_DEFAULT_COMMAND='rg --files --follow . '
command! -bang -nargs=* Find
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case --fixed-strings --hidden -L -- '.shellescape(<q-args>),
\ 1,
\ <bang>0)
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
nnoremap <c-p> :Files<CR>
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
endif
"-------------------------------------------------------------------------------
" Gundo
"-------------------------------------------------------------------------------
nnoremap <F5> :GundoToggle<CR>
let g:gundo_right = 1
" https://bitbucket.org/sjl/gundo.vim/issues/42
if has('python3')
let g:gundo_prefer_python3 = 1
endif
"-------------------------------------------------------------------------------
" Buffer explorer
"-------------------------------------------------------------------------------
if executable('fzf')
noremap gb :Buffers<CR>
else
noremap gb :BufExplorerHorizontalSplit<CR>
endif