-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
401 lines (366 loc) · 10.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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
"" Global settings
set encoding=utf-8
syntax on
filetype on
filetype plugin on
filetype indent on
set autowrite
set directory=~/.vim/swap
set wildchar=<tab> wildmenu wildmode=full " buffer list with <tab>
set omnifunc=ale#completion#OmniFunc
set belloff=all
"" Vim-plug
" Install
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
" Plugins
call plug#begin('~/.vim/plugged')
"Plug 'bakpakin/fennel.vim', { 'for': 'fennel' }
"Plug 'chr4/nginx.vim'
"Plug 'ekalinin/Dockerfile.vim', { 'for': 'Docker' }
"Plug 'glench/vim-jinja2-syntax', { 'for': 'jinja' }
"Plug 'godlygeek/tabular'
"Plug 'lifepillar/vim-solarized8'
"Plug 'plasticboy/vim-markdown'
"Plug 'romainl/flattened'
"Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggleVCS' }
Plug '/usr/local/opt/fzf'
Plug 'Joorem/vim-haproxy', { 'for': 'haproxy' }
Plug 'Lokaltog/vim-monotone'
Plug 'airblade/vim-gitgutter'
Plug 'bling/vim-airline'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'drmingdrmer/vim-toggle-quickfix'
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries', 'for': 'go' }
Plug 'guns/vim-sexp', { 'for': 'fennel' }
Plug 'jpalardy/vim-slime'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'kien/rainbow_parentheses.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'mileszs/ack.vim', { 'on': 'Ack' }
Plug 'pedrohdz/vim-yaml-folds', { 'for': 'yaml' }
Plug 'plan9-for-vimspace/acme-colors'
Plug 'preservim/tagbar', { 'on': 'TagbarToggle' }
Plug 'qpkorr/vim-bufkill'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fireplace', { 'for': 'fennel' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-sexp-mappings-for-regular-people', { 'for': 'fennel' }
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-vinegar'
Plug 'vim-scripts/indentpython.vim', { 'for': 'python' }
Plug 'w0rp/ale'
Plug 'wfxr/minimap.vim', { 'on': 'MinimapToggle' }
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
Plug 'ycm-core/YouCompleteMe', { 'do': './install.py --go-completer' }
call plug#end()
"" Formatting
set autoindent
set breakindent " Every wrapped line will continue visually indented
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set tabstop=2 " tab spaces size
set softtabstop=2 " when hitting <BS>, pretend like a tab is removed, even if spaces
set shiftwidth=2 " number of spaces to use for autoindenting
"" Display
autocmd VimResized * wincmd = " Auto-equalize window splits
colorscheme monotone " Color scheme
" Use italic terminal fonts for comments
highlight Comment cterm=italic
set foldlevel=3 " Default fold level
set foldmethod=syntax " Default to syntax folding
set hidden " keep buffers hidden
set history=1000
set hlsearch " Highlight search results
set ignorecase " Case-insensitive search
set incsearch " Incremental search
set laststatus=2 " Always show status line
set linebreak " ragged margins
set matchpairs+=<:> " show matching <>
set number " Show line numbers
set ruler " Show current position
set scrolloff=5 " keep three lines between the cursor and the bottom of the screen
set showcmd
set showmode
set smartcase
set title " Set terminal window title to filename
" GUI options
if has('gui_running')
set guifont=Iosevka:h14
set guicursor+=a:blinkon0
set guioptions-=lr " Disable left and right GUI scrollbars
endif
"" Keybindings and aliases
" Tabs
nmap th :tabprev<cr>
nmap tl :tabnext<cr>
nmap tn :tabnew<cr>
nmap tc :tabclose<cr>
nmap te :tabedit
" Buffers
noremap K :bn<cr>
noremap J :bp<cr>
" file browser
nmap <leader>n :Lexplore<cr>
nmap <leader>nn :Lexplore %:p:h<cr>
" edit $MYVIMRC
nmap <leader>v :vsplit $MYVIMRC<cr>
" buffer list
nmap <leader>l :ls<cr>
" diff open windows
command DA :windo diffthis
command Da :diffoff!
" show tags window
nmap <leader>t :TagbarToggle<cr>
" toggle line numbers
nmap <leader>u :set nu!<cr>
" toggle invisible chars
nmap <leader>i :set list!<cr>
" toggle window scroll binding
nmap <leader>b :windo set scrollbind!<cr>
" close quickfix window
nmap <leader>x <Plug>window:quickfix:loop
" clear search highlight
map <leader>c :let @/ = ""<CR>
" Ack search for word
nmap <leader>k :Ack! "\b<cword>\b" <CR>
" CtrlP
nmap <Leader>; :CtrlPMRUFiles<CR>
nmap <Leader>: :CtrlPBuffer<CR>
" fzf
nmap <Leader>f :Files<CR>
nmap <Leader>g :Tags<CR>
nmap <Leader>a :Ag<CR>
" goyo
nmap <Leader>p :Goyo<CR>
" buffkill: delete buffer, keep window
nmap <leader>w :BD<CR>
" git status
nmap <leader>G :G<CR>
nmap <leader>g gq<CR>
nmap <leader>Gl :Commits<CR>
" git shortcuts
command Gblame :G blame
command Gc :G commit -v
command Gp :G push
" Github
nmap <leader>Ghr :!gh run view<CR>
nmap <leader>Gpr :!gh pr create<CR>
" YouCompleteMe
map <leader>d :YcmCompleter GoToDefinitionElseDeclaration<CR>
map <leader>o :YcmCompleter GetDoc<CR>
" vim-session
map <leader>s :SaveSession<CR>
" minimap-vim
map <leader>m :MinimapToggle<CR>
" terminal
map <leader>T :vertical terminal /bin/bash -l<CR>
"" Filetype settings
" Python
augroup python
au!
au! BufNewFile,BufRead *.py setlocal cc=80 tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0 expandtab
au BufNewFile,BufRead *.py setlocal foldmethod=indent foldlevel=3
au BufNewFile,BufRead *.py let b:slime_vimterminal_cmd="ipython"
augroup end
" bash
augroup bash
au!
au! BufNewFile,BufRead *.profile set ft=bash
au BufNewFile,BufRead *.sh setlocal cc=80
au BufNewFile,BufRead *.sh let b:slime_vimterminal_cmd = "/bin/bash -l"
augroup end
" lua
augroup lua
au!
au! BufNewFile,BufRead *.lua let b:slime_vimterminal_cmd = "/bin/bash -l"
augroup end
" SQL
augroup sql
au!
au! BufNewFile,BufRead *.sql let b:slime_vimterminal_cmd = "/usr/local/bin/psql"
augroup end
" Go
augroup go
au!
au! BufNewFile,BufRead *.go let b:slime_vimterminal_cmd = "/usr/local/bin/go"
au BufNewFile,BufRead *.go let foldcolumn = 3
augroup end
" Nginx configuration template
augroup nginx_template
au!
au! BufNewFile,BufRead *nginx.conf.template set ft=nginx
augroup end
" Nginx configuration template
augroup haproxy_template
au!
au! BufNewFile,BufRead *haproxy.cfg.template set ft=haproxy
augroup end
" Terraform
augroup terraform
au!
au! BufNewFile,BufRead *.tfvars set ft=tfvars
augroup end
" YAML Template
augroup yaml_template
au!
au! BufNewFile,BufRead *.yaml.tmpl set ft=yaml
au! BufNewFile,BufRead *.yml.tmpl set ft=yaml
augroup end
" Minimap
" augroup minimap
" au!
" au WinEnter * MinimapRefresh
" augroup end
" vimrc
augroup vimrc
au!
au! BufWritePost ~/.vimrc source ~/.vimrc
augroup end
"" Plugin settings
" airline settings
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#branch#format = 2
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#hunks#non_zero_only = 1
" tagbar settings
let g:tagbar_compact = 1
let g:tagbar_foldlevel = 1
let g:tagbar_position = 'leftabove vertical'
let g:tagbar_zoomwidth = 0
let tlist_sh_settings = 'sh;f:functions;v:variables;c:constants'
" I found adding shell variables to the tagbar too chatty
" let g:tagbar_type_sh = {
" \ 'kinds':[
" \ 'c:constants',
" \ 'f:functions',
" \ 'l:local',
" \ 'v:variables'
" \ ]
" \}
let g:tagbar_type_terraform = {
\ 'ctags_type':'Terraform',
\ 'kinds':[
\ 'd:data',
\ 'm:module',
\ 'o:output',
\ 'p:provider',
\ 'r:resource',
\ 'v:variable'
\ ]
\}
" fugitive settings
autocmd QuickFixCmdPost *grep* cwindow " Open quickfix window for grep search results
" ack.vim settings
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" ALE settings
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ 'bash': ['shfmt'],
\ 'lua': ['lua-format'],
\ 'sh': ['shfmt'],
\ 'terraform': ['terraform'],
\ 'tfvars': ['terraform'],
\ 'python': ['yapf', 'autoimport', 'black', 'reorder-python-imports'],
\}
let g:ale_lint_delay = 1000
let g:ale_lint_on_text_changed = 'always'
let g:ale_linters = {
\ 'bash': ['shellcheck'],
\ 'dockerfile': ['hadolint'],
\ 'javascript': ['eslint'],
\ 'lua': ['luac', 'luacheck --std ngx_lua'],
\ 'python': ['pylsp', 'pylint'],
\ 'sh': ['shellcheck'],
\ 'terraform': ['terraform', 'tflint', 'terraform_ls'],
\ 'tfvars': ['terraform', 'tflint','terraform_ls' ],
\}
let g:ale_linters_ignore = {
\ 'vim' : ['vim-language-server'],
\}
let g:ale_sign_column_always = 1
" let g:ale_root = {
" \ 'terraform': ale_linters#terraform#terraform_ls#GetProjectRoot(expand('%:p:h')),
" \}
"" ALE Python
let g:ale_python_auto_virtualenv = 1
let g:ale_python_flake8_options = '--ignore=E501,W503'
let g:ale_python_pylint_options = '--disable=line-too-long --disable=missing-class-docstring --disable=missing-function-docstring --disable=missing-module-docstring --disable=too-few-public-methods --disable=broad-except --disable=too-many-arguments --disable=too-many-positional-arguments'
let g:ale_python_pylsp_executable = 'pyls'
"" ALE yamllint
let g:ale_yaml_yamllint_options = '-d relaxed'
"" ALE luacheck
let g:ale_lua_luacheck_options = '--std ngx_lua'
"" ALE shfmt
let g:ale_sh_shfmt_options = '-i 4 %'
"" ALE tflint
"" TODO ALE tflint definition is out of date, does not
"" match tflint >=0.49.0 JSON fields or CLI options (--chdir).
"" See file:
"" https://github.com/dense-analysis/ale/blob/master/ale_linters/terraform/tflint.vim
" let g:ale_terraform_tflint_options = '-f json --module --chdir '.expand('%:p:h')
" vim-go settings
let g:go_doc_keywordprg_enabled = 0
let g:go_debug_mappings = {
\ '(go-debug-continue)': {'key': '<F5>'},
\ '(go-debug-print)': {'key': '<F6>'},
\ '(go-debug-breakpoint)': {'key': '<F9>'},
\ '(go-debug-next)': {'key': '<F10>'},
\ '(go-debug-step)': {'key': '<F11>'},
\ '(go-debug-halt)': {'key': '<F8>'},
\ }
" vim-gutentag settings
let gutentags_cache_dir = '~/.vim/cache/vim-gutentags'
" YouCompleteMe settings
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_auto_hover=''
let g:ycm_enable_inlay_hints=1
let g:ycm_language_server = [
\ { 'name': 'lua',
\ 'filetypes': [ 'lua' ],
\ 'cmdline': [ '/usr/local/Cellar/lua-language-server/3.2.2/bin/lua-language-server',
\ '/usr/local/Cellar/lua-language-server/3.2.2/libexec/main.lua' ]
\ },
\ ]
" vim-slime
let g:slime_target = 'tmux'
let g:slime_default_config = { 'socket_name': 'default', 'target_pane': '{last}' }
let g:slime_dont_ask_default = 1
let g:slime_python_ipython = 1
let g:slime_vimterminal_config = { 'vertical': 1 }
" vim-session
let g:session_autoload = 'no'
let g:session_autosave = 'no'
" CtrlP
let g:ctrlp_show_hidden = 1
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules',
\ }
" mimimap-vim
let g:minimap_highlight_range = 1
" Netrw
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = -31
let g:netrw_wiw = 31
function! NetrwMapping()
nmap <buffer> . gh
nmap <buffer> P <C-w>z
endfunction
augroup netrw_mapping
autocmd!
autocmd filetype netrw call NetrwMapping()
augroup END