-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
477 lines (382 loc) · 13.1 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
" auto install vim-plug, plugin manager
" detects if running neovim
" Neovim uses ~/.config/nvim/init.vim, not ~/.vimrc
if has('nvim')
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
else
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endif
if empty(glob('~/go'))
autocmd VimEnter * GoInstallBinaries --sync
endif
call plug#begin('~/.vim/plugged')
" Theme
Plug 'lifepillar/vim-solarized8'
" Plug 'arcticicestudio/nord-vim'
" Status bar
Plug 'itchyny/lightline.vim'
"Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
" Utilities
Plug 'scrooloose/nerdtree'
" Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'preservim/nerdcommenter'
Plug 'ludovicchabant/vim-gutentags'
Plug 'majutsushi/tagbar'
" Plug 'liuchengxu/vista.vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'ervandew/supertab'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'mileszs/ack.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-surround'
Plug 'sheerun/vim-polyglot'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'gcmt/taboo.vim'
Plug 'Chiel92/vim-autoformat'
" Check syntax
Plug 'dense-analysis/ale'
Plug 'maximbaz/lightline-ale'
" GIT
Plug 'itchyny/vim-gitbranch'
Plug 'airblade/vim-gitgutter'
" ---------
" Terraform
" ---------
Plug 'hashivim/vim-terraform'
" -------
" Ansible
" -------
Plug 'pearofducks/ansible-vim'
" --
" Go
" --
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries', 'for': 'go' }
" ------
" Vue.js
" ------
Plug 'posva/vim-vue'
" ----
" rego
" ----
Plug 'tsandall/vim-rego'
" ----
" TMux
" ----
Plug 'christoomey/vim-tmux-navigator'
" ---------------
" Code completion
" ---------------
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'zchee/deoplete-go', { 'do': 'make' }
" Plug 'deoplete-plugins/deoplete-go', { 'do': 'make' }
" do not forget to install jedi
Plug 'deoplete-plugins/deoplete-jedi'
call plug#end()
let g:deoplete#enable_at_startup = 1
let g:go_def_mode = "gopls"
let g:go_info_mode='guru'
let g:go_auto_type_info='gopls'
" go get -u github.com/mdempsky/gocode
" let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
" Color theme {{{
let g:solarized_termcolors=256
colorscheme solarized8_high
" colorscheme nord
set background=dark " dark background
" let g:airline_theme='solarized'
" let g:airline_solarized_bg='dark'
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch'],
\ [ 'readonly', 'absolutepath', 'modified' ] ],
\ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ],
\ [ 'lineinfo', 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ] ],
\ },
\ 'component_function': {
\ 'gitbranch': 'gitbranch#name',
\ },
\ }
let g:lightline.component_expand = {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ }
let g:lightline.component_type = {
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left',
\ }
let g:lightline.separator = {
\ 'left': '', 'right': ''
\}
let g:lightline.subseparator = {
\ 'left': '', 'right': ''
\}
" Hey, I do not get the right colors when running Vim inside tmux
" or in my favourite true-color enabled terminal!
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" }}}
" Basics and Features {{{
" When on, uses highlight-guifg and highlight-guibg attributes in
" the terminal (thus using 24-bit color).
if (has("termguicolors"))
set termguicolors
endif
if !has('gui_running')
set t_Co=256 " max number of colors that can be displayed by the terminal
endif
filetype plugin indent on " add filetype, plugin, and indent support
syntax on " turn on syntax highlighting
set hlsearch " highlight searches
set backspace=indent,eol,start
set smartcase " case-sensitive if search contains an uppercase character
set number relativenumber " turn relative line numbers on
set colorcolumn=80,120 " add vertical lines on columns
set cursorline " highligh current line
set laststatus=2 " to display the status line always
set shiftwidth=2 " indent is 2 spaces (should be same as softtabstop for consistency)
set softtabstop=2 " number of spaces inserted when inputting tab
set expandtab " don't use actual tab character (use spaces instead)
set hidden " allow switching buffers without writing to disk
set noswapfile " no swap files
" set path=.,** " search relative to current file + directory
set confirm " instead raise a dialogue asking if you wish to save changed files.
set wildmenu " better command-line completion
set wildmode=list:longest,full " set command-line completion mode
set autoindent " auto indentation
" Completion options (select longest + show menu even if a single match is
" found)
set completeopt=longest,menuone
" Enable folding
set foldmethod=indent
set foldlevel=99
set showcmd " show partial commands in the last line of the screen
set encoding=utf-8 " set default enconding
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
endif
" Python tabs and spaces
au BufNewFile,BufRead *.py set expandtab
au BufNewFile,BufRead *.py set shiftwidth=4
au BufNewFile,BufRead *.py set softtabstop=4
au BufNewFile,BufRead *.py set tabstop=4
au BufNewFile,BufRead *.py set fileformat=unix
" Path to python interpreter for neovim
let g:python3_host_prog = '/usr/bin/python3'
let g:python_host_prog = '/usr/bin/python2'
" Skip the check of neovim module
let g:python3_host_skip_check = 0"
" Markdown
au BufNewFile,BufRead *.md set filetype=markdown
au BufNewFile,BufRead *.md set spell
au BufNewFile,BufRead *.md set textwidth=80
set shell=/usr/bin/zsh " prefer zsh for shell-related tasks
let s:default_path = escape(&path, '\ ') " store default value of 'path'
" Always add the current file's directory to the path and tags list if not
" already there. Add it to the beginning to speed up searches.
autocmd BufRead *
\ let s:tempPath=escape(escape(expand("%:p:h"), ' '), '\ ') |
\ exec "set path-=".s:tempPath |
\ exec "set path-=".s:default_path |
\ exec "set path^=".s:tempPath |
\ exec "set path^=".s:default_path
" }}}
" Plugin Configurations {{{
" ----- Taboo -----
let g:taboo_tab_format = " %I %r %U %m "
" ----- UltiSnips -----
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" ----- Gutentags -----
let g:gutentags_cache_dir = expand('~/.vim/gutentags/')
let g:gutentags_generate_on_new = 1
let g:gutentags_generate_on_missing = 1
let g:gutentags_generate_on_write = 1
let g:gutentags_generate_on_empty_buffer = 0
" ----- ALE -----
let g:ale_linters = {
\ 'python': ['flake8', 'pylint'],
\ 'ruby': ['standardrb', 'rubocop'],
\ 'javascript': ['eslint'],
\ 'yaml.ansible': ['ansible-lint'],
\ 'yaml' : ['yamllint'],
\}
let g:ale_fixers = {
\ 'python': ['yapf'],
\}
nmap <F10> :ALEFix<CR>
nmap <F9> :ALENext<CR>
nmap <F8> :ALEPrevious<CR>
let g:ale_fix_on_save = 1
" ----- Golang -----
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_methods = 1
let g:go_highlight_functions = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_types = 1
let g:go_hightlight_fields = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_variable_declarations = 1
let g:go_highlight_variable_assignments = 1
let g:go_fmt_command = "goimports"
" ----- rego autoformat -----
let g:formatdef_rego = '"opa fmt"'
let g:formatters_rego = ['rego']
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
au BufWritePre *.rego Autoformat
" ----- NerdCommenter -----
" :help nerdcommenter
"
" [count]<leader>c<space> |NERDCommenterToggle|
" Toggles the comment state of the selected line(s). If the topmost selected
" line is commented, all selected lines are uncommented and vice versa.
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" ----- NERDTree -----
" :help NERDTreeMappings
" t: Open the selected file in a new tab
" i: Open the selected file in a horizontal split window
" s: Open the selected file in a vertical split window
" I: Toggle hidden files
" m: Show the NERD Tree menu
" R: Refresh the tree, useful if files change outside of Vim
" ?: Toggle NERD Tree's quick help
map <F6> : NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
" ----- TagBar -----
" :help tagbar
map <F7> : TagbarToggle<CR>
" ----- Vista.vim -----
" map <F7> : Vista!!<CR>
" ----- Indent Guides -----
" :help indent-guides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 1
" ----- Super TAB -----
" :help supertab
" ----- FZF: Fuzzy Finder -----
" :Files
" Fzf Configuration
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" ----- Ack -----
" use silver searcher if available
" https://github.com/ggreer/the_silver_searcher
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Usage
" :Ack [options] {pattern} [{directories}]
" Search recursively in {directories} (which defaults to the current directory) for the {pattern}.
" Files containing the search term will be listed in the quickfix window, along with the line number of the occurrence, once for each occurrence. <Enter> on a line in this window will open the file and place the cursor on the matching line.
" Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use :Ack, :AckAdd, :LAck, and :LAckAdd respectively. (See :help Ack after installing, or doc/ack.txt in the repo, for more information.)
" For more ack help see ack documentation.
"
" Keyboard Shortcuts
" The quickfix results window is augmented with these convenience mappings:
" ? a quick summary of these keys, repeat to close
" o to open (same as Enter)
" O to open and close the quickfix window
" go to preview file, open but maintain focus on ack.vim results
" t to open in new tab
" T to open in new tab without moving to it
" h to open in horizontal split
" H to open in horizontal split, keeping focus on the results
" v to open in vertical split
" gv to open in vertical split, keeping focus on the results
" q to close the quickfix window
" ----- vim-terraform -----
let g:terraform_align=1
let g:terraform_fold_sections=0
let g:terraform_fmt_on_save=1
" HCL
augroup filetypedetect
au! BufRead,BufNewFile *.hcl setf terraform
augroup END
" ----- vim-ansible -----
let g:ansible_unindent_after_newline = 1
let g:ansible_attribute_highlight = "ob"
" }}}
" Mapping {{{
" toggle paste mode
set pastetoggle=<F2>
" better completeopt
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Remove newbie crutches in Command Mode
" cnoremap <Down> <Nop>
" cnoremap <Left> <Nop>
" cnoremap <Right> <Nop>
" cnoremap <Up> <Nop>
" Remove newbie crutches in Insert Mode
" inoremap <Down> <Nop>
" inoremap <Left> <Nop>
" inoremap <Right> <Nop>
" inoremap <Up> <Nop>
" Remove newbie crutches in Normal Mode
" nnoremap <Down> <Nop>
" nnoremap <Left> <Nop>
" nnoremap <Right> <Nop>
" nnoremap <Up> <Nop>
" Remove newbie crutches in Visual Mode
" vnoremap <Down> <Nop>
" vnoremap <Left> <Nop>
" vnoremap <Right> <Nop>
" vnoremap <Up> <Nop>
" source $MYVIMRC reloads the saved $MYVIMRC
:nmap <Leader>s :source $MYVIMRC<CR>
" opens $MYVIMRC for editing, or use :tabedit $MYVIMRC
:nmap <Leader>v :e $MYVIMRC<CR>
" format json with jq
:nmap <Leader>j :%!jq .<CR>
" <Leader> is \ by default, so those commands can be invoked by doing \v and \s
"
" useful settings:
" Typing ":set xxx" sets the option "xxx". Some options are:
" 'ic' 'ignorecase' ignore upper/lower case when searching
" 'is' 'incsearch' show partial matches for a search phrase
" 'hls' 'hlsearch' highlight all matching phrases
" You can either use the long or the short option name.
"
" Prepend "no" to switch an option off: :set noic
" }}}