dot_vimrc 20.1 KB
Newer Older
Jeric de Leon's avatar
Jeric de Leon committed
1
2
3
4
5
6
7
8
9
10
11
" Install vim-plug if not found
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
endif

" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
  \| PlugInstall --sync | source $MYVIMRC
  \| endif

Jeric de Leon's avatar
update    
Jeric de Leon committed
12
13
14
15
16
17
18
19
function! PlugHookPreBase()
  " line numbers
  set number

  " faster navigation
  " normal mode:
  nnoremap <c-j> 5j
  nnoremap <c-k> 5k
Jeric de Leon's avatar
update    
Jeric de Leon committed
20
21
  nnoremap <c-h> ^
  nnoremap <c-l> $
Jeric de Leon's avatar
update    
Jeric de Leon committed
22
23
24
  " visual mode:
  xnoremap <c-j> 5j
  xnoremap <c-k> 5k
Jeric de Leon's avatar
update    
Jeric de Leon committed
25
26
27
28
29
  xnoremap <c-h> ^
  xnoremap <c-l> $

  " turn off ex mode
  nnoremap Q <nop>
Jeric de Leon's avatar
update    
Jeric de Leon committed
30
31
32
33
34

  " turn off replace mode
  nnoremap r <nop>
  nnoremap R <nop>

Jeric de Leon's avatar
update    
Jeric de Leon committed
35
  " use <esc>
Jeric de Leon's avatar
update    
Jeric de Leon committed
36
  inoremap <c-c> <Esc>
Jeric de Leon's avatar
update    
Jeric de Leon committed
37
38
39
40
41

  " use rg for grep
  set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
  set grepformat=%f:%l:%c:%m,%f:%l:%m
  map <Leader>S :silent grep<Space>
Jeric de Leon's avatar
update    
Jeric de Leon committed
42
43
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
44
45
function! PlugHookPreArecarnCloseBuffersVim()
  map <Leader>ba :Bdelete all<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
46
47
48
  map <Leader>bh :Bdelete hidden<CR>
  " <Leader>bl is used in tpope/vim-fugitive
  map <Leader>bm :Bdelete menu<CR>
Jeric de Leon's avatar
Jeric de Leon committed
49
  map <Leader>bn :Bdelete nameless<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
50
  map <Leader>bo :Bdelete other<CR>
Jeric de Leon's avatar
Jeric de Leon committed
51
  map <Leader>bs :Bdelete select<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
52
  map <Leader>bt :Bdelete this<CR>
Jeric de Leon's avatar
Jeric de Leon committed
53
54
55
56
57
58
59
60
61
62
endfunction

function! PlugHookPreBenknobleVimAutoOrigami()
  augroup autofoldcolumn
    au!
    " Or whatever autocmd-events you want
    au CursorHold,BufWinEnter,WinEnter * AutoOrigamiFoldColumn
  augroup END
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
63
function! PlugHookPreBroothFarVim()
Jeric de Leon's avatar
update    
Jeric de Leon committed
64
65
66
  map <Leader>/ :Farf<CR>
  map <Leader>? :Farr<CR>

Jeric de Leon's avatar
Jeric de Leon committed
67
68
69
70
71
72
73
  set lazyredraw            " improve scrolling performance when navigating through large results
  set ignorecase smartcase  " ignore case only when the pattern contains no capital letters

  let g:far#enable_undo = 1
  let g:far#glob_mode = 'native'
  let g:far#open_in_parent_window = 1
  let g:far#preview_window_height = 20
Jeric de Leon's avatar
update    
Jeric de Leon committed
74
  let g:far#source = 'rgnvim'
Jeric de Leon's avatar
update    
Jeric de Leon committed
75
76
77
78
  let g:far#mapping = {
      \ "preview_scroll_up" : "",
      \ "preview_scroll_down" : "",
      \ }
Jeric de Leon's avatar
Jeric de Leon committed
79
80
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
81
82
function! PlugHookPreDenseAnalysisAle()
  let g:ale_fix_on_save = 1
