@@ -28,10 +28,19 @@ call plug#end()
2828
2929" ### Plugins #####################################
3030let g: fzf_layout = { ' down' : ' ~70%' }
31+ let g: fzf_preview_window = [' right:50%:hidden' , ' ctrl-p' ]
32+
33+ autocmd ! FileType fzf
34+ autocmd FileType fzf set laststatus = 0 noshowmode noruler
35+ \| autocmd BufLeave <buffer> set laststatus = 2 showmode ruler
36+
3137command ! - bang -nargs =? -complete =dir Files
3238 \ call fzf#vim#files (<q-args> , fzf#vim#with_preview (), <bang> 0 )
3339command ! - bang -nargs =? GFiles
3440 \ call fzf#vim#gitfiles (<q-args> , fzf#vim#with_preview (), <bang> 0 )
41+ command ! - bang -nargs =* Bindings
42+ \ call fzf#vim#grep (' grep --line-number "ma[p]" ~/.config/nvim/init.vim -- ' .shellescape (<q-args> ), 0 ,
43+ \ fzf#vim#with_preview ({' options' : [' --delimiter=:' , ' --with-nth=3..' ]}), <bang> 0 )
3544
3645let g: ale_fixers = {
3746 \ ' go' : [' goimports' ],
@@ -47,13 +56,11 @@ let g:ale_rust_rls_config = {
4756 \ }
4857 \ }
4958
50- let g: rustlint1 = [' rls' , ' cargo' ]
51- let g: rustlint2 = [' rls' , ' cargo' , ' rustc' ]
52-
5359let g: ale_linters = {
5460 \ ' go' : [' gopls' , ' gobuild' , ' golangci-lint' ],
55- \ ' rust' : g: rustlint1
61+ \ ' rust' : [ ' rls ' , ' cargo ' ]
5662 \}
63+ " \ 'rust': ['rls', 'cargo', 'rustc']
5764
5865let g: ale_go_golangci_lint_options = " --enable-all -D lll,gomnd -E EXC0002 --skip-files _test.go"
5966let g: ale_rust_ignore_error_codes = [' E0601' ]
@@ -78,7 +85,10 @@ let g:go_imports_mode = "gopls"
7885let g: go_gopls_complete_unimported = v: true
7986let g: go_gopls_deep_completion = v: true
8087let g: go_gopls_matcher = " fuzzy"
81- let g: go_doc_popup_window = 1
88+ " let g:go_doc_popup_window = 1
89+
90+ let g: racer_insert_paren = 1
91+ let g: racer_experimental_completer = 1
8292
8393let g: neosolarized_contrast = " high"
8494let g: neosolarized_visibility = " high"
@@ -95,10 +105,10 @@ let g:airline_symbols.notexists = "\ue009"
95105
96106let g: indentLine_char = ' │'
97107
98- let g: racer_insert_paren = 1
99- let g: racer_experimental_completer = 1
108+ let g: EasyMotion_keys = " xwchmuloriaefds"
100109
101- let g: EasyMotion_keys = " ohlurfdaies"
110+ autocmd TermOpen * setlocal laststatus = 0 noshowmode noruler
111+ \| autocmd TermClose * setlocal laststatus = 2 showmode ruler
102112
103113" ### Settings ####################################
104114set fileformats = unix,mac,dos
@@ -183,11 +193,9 @@ function! ChangeReplace(...)
183193 if a: 0 == 0
184194 let motion = GetMotion ()
185195 endif
186- let save_cursor = getcurpos ()
187- exe ' norm "_c' .motion.trim (getreg (" +" ), " \<c-J> " )." \<ESC> mm"
188- call setpos (" ." , save_cursor)
189- norm = 'm
190- call setpos (" ." , save_cursor)
196+ set paste
197+ exe ' norm "_c' .motion.trim (getreg (" +" ), " \<c-J> " )." \<ESC> "
198+ set nopaste
191199 call repeat#set (" :call ChangeReplace('" .motion." ')\<CR> " ,-1 )
192200 return " "
193201endfunction
@@ -206,6 +214,23 @@ function! YankAppend(...)
206214 return " "
207215endfunction
208216
217+ function ! YankComment (... )
218+ let motion = get (a: , 1 )
219+ if a: 0 == 0
220+ let motion = GetMotion ()
221+ endif
222+ if motion == " c"
223+ norm yy
224+ elseif motion == " ip"
225+ norm yap
226+ else
227+ exe ' norm y' .motion
228+ endif
229+ exe ' norm gc' .motion
230+ call repeat#set (" :call YankComment('" .motion." ')\<CR> " ,-1 )
231+ return " "
232+ endfunction
233+
209234function ! CleverTab ()
210235 if pumvisible ()
211236 return " \<c-n> "
@@ -258,50 +283,111 @@ function! GitFileUrl()
258283 return repo_url." /blob/" .branch.tree." \\ #L" .line
259284endfunction
260285
261- " ### Remappings ##################################
262- " --- Functions -----------------------------------
263- nnoremap <silent> gC :call ChangeReplace()<CR>
264- nnoremap <silent> gy :call YankAppend()<CR>
286+ " ### Bindings ####################################
287+ let mapleader = " ,"
265288
266- nnoremap <silent> gh :let @+ = GitFileUrl()<CR>
267- nnoremap <silent> gH :silent exe "!open ".GitFileUrl()<CR>
289+ " --- Should-Be-Defaults --------------------------
290+ nnoremap <silent> c "_c
291+ nnoremap <silent> Y y$
292+ nnoremap <silent> C "_C
293+ nnoremap <silent> x "_x
294+ tmap <silent> <c-w> <c-\><c-w>
295+ tnoremap <silent> <c-\> <c-\><c-n>
296+ inoremap <silent> <c-f> <c-x><c-f>
297+ inoremap <silent> <c-l> <c-x><c-l>
298+ inoremap <silent> <c-b> <c-x><c-p>
299+ " ^ <c-x><c-p> block complete (continue completing where left off)
268300
269- nnoremap <silent> gA i<c-r> =AlignWithMark()<CR><ESC>
270- vnoremap <silent> gA I<c-r> =AlignWithMark()<CR><ESC>
301+ " --- Functions -----------------------------------
302+ nnoremap <silent> yc :call YankComment()<CR>
303+ nnoremap <silent> gy :call YankAppend()<CR>
304+ nnoremap <silent> gr :call ChangeReplace()<CR>
305+ nnoremap <silent> gR :call ChangeReplace("$")<CR>
306+ nnoremap <silent> grr :call ChangeReplace("c")<CR>
307+ nnoremap <silent> ga i<c-r> =AlignWithMark()<CR><ESC>
308+ vnoremap <silent> ga I<c-r> =AlignWithMark()<CR><ESC>
309+
310+ nnoremap <silent> gt :call TempTerm(" ")<CR>
311+ nnoremap <silent> gL :call TempTerm("lazygit")<CR>
312+ nnoremap <silent> gl :call TempTerm("lf")<CR>
271313
272314nnoremap <silent> <c-w> r :call ResizeMode()<CR>
273-
274315inoremap <silent> <c-c> <c-r> =CompletionStatus()<CR>
275-
276316inoremap <silent> <Tab> <c-r> =CleverTab()<CR>
277317inoremap <silent> <s-Tab> <c-r> =OmniTab()<CR>
278318
279- " --- Should-Be-Defaults --------------------------
280- nnoremap <silent> gw :w<CR>
281- nnoremap <silent> c "_c
282- nnoremap <silent> Y y$
283- nnoremap <silent> C "_C
284- nnoremap <silent> x "_x
285- tnoremap <silent> <c-\> <c-\><c-n>
286- tmap <silent> <c-w> <c-\><c-w>
319+ " --- Surround ------------------------------------
320+ nmap <silent> gs ys
321+ nmap <silent> g' ysiW"
322+ nmap <silent> dsf dt(ds(
287323
324+ " --- Saving --------------------------------------
288325cnoremap W! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
289-
290- " --- Testing -------------------------------------
326+ nnoremap <silent> gw :w<CR>
291327nnoremap <silent> gW ZZ
292328nnoremap <silent> gQ ZQ
293329
294- " --- Autocomplete --------------------------------
295- inoremap <c-f> <c-x><c-f>
296- inoremap <c-l> <c-x><c-l>
297- inoremap <c-b> <c-x><c-p>
298- " ^ <c-x><c-p> block complete (continue completing where left off)
330+ " --- Buffers -------------------------------------
331+ nnoremap <silent> gn :bn<CR>
332+ nnoremap <silent> gp :bp<CR>
333+ nnoremap <silent> gq :bd<CR>
334+
335+ " --- Coding --------------------------------------
336+ nnoremap <Leader> s :%s//g<Left><Left>
337+ nnoremap <Leader> S :%s/<c-r><c-w> //g<Left><Left>
338+
339+ nnoremap <silent> <Leader> g :let @+ = GitFileUrl()<CR>
340+ nnoremap <silent> <Leader> G :silent exe "!open ".GitFileUrl()<CR>
341+
342+ nnoremap <silent> <Leader><Leader> h :set hlsearch!<CR>
343+ nnoremap <silent> <Leader><Leader> i :IndentLinesToggle<CR>
344+
345+ " --- Ale Linting ---------------------------------
346+ nnoremap <silent> <Leader> n :ALENextWrap<CR>
347+ nnoremap <silent> <Leader> p :ALEPreviousWrap<CR>
348+ nnoremap <silent> <Leader> f :ALEFix<CR>
349+ nnoremap <silent> <Leader> d :ALEDetail<CR>
299350
300- " --- Splits/Buffers ------------------------------
301- nnoremap <silent> gn :bn<CR>
302- nnoremap <silent> gp :bp<CR>
303- nnoremap <silent> gbd :bd<CR>
304- nnoremap <silent> gbD :bd \| sbn<CR>
351+ " --- Vim-Go --------------------------------------
352+ augroup go
353+ autocmd !
354+ autocmd FileType go IndentLinesDisable
355+ autocmd FileType go highlight link Whitespace Conceal
356+ autocmd FileType go set list listchars = tab :\|\ " keep trailing space
357+
358+ autocmd FileType go nmap gd :GoDef<CR>
359+ autocmd FileType go nmap gD :sp<CR> :GoDef<CR>
360+
361+ autocmd FileType go nmap <Leader> i :GoInfo<CR>
362+ autocmd FileType go nmap <Leader> I :GoSameIdsToggle<CR>
363+ autocmd FileType go nmap <Leader> t :GoTest!<CR>
364+ autocmd FileType go nmap <Leader> T :GoTestFunc!<CR>
365+ autocmd FileType go nmap <Leader> a :GoAlternate<CR>
366+ autocmd FileType go nmap <Leader> A :e <c-r> %<LEFT><LEFT><LEFT> _test<CR>
367+ autocmd FileType go nmap <Leader> c :GoCoverageToggle<CR>
368+ autocmd FileType go nmap <Leader> C :GoCoverageBrowser<CR>
369+ autocmd FileType go nmap <Leader> r :GoRun %<CR>
370+ autocmd FileType go nmap <Leader> R :GoRun %<Space>
371+ autocmd FileType go nmap <Leader> b :GoTestCompile<CR>
372+
373+ autocmd FileType go nmap <Leader> <Leader> i :set list!<CR>
374+ autocmd FileType go nmap <silent> <Leader> o :silent exe "!open ".
375+ \ substitute('<c-r><c-l> ', '^.*"\([^/]*/[^/]*/[^/]*\)\(.*\)"', 'https://\1/tree/master\2', '')<CR>
376+ augroup END
377+
378+ " --- Vim-Rust ------------------------------------
379+ augroup Racer
380+ autocmd !
381+ autocmd FileType rust nmap gd <Plug> (rust-def)
382+ autocmd FileType rust nmap gD <Plug> (rust-def-split)
383+ autocmd FileType rust nmap K <Plug> (rust-doc)
384+
385+ autocmd FileType rust nmap <Leader> t :Ctest<CR>
386+ autocmd FileType rust nmap <Leader> T :RustTest<CR>
387+ autocmd FileType rust nmap <Leader> r :Crun<CR>
388+ autocmd FileType rust nmap <Leader> R :Crun<Space>
389+ autocmd FileType rust nmap <Leader> b :Cbuild<CR>
390+ augroup END
305391
306392" --- Writing -------------------------------------
307393function ! s: goyo_enter ()
@@ -322,98 +408,30 @@ endfunction
322408autocmd ! User GoyoEnter nested call <SID> goyo_enter ()
323409autocmd ! User GoyoLeave nested call <SID> goyo_leave ()
324410
325- autocmd FileType text nnoremap gan ]s
326- autocmd FileType text nnoremap gap [s
327- autocmd FileType text nnoremap gaf z=
328- autocmd FileType text nnoremap gaF :spellrepall<CR>
329-
330- " --- Coding --------------------------------------
331- nnoremap goq <c-w> j<c-w> q
332- nnoremap gs :%s//g<Left><Left>
333- nnoremap gS :%s/<c-r><c-w> //g<Left><Left>
334- nnoremap gth :set hlsearch!<CR>
335- nnoremap gtl :IndentLinesToggle<CR>
336-
337- " --- Surround ------------------------------------
338- nmap <silent> dsf dt(ds(
339- nmap <silent> dsm dt[ds[
340- nmap <silent> dsl dt{ds{
341- nmap <silent> dsv dt<ds<
342- nmap <silent> g' ysiW"
343-
344- " --- Ale Linting ---------------------------------
345- nnoremap <silent> gaa :ALEFirst<CR>
346- nnoremap <silent> gan :ALENextWrap<CR>
347- nnoremap <silent> gap :ALEPreviousWrap<CR>
348- nnoremap <silent> gaf :ALEFix<CR>
349- nnoremap <silent> gad :ALEDetail<CR>
350-
351- " --- Vim-Go --------------------------------------
352- autocmd FileType go nnoremap gd :GoDef<CR>
353- autocmd FileType go nnoremap gD :sp<CR> :GoDef<CR>
354- autocmd FileType go nnoremap goi :GoInfo<CR>
355- autocmd FileType go nnoremap goI :GoSameIdsToggle<CR>
356- autocmd FileType go nnoremap got :GoTest!<CR>
357- autocmd FileType go nnoremap goT :GoTestFunc!<CR>
358- autocmd FileType go nnoremap goa :GoAlternate<CR>
359- autocmd FileType go nnoremap goA :e <c-r> %<LEFT><LEFT><LEFT> _test<CR>
360- autocmd FileType go nnoremap goc :GoCoverageToggle<CR>
361- autocmd FileType go nnoremap goC :GoCoverageBrowser<CR>
362- autocmd FileType go nnoremap gor :GoRun %<CR>
363- autocmd FileType go nnoremap goR :GoRun %<Space>
364- autocmd FileType go nnoremap gob :GoTestCompile<CR>
365- autocmd FileType go nnoremap gtl :set list!<CR>
366-
367- autocmd FileType go nnoremap <silent> goo :silent exe "!open ".
368- \ substitute('<c-r><c-l> ', '^.*"\([^/]*/[^/]*/[^/]*\)\(.*\)"', 'https://\1/tree/master\2', '')<CR>
369-
370- autocmd FileType go IndentLinesDisable
371- autocmd FileType go highlight link Whitespace Conceal
372- autocmd FileType go set list listchars = tab :\|\ " keep trailing space
373-
374- " --- Vim-Rust ------------------------------------
375- augroup Racer
376- " autocmd!
377- autocmd FileType rust nmap gd <Plug> (rust-def)
378- autocmd FileType rust nmap gD <Plug> (rust-def-split)
379- autocmd FileType rust nmap K <Plug> (rust-doc)
380- autocmd FileType rust nmap gor :Crun<CR>
381- autocmd FileType rust nmap goR :Crun<Space>
382- autocmd FileType rust nmap got :Ctest<CR>
383- autocmd FileType rust nmap goT :RustTest<CR>
384- autocmd FileType rust nmap gob :Cbuild<CR>
385- autocmd FileType rust nmap gtr :let g:ale_linters['rust'] = g:rustlint1<CR>
386- autocmd FileType rust nmap gtR :let g:ale_linters['rust'] = g:rustlint2<CR>
387- augroup END
388-
389- " --- Leader Key ----------------------------------
390- let mapleader = " ,"
391- nnoremap <silent> <Leader> t :call TempTerm(" ")<CR>
392- nnoremap <silent> <Leader> L :call TempTerm("lazygit")<CR>
393- nnoremap <silent> <Leader> l :call TempTerm("lf")<CR>
411+ autocmd FileType text nnoremap <Leader> n ]s
412+ autocmd FileType text nnoremap <Leader> p [s
413+ autocmd FileType text nnoremap <Leader> f z=
414+ autocmd FileType text nnoremap <Leader> F :spellrepall<CR>
394415
395416" --- Fzf -----------------------------------------
396417let maplocalleader = " \<Space> "
397- nnoremap <LocalLeader> g :GFiles<CR>
398- nnoremap <LocalLeader> s :GFiles?<CR>
399- nnoremap <LocalLeader> c :Files<CR>
400- nnoremap <LocalLeader> L :Lines<CR>
401- nnoremap <LocalLeader> t :Filetypes<CR>
402- nnoremap <LocalLeader> T :set filetype=<CR>
403- nnoremap <LocalLeader> b :Buffers<CR>
404- nnoremap <LocalLeader> w :Windows<CR>
405- nnoremap <LocalLeader> r :Rg<CR>
406- nnoremap <LocalLeader> h :History<CR>
407- nnoremap <LocalLeader> m :Maps<CR>
408- nnoremap <LocalLeader> / :BLines<CR>
409- nnoremap <LocalLeader> ' :Marks<CR>
410- nnoremap <LocalLeader> : :Commands<CR>
411- nnoremap <LocalLeader> ? :Helptags<CR>
412- nnoremap <LocalLeader> ~ :Files ~
413- nnoremap <LocalLeader> . :Files ../
418+
419+ nnoremap <LocalLeader> <LocalLeader> s :GFiles?<CR>
420+ nnoremap <LocalLeader> <LocalLeader> g :GFiles<CR>
421+ nnoremap <LocalLeader> <LocalLeader> f :Files<CR>
422+ nnoremap <LocalLeader> <LocalLeader> . :Files ../
423+ nnoremap <LocalLeader> <LocalLeader> / :BLines<CR>
424+ nnoremap <LocalLeader> <LocalLeader> l :Lines<CR>
425+ nnoremap <LocalLeader> <LocalLeader> r :Rg<CR>
426+ nnoremap <LocalLeader> <LocalLeader> b :Buffers<CR>
427+ nnoremap <LocalLeader> <LocalLeader> m :Maps<CR>
428+ nnoremap <LocalLeader> <LocalLeader> h :Helptags<CR>
429+ nnoremap <LocalLeader> <LocalLeader> t :Filetypes<CR>
430+ " nnoremap <LocalLeader><LocalLeader>T :set filetype=<CR>
431+ nnoremap <LocalLeader> <LocalLeader> ? :Bindings<CR>
414432
415433" --- Easy Motion ---------------------------------
416- nmap <LocalLeader> <LocalLeader> <Plug> (easymotion-overwin-w)
417- nmap <LocalLeader> a <Plug> (easymotion-jumptoanywhere)
418- nmap <LocalLeader> f <Plug> (easymotion-bd-wl)
419- nmap <LocalLeader> l <Plug> (easymotion-sol-bd-jk)
434+ nmap <LocalLeader> g <Plug> (easymotion-overwin-w)
435+ nmap <LocalLeader> a <Plug> (easymotion-jumptoanywhere)
436+ nmap <LocalLeader> f <Plug> (easymotion-bd-wl)
437+ nmap <LocalLeader> l <Plug> (easymotion-sol-bd-jk)
0 commit comments