-
Notifications
You must be signed in to change notification settings - Fork 6
/
vimrc
429 lines (327 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
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
if !has('packages')
runtime pack/vanilla/opt/pathogen/autoload/pathogen.vim
call pathogen#infect('pack/vanilla/start/{}')
if has('lua')
call pathogen#infect('pack/lua-support/start/{}')
endif
endif
"{{{Auto Commands
set formatprg=fmt\ -w80
augroup vimrc
autocmd!
au BufEnter * syntax sync fromstart
au VimEnter * set vb t_vb=
au FileType perl let b:dispatch = 'perl %'
au FileType perl setlocal formatprg=perltidy
au FileType mail setlocal formatprg=mailfmt
au FileType markdown setlocal formatprg=markdownfmt
au FileType sql setlocal commentstring=--\ %s
au FileType sml setlocal commentstring=(*\ %s\ *)
au FileType racket setlocal commentstring=;\ %s
au FileType tf setlocal commentstring=#\ %s
au FileType matlab setlocal commentstring=%\ %s
au FileType muttrc setlocal keywordprg=neoman
au BufReadPost *.rkt,*.rktl setlocal filetype=racket
au FileType racket setlocal lisp
au FileType racket setlocal autoindent
au FileType markdown setlocal nowrap | let b:lost_regex = '\v^#'
au FileType help setlocal nolist
au BufWritePre /tmp/* setlocal noundofile
au BufWritePre /run/shm/* setlocal noundofile
au FileType lua setlocal path+=/usr/share/awesome/lib
au FileType lua setlocal includeexpr=substitute(v:fname,'\\.','/','g')
augroup END
"}}}
"{{{Misc Settings
set conceallevel=2
" PERSISTENT UNDO
set undofile
set history=10000
if has('nvim')
set viminfo='100,\"100,n~/.nviminfo
else
set viminfo='100,\"100,n~/.viminfo
endif
set matchpairs+=<:>
if has('termguicolors')
set termguicolors
endif
" Necessary for lots of cool vim things
set nocompatible
" This shows what you are typing as a command. I love this!
set showcmd
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
filetype plugin indent on
syntax enable
" Who doesn't like autoindent?
set autoindent
" Spaces are better than a tab character
set expandtab
" Cool tab completion stuff
set wildmenu
set wildmode=longest,list
" Case insensitive wild menu
set wildignorecase
" Line Numbers PWN!
set number
" Ignoring case is a fun trick
set ignorecase
" And so is Artificial Intelligence!
set smartcase
" This is totally awesome - remap jk to escape in insert mode. You'll never type jk anyway, so it's great!
inoremap jk <Esc>
" Incremental searching is sexy
set incsearch
" Highlight things that we find with the search
set hlsearch
" allow selection of nothing
set virtualedit=block
" I never use octal (or hex?) so only treat numbers like decimals
set nrformats=
" }}}
"{{{Look and Feel
if has('termguicolors') && $COLORTERM == 'truecolor'
set termguicolors
if len($TMUX) > 0
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
endif
"Status line gnarliness
set laststatus=2
" }}}
"{{{ Mappings
if has('nvim')
tnoremap <Esc> <C-\><C-n>
tnoremap <C-v><Esc> <Esc>
endif
" toppost
nnoremap <silent> <Leader>tp :%!top-post<CR>ggI
vnoremap <silent> <Leader>tp :!top-post<CR>
" Edit vimrc \ev
nnoremap <silent> <Leader>ev :split $MYVIMRC<CR>
" Up and down are more logical with g..
nnoremap <silent> k gk
nnoremap <silent> j gj
" 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.
noremap N Nzz
noremap n nzz
" http://learnvimscriptthehardway.stevelosh.com/chapters/04.html
nnoremap <c-u> viwU
inoremap <c-u> <esc>viwUi
" Testing
set completeopt=longest,menuone,preview
set complete-=i
" Swap ; and : Convenient.
nnoremap ; :
vnoremap ; :
" Make %% represent the dir of the current buffer
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
nmap gV `[v`]
nnoremap <leader>ts :r !date "+\%FT\%T\%:z"<CR>
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
nnoremap <silent> <leader>DD :exe ":profile start profile.log"<cr>:exe ":profile func *"<cr>:exe ":profile file *"<cr>
nnoremap <silent> <leader>DP :exe ":profile pause"<cr>
nnoremap <silent> <leader>DC :exe ":profile continue"<cr>
nnoremap <silent> <leader>DQ :exe ":profile pause"<cr>:noautocmd wqa!<cr>
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
inoremap <silent> <PageDown> <nop>
inoremap <silent> <PageUp> <nop>
nnoremap <silent> gh : <C-u>call GOVIMHover()<CR>
nnoremap <silent> gH :GOVIMQuickfixDiagnostics<CR>
"}}}
" {{{ airline settings
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
if has('win32')
set listchars=tab:-\ ,nbsp:~
let g:airline_left_sep = '>'
let g:airline_right_sep = '<'
let g:airline_symbols.linenr = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.whitespace = '='
else
set listchars=tab:▸\ ,nbsp:~
let g:airline_left_sep = '▶'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = ''
let g:airline_symbols.branch = '⎇ '
let g:airline_symbols.whitespace = 'Ξ'
endif
" }}}
set list
" {{{ ale settings
let g:ale_linters_ignore = {'go': ['golint', 'gopls']}
" }}}
" {{{ vim-lsp
let g:lsp_document_code_action_signs_enabled = 0
let g:lsp_semantic_enabled = 0
let g:lsp_document_highlight_enabled = 0
au User lsp_setup call lsp#register_server({
\ 'name': 'metals',
\ 'cmd': ['metals'],
\ 'initialization_options': { 'rootPatterns': 'build.gradle', 'isHttpEnabled': 'true' },
\ 'allowlist': [ 'scala', 'sbt' ],
\ })
au User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
\ 'cmd': ['gopls'],
\ 'allowlist': [ 'go' ],
\ })
nnoremap <silent> gd :LspDefinition<CR>
set omnifunc=lsp#complete
" }}}
" {{{ ctrlp settings
function! DirCtrlP()
let g:ctrlp_working_path_mode = 0
CtrlP
endfunction
function! FileRelCtrlP()
let g:ctrlp_working_path_mode = 'c'
CtrlP
endfunction
let g:ctrlp_abbrev = {
\ "abbrevs": [
\ {
\ "pattern": "^lib:",
\ "expanded": "^lib/"
\ },
\ {
\ "pattern": "^t:",
\ "expanded": "^t/"
\ }
\ ]
\ }
" put ctrlp matcher on top, ordering top to bottom
let g:ctrlp_match_window = 'top,order:ttb,min:5,max:30'
" search with regexen by default
let g:ctrlp_regexp = 1
if filereadable($HOME . "/.fzf/README.md")
set rtp+=~/.fzf
command! FDir :call fzf#run({'dir': expand("%:h"), 'sink': 'e'})
command! FBuf :call fzf#run({'source': map(range(1, bufnr('$')), 'bufname(v:val)'), 'sink': 'e', 'down': '30%'})
endif
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_use_caching = 0
" }}}
let g:jshintprg="hint"
" hopefully can get these into unimpaired
" (https://github.com/tpope/vim-unimpaired/issues/63)
nnoremap [oy :setlocal syntax=on<cr>
nnoremap ]oy :setlocal syntax=off<cr>
nnoremap coy :if &syntax != "off" \| setlocal syntax=off \| else \| setlocal syntax=on \| endif<CR>
nnoremap [oM :Matchmaker<cr>
nnoremap ]oM :Matchmaker!<cr>
nnoremap coM :MatchmakerToggle<CR>
nnoremap [oW :EnableWhitespace<cr>
nnoremap ]oW :DisableWhitespace<cr>
nnoremap coW :ToggleWhitespace<cr>
nnoremap [oS :ALEEnable<cr>
nnoremap ]oS :ALEDisable<cr>
nnoremap coS :ALEToggle<cr>
nnoremap [oQ :let g:qs_enable = 1<cr>
nnoremap ]oQ :let g:qs_enable = 0<cr>
nnoremap coQ :QuickScopeToggle<cr>
nnoremap [oN :NeoCompleteEnable<cr>
nnoremap ]oN :NeoCompleteDisable<cr>
nnoremap coN :NeoCompleteToggle<CR>
nnoremap [og :GitGutterEnable<cr>
nnoremap ]og :GitGutterDisable<cr>
nnoremap cog :GitGutterToggle<CR>
function! CycleColors()
let mycolors = []
if has('termguicolors') && &termguicolors
let mycolors += ['solarized8_dark_high', 'solarized8_light_high']
endif
let mycolors += [ 'elflord', 'desert' ]
let colordict = {}
let index = 0
while index < len(mycolors) - 1
let item = mycolors[index]
let colordict[item] = mycolors[index+1]
let index += 1
endwhile
let colordict[mycolors[-1]] = mycolors[0]
if !has_key(g:, 'nextColor') || colordict[g:nextColor] == ""
let g:nextColor = mycolors[-1]
endif
let attempts = 0
while 1
try
let attempts += 1
let g:nextColor = colordict[g:nextColor]
execute ':colorscheme ' . g:nextColor
return
catch
if attempts == len(mycolors)
return
endif
endtry
endwhile
endfunction
command! CycleColors :call CycleColors()
call CycleColors()
set directory=$HOME/.vvar/swap//
set undodir=$HOME/.vvar/undo//
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
vmap <silent> <expr> p <sid>Repl()
let perl_no_subprototype_error = 1
function! ZRPod()
let path = substitute(substitute(@%, '\(app/lib/\|\.pm\)', '', 'g'), '/', '::', 'g')
let url = 'https://pod.ziprecruiter.com/?' . path
let command = "firefox '" . url . "'"
execute ":!" command
endfunction
command! Pod call ZRPod()
let g:qs_highlight_on_keys = [ 'f', 'F', 't', 'T' ]
command! Gdiffs cexpr system('git diff \| diff-hunk-list')
command! GLdiffs lexpr system('git diff \| diff-hunk-list')
command! CountMatches %s///gn
let g:fugitive_gitlab_domains = ['https://git.ziprecruiter.com']
command! -nargs=1 Gg :Ggrep <args>
command! ESession execute ":tabnew | edit " . v:this_session . "x.vim | split" . v:this_session " | split " . v:this_session . "a.vim"
function! Multiple_cursors_before()
if exists(':NeoCompleteLock')==2
exe 'NeoCompleteLock'
endif
endfunction
function! Multiple_cursors_after()
if exists(':NeoCompleteUnlock')==2
exe 'NeoCompleteUnlock'
endif
endfunction
let g:go_fmt_command = "goimports"
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
augroup configure_projects
autocmd!
autocmd User ProjectionistActivate call s:configure_format()
augroup END
function! s:configure_format() abort
let l:i = projectionist#query('localimports')
if len(l:i) > 0
let g:go_fmt_options = {'goimports': '-local ' . l:i[0][1]}
endif
endfunction
nmap co yo
command! -nargs=* GozrTests execute 'cexpr system("bin/gozr tests ' <args> '")'
command! -nargs=* GoTest execute 'cexpr system("go test ' <args> '")'
command! -nargs=* GozrAnalyze execute 'cexpr system("/usr/bin/nice -20 bin/gozr analyze ' <args> '")'
command! Kit execute 'pa vinegar | pa eunuch | pa obsession | pa unimpaired | pa commentary'
command! PackAdd execute 'pa airline | pa ale | pa better-whitespace | pa colors-solarized | pa commentary | pa csv | pa ctrlp | pa dispatch | pa editorconfig | pa eunuch | pa exchange | pa FastFold | pa fugitive | pa fugitive-gitlab | pa gitgutter | pa govim | pa goyo | pa grepper | pa IndentAnything | pa l9 | pa lastplace | pa lost | pa matchit | pa matchmaker | pa multiple-cursors | pa obsession | pa perl | pa projectionist | pa python | pa quick-scope | pa regedit | pa repeat | pa solarized8 | pa surround | pa tabular | pa terminus | pa textobj-user | pa textobj-between | pa textobj-entire | pa textobj-underscore | pa unimpaired | pa vinegar | pa visual-star-search | pa wipeout'
command! -nargs=1 Hl :match ErrorMsg <args>
" vim: foldmethod=marker