Jeric de Leon's avatar
update    
Jeric de Leon committed
83
84
  let g:ale_linters = {
        \   'go': ['gopls'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
85
        \   'rust': ['rls'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
86
        \}
Jeric de Leon's avatar
Jeric de Leon committed
87
88
  let g:ale_fixers = {
        \   '*': ['remove_trailing_lines', 'trim_whitespace'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
89
        \   'css': ['eslint'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
90
        \   'go': ['gofmt'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
91
        \   'html': ['eslint'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
92
        \   'javascript': ['eslint'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
93
        \   'json': ['eslint'],
Jeric de Leon's avatar
Jeric de Leon committed
94
        \   'ruby': ['rubocop'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
95
        \   'rust': ['rustfmt'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
96
        \   'typescript': ['eslint'],
Jeric de Leon's avatar
update    
Jeric de Leon committed
97
        \   'vue': ['eslint'],
Jeric de Leon's avatar
Jeric de Leon committed
98
        \}
Jeric de Leon's avatar
update    
Jeric de Leon committed
99
  let g:ale_disable_lsp = 1
Jeric de Leon's avatar
Jeric de Leon committed
100
101
102
103

  " vim-airline integration
  let g:airline#extensions#ale#enabled = 1

Jeric de Leon's avatar
update    
Jeric de Leon committed
104
105
106
107
108
109
110
111
112
113
114
  " vim only

  " map <Leader>rd :ALEGoToDefinition<CR>
  " map <Leader>rr :ALEFindReferences<CR>
  " map <Leader>rt :ALEDetail<CR>
  " map <Leader>re :ALEHover<CR>
  " map <Leader>rs :ALESymbolSearch<Space>
  " map <Leader>ra :ALECodeAction<CR>
  " map <Leader>rn :ALENext<CR>
  " map <Leader>rp :ALEPrevious<CR>
  " map <Leader>ri :ALEInfoToClipboard<CR>
Jeric de Leon's avatar
Jeric de Leon committed
115
116

  " configure hover
Jeric de Leon's avatar
update    
Jeric de Leon committed
117
  " let g:ale_set_balloons = 1
Jeric de Leon's avatar
Jeric de Leon committed
118
  " let g:ale_hover_to_preview = 1
Jeric de Leon's avatar
update    
Jeric de Leon committed
119

Jeric de Leon's avatar
update    
Jeric de Leon committed
120
121
122
123
124
125
126
127
128
  " completion
  " let g:ale_completion_enabled = 1
  " set omnifunc=ale#completion#OmniFunc

  " auto-import typescript modules
  " let g:ale_completion_autoimport = 1

  " turn off aggressive autocompletion
  " set completeopt=menu,menuone,preview,noselect,noinsert
Jeric de Leon's avatar
Jeric de Leon committed
129
130
131
endfunction

function! PlugHookPreGruvboxCommunityGruvbox()
Jeric de Leon's avatar
Jeric de Leon committed
132
  let g:gruvbox_italic=1
Jeric de Leon's avatar
update    
Jeric de Leon committed
133
134
  let g:gruvbox_contrast_dark='soft'
  let g:gruvbox_contrast_light='soft'
Jeric de Leon's avatar
Jeric de Leon committed
135
136
137
138

  " set true colors in vim inside tmux
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
Jeric de Leon's avatar
Jeric de Leon committed
139
140
  set termguicolors

Jeric de Leon's avatar
Jeric de Leon committed
141
  set background=light
Jeric de Leon's avatar
update    
Jeric de Leon committed
142
143
144
145
146
147
148
149
150
151
152
153
154

  " handling setting and unsetting BAT_THEME for fzf.vim
  augroup update_bat_theme
    autocmd!
    autocmd colorscheme * call ToggleBatEnvVar()
  augroup end
  function ToggleBatEnvVar()
    if (&background == "light")
        let $BAT_THEME='gruvbox-light'
    else
        let $BAT_THEME='gruvbox-dark'
    endif
  endfunction
Jeric de Leon's avatar
Jeric de Leon committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
endfunction

function! PlugHookPreHaya14busaIncSearchVim()
  map /  <Plug>(incsearch-forward)
  map ?  <Plug>(incsearch-backward)
  map g/ <Plug>(incsearch-stay)

  set hlsearch
  let g:incsearch#auto_nohlsearch = 1
  map n  <Plug>(incsearch-nohl-n)
  map N  <Plug>(incsearch-nohl-N)
  map *  <Plug>(incsearch-nohl-*)
  map #  <Plug>(incsearch-nohl-#)
  map g* <Plug>(incsearch-nohl-g*)
  map g# <Plug>(incsearch-nohl-g#)
endfunction

function! PlugHookPreJunegunnFzfVim()
  map <Space> <Leader>

Jeric de Leon's avatar
update    
Jeric de Leon committed
175
176
177
178
179
  map <Leader>eq :q<CR>
  map <Leader>eQ :q!<CR>
  map <Leader>ew :w<CR>
  map <Leader>eW :w!<CR>
  " <Leader>ee is used in lambdalisue/fern.vim
Jeric de Leon's avatar
update    
Jeric de Leon committed
180
181
182
183
184
185
186
187
188
189
  " <Leader>r is used in dense-analysis/ale
  map <Leader>t :BTags<Space>
  map <Leader>T :Tags<Space>

  map <Leader>o :BCommits<CR>
  map <Leader>O :Commits<CR>

  " <Leader>a is used in valloric/listtoggle
  map <Leader>s :Rg<Space>
  " <Leader>d is used in valloric/listtoggle
Jeric de Leon's avatar
Jeric de Leon committed
190
191
  map <Leader>f :GFiles<CR>
  map <Leader>F :Files<CR>
Jeric de Leon's avatar
Jeric de Leon committed
192
  " <Leader>g is used in tpope/vim-fugitive
Jeric de Leon's avatar
update    
Jeric de Leon committed
193
  " <Leader>G is used in rbong/vim-flog
Jeric de Leon's avatar
update    
Jeric de Leon committed
194

Jeric de Leon's avatar
Jeric de Leon committed
195
196
197
198
  map <Leader>hh :Helptags<CR>
  map <Leader>hi :History<CR>
  map <Leader>h: :History:<CR>
  map <Leader>h/ :History/<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
199
200
  map <Leader>l :BLines<CR>
  map <Leader>L :Lines<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
201
202
203
204
205
206
207
208
209
  map <Leader>: :Commands<CR>

  " <Leader>z is used in junegunn/goyo.vim
  " <Leader>c is used in dense-analysis/ale
  " <Leader>v is used in vimwiki/vimwiki
  " <Leader>b is used in asheq/close-buffers.vim
  map <Leader>B :Buffers<CR>

  " <Leader>n is used in ledger/vim-ledger
Jeric de Leon's avatar
Jeric de Leon committed
210
211
  map <Leader>m :Maps<CR>
  map <Leader>M :Marks<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
212
213
  " <Leader>/ is used in brooth/far.vim
  " <Leader>? is used in brooth/far.vim
Jeric de Leon's avatar
Jeric de Leon committed
214

Jeric de Leon's avatar
update    
Jeric de Leon committed
215
  let g:fzf_layout = { 'window': { 'width': 1, 'height': 1 } }
Jeric de Leon's avatar
update    
Jeric de Leon committed
216
217
  let g:fzf_preview_window = ['down,60%']

Jeric de Leon's avatar
Jeric de Leon committed
218
219
220
221
222
223
224
225
226
227
  " [Buffers] Jump to the existing window if possible
  let g:fzf_buffers_jump = 1

  " [[B]Commits] Customize the options used by 'git log':
  let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'

  " [Tags] Command to generate tags file
  let g:fzf_tags_command = 'ctags -R'

  " [Commands] --expect expression for directly executing the command
Jeric de Leon's avatar
update    
Jeric de Leon committed
228
  let g:fzf_commands_expect = 'ctrl-x'
Jeric de Leon's avatar
update    
Jeric de Leon committed
229
230

  " [Rg] pass arguments to rg (such as --hidden)
Jeric de Leon's avatar
update    
Jeric de Leon committed
231
232
  " To customize: lift from source, then remove double-dash and shellescape
  command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".<q-args>, 1, fzf#vim#with_preview(), <bang>0)
Jeric de Leon's avatar
Jeric de Leon committed
233
234
235
236
237
endfunction

function! PlugHookPreJunegunnGoyoVim()
  map <Leader>z :Goyo<CR>

238
  let g:goyo_linenr = 1
Jeric de Leon's avatar
Jeric de Leon committed
239
  let g:goyo_height = 100
240
  " let g:goyo_width = 100
Jeric de Leon's avatar
update    
Jeric de Leon committed
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

  " Run logic when goyo is enabled / disabled
  function! s:goyo_enter()
    if executable('tmux') && strlen($TMUX)
      silent !tmux set status off
      silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
    endif
    set noshowmode
    set noshowcmd
    set scrolloff=999
    Limelight
    SignifyEnable
  endfunction

  function! s:goyo_leave()
    if executable('tmux') && strlen($TMUX)
      silent !tmux set status on
      silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
    endif
    set showmode
    set showcmd
    set scrolloff=1 " set by tpope/vim-sensible
    Limelight!
    SignifyEnable
  endfunction

  autocmd! User GoyoEnter nested call <SID>goyo_enter()
  autocmd! User GoyoLeave nested call <SID>goyo_leave()
endfunction

function! PlugHookPreJunegunnLimelight()
Jeric de Leon's avatar
Jeric de Leon committed
272
273
274
275
276
277
endfunction

function! PlugHookPreJunegunnRainbowParenthesesVim()
  map <Leader>p :RainbowParentheses!!<CR>
endfunction

278
279
280
281
282
283
284
function! PlugHookPreJustinmkVimSneak()
  map f <Plug>Sneak_s
  map F <Plug>Sneak_S

  let g:sneak#s_next = 1
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
285
function! PlugHookPreLambdalisueFernVim()
Jeric de Leon's avatar
update    
Jeric de Leon committed
286
  map <Leader>ee :Fern . -drawer -reveal=% -width=40 -toggle<CR>
Jeric de Leon's avatar
Jeric de Leon committed
287
288

  let g:fern#renderer = "nerdfont"
Jeric de Leon's avatar
update    
Jeric de Leon committed
289
290
291
292

  function! s:init_fern() abort
    nmap <buffer><nowait> <C-j> 5j
    nmap <buffer><nowait> <C-k> 5k
Jeric de Leon's avatar
update    
Jeric de Leon committed
293
294
295
    nmap <buffer><nowait> zt zt
    nmap <buffer><nowait> zz zz
    nmap <buffer><nowait> zb zb
Jeric de Leon's avatar
update    
Jeric de Leon committed
296
297
298
299
300
301
  endfunction

  augroup fern-custom
    autocmd! *
    autocmd FileType fern call s:init_fern()
  augroup END
Jeric de Leon's avatar
Jeric de Leon committed
302
303
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
304
function! PlugHookPreLedgerVimLedger()
Jeric de Leon's avatar
update    
Jeric de Leon committed
305
306
  map <Leader>na :LedgerAlignBuffer<CR>
  map <Leader>nt :put=strftime('%Y/%m/%d')<CR>
Jeric de Leon's avatar
update    
Jeric de Leon committed
307

Jeric de Leon's avatar
update    
Jeric de Leon committed
308
  autocmd BufWritePost *.journal LedgerAlignBuffer
Jeric de Leon's avatar
update    
Jeric de Leon committed
309

Jeric de Leon's avatar
update    
Jeric de Leon committed
310
311
312
313
314
  " use "{" and "}" to move by paragraphs
  au FileType ledger noremap { ?^\d<CR>
  au FileType ledger noremap } /^\d<CR>
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
315
316
317
318
function! PlugHookPrePseewaldVimAnyfold()
  filetype plugin indent on " required
  syntax on                 " required

Jeric de Leon's avatar
Jeric de Leon committed
319
320
321
322
323
  autocmd Filetype * if &ft == "vimwiki" | call SetupFoldExclude() | elseif &ft == "git" | call SetupFoldGit() | else | call SetupFoldAny() | endif
  function! SetupFoldExclude()
    set nofoldenable " disable fold
    " vimwiki will handle its own folding
  endfunction
Jeric de Leon's avatar
Jeric de Leon committed
324
  function! SetupFoldGit()
Jeric de Leon's avatar
Jeric de Leon committed
325
    set foldenable " enable fold
Jeric de Leon's avatar
Jeric de Leon committed
326
327
328
    set foldlevel=0
  endfunction
  function! SetupFoldAny()
Jeric de Leon's avatar
Jeric de Leon committed
329
    set nofoldenable " disable fold
Jeric de Leon's avatar
Jeric de Leon committed
330
331
332
333
334
    AnyFoldActivate
    set foldlevel=99
  endfunction
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
335
336
function! PlugHookPrePsliwkaVimSmoothie()
  " speed at start of animation; default value: 10
Jeric de Leon's avatar
update    
Jeric de Leon committed
337
  let g:smoothie_speed_linear_factor = 40
Jeric de Leon's avatar
update    
Jeric de Leon committed
338
  " speed at end of animation; default value: 10
Jeric de Leon's avatar
update    
Jeric de Leon committed
339
  let g:smoothie_speed_constant_factor = 40
Jeric de Leon's avatar
update    
Jeric de Leon committed
340
341
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
342
function! PlugHookPreRbongVimFlog()
Jeric de Leon's avatar
update    
Jeric de Leon committed
343
  map <Leader>G :Flogsplit<CR>
Jeric de Leon's avatar
Jeric de Leon committed
344
345
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
346
function! PlugHookPreRuanylVimSortImports()
Jeric de Leon's avatar
update    
Jeric de Leon committed
347
  " let g:import_sort_auto = 1
Jeric de Leon's avatar
update    
Jeric de Leon committed
348
349
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
350
351
352
353
function! PlugHookRrethyVimHexokinase()
  let g:Hexokinase_highlighters = ['sign_column']
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
354
355
356
357
358
359
360
361
362
363
364
365
function! PlugHookPreSheerunVimPolyglot()
  " csv
  " let g:csv_nomap_space = 1
  " let g:csv_delim=','
  let g:polyglot_disabled = ['csv']

  " vim
  " do not conceal
  let g:vim_markdown_conceal = 0
  let g:vim_markdown_conceal_code_blocks = 0
endfunction

366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
function! PlugHookPreSvermeulenVimCutlass()
  " x to delete directly without cutting
  " use dl to delete a character
  nnoremap x d
  xnoremap x d
  nnoremap xx dd
  nnoremap X D
endfunction

function! PlugHookPreSvermeulenVimSubversive()
  " s to substitute
  " use cl to change a letter
  nmap s <plug>(SubversiveSubstitute)
  nmap ss <plug>(SubversiveSubstituteLine)
  nmap S <plug>(SubversiveSubstituteToEndOfLine)
endfunction

function! PlugHookPreSvermeulenVimYoink()
Jeric de Leon's avatar
update    
Jeric de Leon committed
384
385
386
387
388
389
390
391
392
393
394
395
396
397
  map <Leader>y :Yanks<CR>
  map <Leader>Y :ClearYanks<CR>

  let g:yoinkIncludeDeleteOperations = 1

  nmap p <plug>(YoinkPaste_p)
  nmap P <plug>(YoinkPaste_P)

  " Also replace the default gp with yoink paste so we can toggle paste in this case too
  nmap gp <plug>(YoinkPaste_gp)
  nmap gP <plug>(YoinkPaste_gP)

  nmap [p <plug>(YoinkRotateBack)
  nmap ]p <plug>(YoinkRotateForward)
398
399
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
400
function! PlugHookPreTpopeVimFugitive()
Jeric de Leon's avatar
update    
Jeric de Leon committed
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
  map <Leader>gg :G<CR>

  map <Leader>gw :GBrowse<CR>
  map <Leader>ge :Gedit<Space>
  map <Leader>gt :Git difftool<CR>
  map <Leader>gs :Gvdiffsplit<CR>
  map <Leader>gd :Git diff<CR>
  map <Leader>gh :Ghdiffsplit<CR>
  map <Leader>gl :Git log<CR>
  map <Leader>gb :Git blame<CR>
  map <Leader>gm :Git mergetool<CR>

  map <Leader>gM :GMove<Space>
  map <Leader>gR :GRename<Space>
  map <Leader>gD :GDelete<CR>
  map <Leader>gV :GRemove<CR>
Jeric de Leon's avatar
Jeric de Leon committed
417

Jeric de Leon's avatar
Jeric de Leon committed
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
  " set split to vertical
  set diffopt+=vertical

  " delete buffers
  autocmd BufReadPost fugitive://* set bufhidden=delete

  " to compare branches: :G difftool --name-only _from_ _to_
  " use <Leader>d to compare diffs in difftool
  " keep until part of plugin: https://github.com/tpope/vim-fugitive/issues/132#issuecomment-570844756
  fun! DiffCurrentQuickfixEntry() abort
    cc
    let qf = getqflist({'context': 0, 'idx': 0})
    if get(qf, 'idx') && type(get(qf, 'context')) == type({}) && type(get(qf.context, 'items')) == type([])
      let diff = get(qf.context.items[qf.idx - 1], 'diff', [])
      for i in reverse(range(len(diff)))
        exe (i ? 'rightbelow' : 'leftabove') 'vert diffsplit' fnameescape(diff[i].filename)
        wincmd p
      endfor
    endif
  endfun
Jeric de Leon's avatar
update    
Jeric de Leon committed
438
  " map <Leader>d :call DiffCurrentQuickfixEntry()<CR>
Jeric de Leon's avatar
Jeric de Leon committed
439
440
441
442
443
444
445
446
endfunction

function! PlugHookPreTpopeVimUnimpaired()
  nnoremap td :tabclose<CR>
  nnoremap tn :tabnew<CR>
endfunction

function! PlugHookPreValloricListToggle()
Jeric de Leon's avatar
update    
Jeric de Leon committed
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
  let g:lt_quickfix_list_toggle_map = '<Leader>at'
  let g:lt_location_list_toggle_map = '<Leader>dt'

  " quickfix
  map <Leader>ao :copen<CR>
  map <Leader>ac :cclose<CR>
  map <Leader>an :cnext<CR>
  map <Leader>ap :cprev<CR>
  map <Leader>ab :cb<CR>

  " loclist
  map <Leader>do :lopen<CR>
  map <Leader>dc :lclose<CR>
  map <Leader>dn :lnext<CR>
  map <Leader>dp :lprev<CR>
  map <Leader>db :lb<CR>
Jeric de Leon's avatar
Jeric de Leon committed
463
464
465
466
467
468
469
endfunction

function! PlugHookPreVimAirlineVimAirline()
  let g:airline_powerline_fonts = 1
  let g:airline#extensions#tabline#enabled = 1
endfunction

Jeric de Leon's avatar
Jeric de Leon committed
470
function! PlugHookPreVimwikiVimwiki()
Jeric de Leon's avatar
update    
Jeric de Leon committed
471
  map <Leader>vx :VimwikiToggleListItem<CR>
Jeric de Leon's avatar
Jeric de Leon committed
472
473
  map <Leader>vh :VimwikiAll2HTML!<CR>
  map <Leader>vs :VimwikiSearchTags<Space>
Jeric de Leon's avatar
Jeric de Leon committed
474
475
476
477
  map <Leader>vt :VimwikiTable<CR>

  au FileType vimwiki setlocal shiftwidth=2 tabstop=2 expandtab

Jeric de Leon's avatar
Jeric de Leon committed
478
  let g:vimwiki_folding = 'syntax'
Jeric de Leon's avatar
update    
Jeric de Leon committed
479
480

  " wiki
Jeric de Leon's avatar
update    
Jeric de Leon committed
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
  let g:vimwiki_list = [
  \ {
  \    'automatic_nested_syntaxes': 1,
  \    'auto_export': 1,
  \    'auto_tags': 1,
  \    'auto_toc': 1,
  \    'path': '$HOME/.local/share/notes/content',
  \    'path_html': '$HOME/.local/share/notes/public',
  \    'template_default': 'default',
  \    'template_ext': '.html',
  \    'template_path': '$HOME/.local/share/notes/templates',
  \ },
  \ {
  \    'automatic_nested_syntaxes': 1,
  \    'auto_export': 1,
  \    'auto_tags': 1,
  \    'auto_toc': 1,
  \    'path': '$HOME/.local/share/work/content',
  \    'path_html': '$HOME/.local/share/work/public',
  \    'template_default': 'default',
  \    'template_ext': '.html',
  \    'template_path': '$HOME/.local/share/work/templates',
  \ },
  \ ]
Jeric de Leon's avatar
Jeric de Leon committed
505
506
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
function! PlugHookPostGruvboxCommunityGruvbox()
  colorscheme gruvbox
endfunction

function! PlugHookPostNeovimLspconfig()
  " nnoremap <Leader>rd <cmd>lua vim.lsp.buf.definition()<CR>
  " nnoremap <Leader>rc <cmd>lua vim.lsp.buf.declaration()<CR>
  " nnoremap <Leader>rr <cmd>lua vim.lsp.buf.references()<CR>
  " nnoremap <Leader>ri <cmd>lua vim.lsp.buf.implementation()<CR>
  " nnoremap <Leader>re <cmd>lua vim.lsp.buf.hover()<CR>
  " nnoremap <Leader>rh <cmd>lua vim.lsp.buf.signature_help()<CR>
  " nnoremap <Leader>ra <cmd>lua vim.lsp.buf.code_action()<CR>
  " nnoremap <Leader>rm <cmd>lua vim.lsp.buf.rename()<CR>
  " nnoremap <Leader>rf <cmd>lua vim.lsp.buf.formatting()<CR>
  " nnoremap <Leader>rp <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
  " nnoremap <Leader>rn <cmd>lua vim.lsp.diagnostic.goto_next()<CR>

lua << EOF
local nvim_lsp = require('lspconfig')

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o>
  buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

  -- Mappings.
  local opts = { noremap=true, silent=true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', '<space>rd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', '<space>rD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', '<space>re', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', '<space>ri', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', '<space>rh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  -- buf_set_keymap('n', '<space>rwa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  -- buf_set_keymap('n', '<space>rwr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  -- buf_set_keymap('n', '<space>rwl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  buf_set_keymap('n', '<space>rt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  buf_set_keymap('n', '<space>ra', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', '<space>rc', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', '<space>rr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '<space>rl', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', '<space>rp', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', '<space>ro', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  buf_set_keymap('n', '<space>rf', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end

-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
--
-- To debug, check: ~/.cache/nvim/lsp.log
Jeric de Leon's avatar
update    
Jeric de Leon committed
563
local servers = { 'rls', 'solargraph', 'tsserver', 'vuels' }
Jeric de Leon's avatar
update    
Jeric de Leon committed
564
565
566
567
568
569
570
571
572
573
574
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
    }
  }
end
EOF
endfunction

Jeric de Leon's avatar
update    
Jeric de Leon committed
575
call PlugHookPreBase()
Jeric de Leon's avatar
Jeric de Leon committed
576
577
call PlugHookPreArecarnCloseBuffersVim()
call PlugHookPreBenknobleVimAutoOrigami()
Jeric de Leon's avatar
Jeric de Leon committed
578
call PlugHookPreBroothFarVim()
Jeric de Leon's avatar
update    
Jeric de Leon committed
579
call PlugHookPreDenseAnalysisAle()
Jeric de Leon's avatar
Jeric de Leon committed
580
581
582
583
call PlugHookPreGruvboxCommunityGruvbox()
call PlugHookPreHaya14busaIncSearchVim()
call PlugHookPreJunegunnFzfVim()
call PlugHookPreJunegunnGoyoVim()
Jeric de Leon's avatar
update    
Jeric de Leon committed
584
call PlugHookPreJunegunnLimelight()
Jeric de Leon's avatar
Jeric de Leon committed
585
586
call PlugHookPreJunegunnRainbowParenthesesVim()
call PlugHookPreLambdalisueFernVim()
Jeric de Leon's avatar
update    
Jeric de Leon committed
587
call PlugHookPreLedgerVimLedger()
Jeric de Leon's avatar
Jeric de Leon committed
588
call PlugHookPrePseewaldVimAnyfold()
Jeric de Leon's avatar
update    
Jeric de Leon committed
589
call PlugHookPrePsliwkaVimSmoothie()
Jeric de Leon's avatar
Jeric de Leon committed
590
call PlugHookPreRbongVimFlog()
Jeric de Leon's avatar
update    
Jeric de Leon committed
591
call PlugHookPreRuanylVimSortImports()
Jeric de Leon's avatar
update    
Jeric de Leon committed
592
call PlugHookRrethyVimHexokinase()
Jeric de Leon's avatar
Jeric de Leon committed
593
call PlugHookPreSheerunVimPolyglot()
594
595
596
call PlugHookPreSvermeulenVimCutlass()
call PlugHookPreSvermeulenVimSubversive()
call PlugHookPreSvermeulenVimYoink()
Jeric de Leon's avatar
Jeric de Leon committed
597
598
599
600
call PlugHookPreTpopeVimFugitive()
call PlugHookPreTpopeVimUnimpaired()
call PlugHookPreValloricListToggle()
call PlugHookPreVimAirlineVimAirline()
Jeric de Leon's avatar
Jeric de Leon committed
601
call PlugHookPreVimwikiVimwiki()
Jeric de Leon's avatar
Jeric de Leon committed
602
603
604
605
606
607
608

call plug#begin('~/.vim/plugged')

Plug 'arecarn/vim-fold-cycle'
Plug 'asheq/close-buffers.vim'
Plug 'benknoble/vim-auto-origami'
Plug 'blueyed/vim-diminactive'
Jeric de Leon's avatar
Jeric de Leon committed
609
610
Plug 'bronson/vim-visual-star-search'
Plug 'brooth/far.vim'
Jeric de Leon's avatar
Jeric de Leon committed
611
Plug 'christoomey/vim-system-copy'
Jeric de Leon's avatar
update    
Jeric de Leon committed
612
Plug 'dense-analysis/ale'
Jeric de Leon's avatar
Jeric de Leon committed
613
614
615
616
617
Plug 'davinche/godown-vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'gruvbox-community/gruvbox'
Plug 'haya14busa/incsearch.vim'
Plug 'idanarye/vim-merginal'
Jeric de Leon's avatar
update    
Jeric de Leon committed
618
Plug 'juanchanco/vim-jbuilder'
Jeric de Leon's avatar
update    
Jeric de Leon committed
619
Plug 'junegunn/fzf'
Jeric de Leon's avatar
Jeric de Leon committed
620
621
622
623
624
625
626
Plug 'junegunn/fzf.vim'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'kshenoy/vim-signature'
Plug 'lambdalisue/nerdfont.vim'
Plug 'lambdalisue/fern.vim'
Jeric de Leon's avatar
update    
Jeric de Leon committed
627
Plug 'lambdalisue/fern-bookmark.vim'
Jeric de Leon's avatar
Jeric de Leon committed
628
Plug 'lambdalisue/fern-git-status.vim'
Jeric de Leon's avatar
update    
Jeric de Leon committed
629
630
631
Plug 'lambdalisue/fern-hijack.vim'
Plug 'lambdalisue/fern-mapping-mark-children.vim'
Plug 'lambdalisue/fern-mapping-quickfix.vim'
Jeric de Leon's avatar
Jeric de Leon committed
632
Plug 'lambdalisue/fern-renderer-nerdfont.vim'
Jeric de Leon's avatar
update    
Jeric de Leon committed
633
Plug 'ledger/vim-ledger'
Jeric de Leon's avatar
Jeric de Leon committed
634
Plug 'liuchengxu/vista.vim'
Jeric de Leon's avatar
Jeric de Leon committed
635
Plug 'lumakernel/fern-mapping-fzf.vim'
Jeric de Leon's avatar
Jeric de Leon committed
636
637
638
639
640
Plug 'mattn/emmet-vim'
Plug 'matze/vim-move'
Plug 'mg979/vim-visual-multi'
Plug 'mhinz/vim-signify'
Plug 'michaeljsmith/vim-indent-object'
Jeric de Leon's avatar
update    
Jeric de Leon committed
641
Plug 'neovim/nvim-lspconfig'
Jeric de Leon's avatar
Jeric de Leon committed
642
643
644
645
646
Plug 'nicwest/vim-http'
Plug 'pseewald/vim-anyfold'
Plug 'psliwka/vim-smoothie'
Plug 'rbong/vim-flog'
Plug 'roxma/vim-tmux-clipboard'
Jeric de Leon's avatar
Jeric de Leon committed
647
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
Jeric de Leon's avatar
Jeric de Leon committed
648
649
650
651
Plug 'ruanyl/vim-sort-imports'
Plug 'ryanoasis/vim-devicons'
Plug 'sheerun/vim-polyglot'
Plug 'simeji/winresizer'
Jeric de Leon's avatar
update    
Jeric de Leon committed
652
Plug 'slim-template/vim-slim'
653
654
655
Plug 'svermeulen/vim-cutlass'
Plug 'svermeulen/vim-subversive'
Plug 'svermeulen/vim-yoink'
Jeric de Leon's avatar
Jeric de Leon committed
656
657
658
659
660
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-repeat'
Jeric de Leon's avatar
update    
Jeric de Leon committed
661
Plug 'tpope/vim-rhubarb'
Jeric de Leon's avatar
Jeric de Leon committed
662
663
664
665
666
667
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'valloric/listtoggle'
Jeric de Leon's avatar
Jeric de Leon committed
668
Plug 'vimwiki/vimwiki'
Jeric de Leon's avatar
Jeric de Leon committed
669
670
671
672
673
674
675
676
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'wincent/terminus'
Plug 'yggdroot/indentline'

call plug#end()

call PlugHookPostGruvboxCommunityGruvbox()
Jeric de Leon's avatar
update    
Jeric de Leon committed
677
call PlugHookPostNeovimLspconfig()