-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
367 lines (346 loc) · 15.9 KB
/
init.vim
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
"---------------------------=== Set plugins Path ===----------------------------
let vim_plug_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
if has("unix")
if has("nvim")
let vim_plug_root="~/.local/share/nvim"
let vim_plug_plugged=vim_plug_root ."/plugged"
let vim_plug=vim_plug_root . "/site/autoload/plug.vim"
elseif has("vim")
endif
elseif has("win32")
let vim_plug_root="~\\AppData\\Local\\nvim"
let vim_plug_plugged= vim_plug_root ."\\plugged"
let vim_plug=vim_plug_root . "\\autoload\\plug.vim"
let g:python_host_prog='C:/Python27/python.exe'
let g:python3_host_prog='C:/Python36/python.exe'
endif
"---------------------------=== Install vim-plug ===----------------------------
"
if empty(glob(vim_plug))
if has("unix")
silent execute "!curl --create-dirs " . vim_plug_url . " -fLo " . vim_plug
elseif has("win32")
let setup_script = vim_plug_root . "\\install-vimplug.ps1"
silent execute "!powershell.exe " . setup_script
endif
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"--------------------------=== Plugins difinitions ===--------------------------
"
call plug#begin(vim_plug_plugged)
"------------------------------=== Appearance ===-------------------------------
"
Plug 'w0ng/vim-hybrid'
Plug 'itchyny/lightline.vim'
"------------------------=== Code/project navigation ===------------------------
"
Plug 'scrooloose/nerdtree' " Project and file navigation
Plug 'majutsushi/tagbar' " Class/module browser
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tacahiroy/ctrlp-funky'
Plug 'scrooloose/nerdcommenter' " Nerd comment
Plug 'fisadev/FixedTaskList.vim' " Pending tasks list
Plug 'tpope/vim-surround' " Parentheses, brackets, quotes, XML tags, and more
Plug 'Valloric/MatchTagAlways'
Plug 'terryma/vim-multiple-cursors'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'junegunn/vim-easy-align'
Plug 'vim-syntastic/syntastic'
Plug 'hashivim/vim-terraform'
"---------------------------=== Snippets support ===----------------------------
"
Plug 'SirVer/ultisnips'
Plug 'garbas/vim-snipmate' " Snippets manager
Plug 'MarcWeber/vim-addon-mw-utils' " dependencies #1
Plug 'tomtom/tlib_vim' " dependencies #2
Plug 'honza/vim-snippets' " snippets repo
"--------------------=== Language and complation plugins ===--------------------
"
"--------------------------------=== Ansible ===--------------------------------
"
"---------------------------------=== Other ===---------------------------------
"
Plug 'tpope/vim-fugitive'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/neocomplete.vim'
endif
Plug 'ervandew/supertab'
Plug 'pearofducks/ansible-vim'
"----------------------------------=== Go ===-----------------------------------
"
Plug 'fatih/vim-go', { 'for': 'go' , 'do': ':GoInstallBinaries' }
Plug 'nsf/gocode', { 'rtp': 'nvim', 'do': '~/.config/nvim/plugged/gocode/nvim/symlink.sh' }
if has('nvim')
Plug 'zchee/deoplete-go', { 'do': 'make', 'for': 'go'}
endif
"------------------------------=== Powershell ===-------------------------------
"
Plug 'PProvost/vim-ps1', { 'for': 'ps1' }
"--------------------------------=== Python ===---------------------------------
"
if has('nvim')
Plug 'zchee/deoplete-jedi', { 'for': 'py' }
endif
call plug#end()
"-------------------------=== Global Configuration ===--------------------------
"
silent! colorscheme hybrid " Цветовая тема
set background=dark
set numberwidth=1 " Keep line numbers small if it's shown
syntax on " Подсветка синтаксиса
filetype on " Настройки для типов файлов
filetype plugin on " Типы файлов
filetype indent on " отпусты по типу файлов
set fo+=cr " Что то с Enter при вызове меню
set wrap " (no)wrap - динамический (не)перенос длинных строк
set linebreak " переносить целые слова
set cin " Отступы в стиле С
set lz " Ленивая перерисовка экрана
set autoindent " автоматический отступ
set autoread " перечитывать изменённые файлы автоматически
set backspace=indent,eol,start whichwrap+=<,>,[,] "Удобное поведение backspace
set ch=1 " Сделать строку команд высотой в одну строку
set completeopt=menu " только доступные варианты автодополнени " не использовать свап файл для сброса буферовя
set foldenable " Включить сворачивание блоков кода
set foldlevelstart=100 " Первые 100 блоков будет развернуты остальные свернуты
set foldmethod=indent " Тип сворачивания. по отступам
set hlsearch " Включаем подсветку выражения, которое ищется в тексте
set ignorecase " Игнорировать регистр букв при поиске
set incsearch " Поиск по набору текста (очень полезная функция)
set incsearch " При поиске перескакивать на найденный текст в процессе набора строки
set laststatus=2 " Всегда отображать статусную строку для каждого окна
set linebreak " Перенос целых сло Перенос целых словв
set mouse=a " Поодержка мыши при работе в терминале
set nobackup " Вырубаем .swp и ~ (резервные) файлы
set nocompatible " Включаем несовместимость настроек с Vi (ибо Vi нам и не понадобится).
set noswapfile " не использовать свап файл для сброса буферов
set hidden " не выгружать буфер когда переключаешься на другой
set novisualbell " Выключаем надоедливый "звонок" (моргает, а не бибикает при ошибках)
set nowrapscan " Останавливать поиск при достижении конца файла
set nu " Нумерация строк
set ruler " Показывать положение курсора всё время.
set sessionoptions=curdir,buffers,tabpages " Опции сессий
set shiftwidth=8 " размер отступов (нажатие на << или >>)
set showcmd " Показывать незавершенные команды в статус баре
set showmatch " показывать первую парную скобку после ввода второй
set showtabline=1
set smartindent " Умные отступы
set smarttab
set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab
set splitbelow
set title " показывать имя буфера в заголовке терминала
set whichwrap=b,<,>,[,],l,h " перемещать курсор на следующую строку при нажатии на клавиши вправо-влево и пр.
set t_Co=256 " использовать больше цветов в терминале
set matchpairs+=<:> " показывать совпадающие скобки для HTML-тегов
set statusline=%<%f%h%m%r%=format=%{&fileformat}\ file=%{&fileencoding}\ enc=%{&encoding}\ %b\ 0x%B\ %l,%c%V\ %P
set undolevels=2048 " хранить историю изменений числом N
set wildmode=longest,list,full
set wildmenu
"Проблема красного на красном при spellchecking-е решается такой строкой в .vimrc
highlight SpellBad ctermfg=Black ctermbg=Red
"set completeopt-=preview
"set completeopt+=longest
set pumheight=10 " Completion window max size
set hidden " Buffer should still exist if window is closed
set completeopt=menu,menuone " Show popup menu, even if there is one entry
" neocomplete like
set completeopt+=noinsert
" deoplete.nvim recommend
set completeopt+=noselect
set mps-=[:]
set ttyfast
" setlocal omnifunc=
if has('gui_vimr')
set termguicolors
endif
if has('unnamedplus')
set clipboard^=unnamed
set clipboard^=unnamedplus
endif
"-------------------------=== PLUGINS CONFIGURATION ===-------------------------
"
"-------------------------------=== Deoplate ===--------------------------------
"
if has('nvim')
let g:deoplete#enable_at_startup = 1
let g:deoplete#sources#go#use_cache = 1
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
endif
"----------------------------=== Nerd commenter ===-----------------------------
"
let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default
let g:NERDCompactSexyComs = 1 " Use compact syntax for prettified multi-line comments
let g:NERDTrimTrailingWhitespace = 1 " Enable trimming of trailing whitespace when uncommenting
" ----------------------------=== MatchTagAlways ===-----------------------------
"
let g:mta_use_matchparen_group = 1
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\}
"-------------------------------=== Supertab ===--------------------------------
"
let g:SuperTabDefaultCompletionType = "<c-x><c-o>"
"-------------------------------=== Ultisnip ===--------------------------------
"
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets = "<c-k>" "List possible snippets based on current file
"------------------------------=== Neocomplate ===------------------------------
"
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
"-------------------------------=== vim-plug ===--------------------------------
"
let g:plug_shallow = 1
let g:plug_window = "topleft new"
"--------------------------------=== Airline ===--------------------------------
let g:enable_bold_font = 1
"--------------------------------=== TagBar ===---------------------------------
"
let g:tagbar_left = 0
let g:tagbar_autofocus = 1
let g:tagbar_sort = 0 "tagbar shows tags in order of they created in file
let g:tagbar_foldlevel = 1 "close tagbar folds by default
let g:tagbar_width = 35
let g:tagbar_compact = 1
let g:tagbar_iconchars = ['+', '-']
"-------------------------------=== NerdTree ===--------------------------------
"
let g:NERDTreeDirArrows = 0
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
"----------------------------------=== vim-go ===-----------------------------------
"
let g:go_disable_autoinstall = 0
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_addtags_transform = "camelcase"
let g:go_fmt_command = "goimports"
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck', 'varcheck']
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
"-------------------------------=== Syntastic ===-------------------------------
"
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_enable_signs=1
"-------------------------------=== Key maps ===--------------------------------
"
"----------------------------------=== vim ===----------------------------------
"
" Exit terminal
tnoremap <Esc> <C-\><C-n>
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv
" Jump to next error with Ctrl-n and previous error with Ctrl-m. Close the
" quickfix window with <leader>a
map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
"---------------------------------=== Save ===----------------------------------
"
nmap <F4> :w!<CR>
imap <F4> <Esc>:w!<CR>
vmap <F4> <Esc>:w!<CR>
"-------------------------------=== Exit VIM ===--------------------------------
"
nmap <F5> :qa!<CR>
imap <F5> <Esc>:qa!<CR>
vmap <F5> <Esc>:qa!<CR>
"------------------------------=== CtrlPFunky ===-------------------------------
"
nnoremap <Leader>fu :CtrlPFunky<Cr>
" narrow the list down with a word under cursor
nnoremap <Leader>fU :execute 'CtrlPFunky ' . expand('<cword>')<Cr>
"--------------------------------=== TagBar ===---------------------------------
"
map <F3> :TagbarToggle<CR>
imap <F3> <Esc>:TagbarToggle<CR>
vmap <F3> <Esc>:TagbarToggle<CR>
"-------------------------------=== Syntastic ===-------------------------------
"
map <F6> :SyntasticCheck<CR>
imap <F6> <Esc>:SyntasticCheck<CR>
vmap <F6> <Esc>:SyntasticCheck<CR>
map <F6><F6> :lnext<CR>
nnoremap <F6><Esc> :SyntasticReset<CR>
"-------------------------------=== NerdTree ===--------------------------------
"
map <F2> :NERDTreeToggle<CR>
imap <F2> :NERDTreeToggle<CR>
vmap <F2> :NERDTreeToggle<CR>
"-----------------------------=== Nerdcommenter ===-----------------------------
"
if has('macunix')
nmap <D-/> \c<space>
imap <D-/> \c<space>
vmap <D-/> \c<space>
else
nmap <C-_> \c<space>
imap <C-_> \c<space>
vmap <C-_> \c<space>
endif
"-------------------------------=== FileType ===--------------------------------
"
"----------------------------------=== Go ===-----------------------------------
"
augroup go
autocmd!
au FileType go set sw=4
au FileType go set ts=4
au FileType go set sts=4
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage-toggle)
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <F7> <Plug>(go-coverage-toggle)
au FileType go nmap <F8> <Plug>(go-metalinter)
augroup END
"---------------------------------=== Yaml ===----------------------------------
"
augroup yaml
autocmd!
au FileType yaml set sw=4
au FileType yaml set ts=4
au FileType yaml set sts=4
augroup END
"--------------------------------=== Python ===---------------------------------
"
augroup python
autocmd!
au FileType python set sw=4
au FileType python set ts=4
au FileType python set sts=4
augroup END
"---------------------------------=== Other ===---------------------------------
"
au FileType crontab,fstab,make set noexpandtab tabstop=8 shiftwidth=8
"-------------------------------=== Functions ===-------------------------------
" FancySmancyComment(text, fill_char, width)
function! FancySmancyComment(...)
let text = "=== " . get(a:000, 0, '') . " ==="
let fill = get(a:000, 1, '-')[0]
let width = get(a:000, 2, 80) - len(printf(&commentstring, '')) - len(text)
let left = width / 2
let right = width - left
put=printf(&commentstring, repeat(fill, left) . text . repeat(fill, right))
endfunction
command! -nargs=* FComment call FancySmancyComment( '<args>' )