From 9dd0ad4e876fd185f57cafe4756b8c1509fc65fd Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 2 Dec 2019 16:52:42 +0530 Subject: [PATCH] nvim: init.vim: Switch to vim-clap vim-clap seems to be much nicer and has better integration with the floating window feature of neovim. Use fzf again since we need cscope integration. Eventually we would like to have a cscope provider for clap. Also fzf seems to be installed by default on Manjaro i3. Signed-off-by: Sanchayan Maity --- nvim/init.vim | 63 +++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index 80eceb9..a11b5b5 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -8,9 +8,9 @@ Plug 'ervandew/supertab' " EasyMotion - Allows (b|e) to jump to (b)eginning or (end) " of words. Plug 'easymotion/vim-easymotion' -" Fuzzy file search -Plug 'lotabout/skim', { 'dir': '~/.skim', 'do': './install' } -Plug 'lotabout/skim.vim' +" Fuzzy search +Plug 'junegunn/fzf.vim' +Plug 'liuchengxu/vim-clap' " Remove extraneous whitespace when edit mode is exited Plug 'thirtythreeforty/lessspace.vim' " Status bar mods @@ -193,20 +193,19 @@ nnoremap Q nnoremap pg :PlugUpgrade nnoremap pd :PlugUpdate nnoremap pc :PlugClean -" For skim -nnoremap vf :Files -nnoremap vg :GFiles -nnoremap vb :Buffers -nnoremap vL :Lines -nnoremap vl :BLines -nnoremap vt :BTags -nnoremap vT :Tags -nnoremap vc :BCommits -nnoremap va :Commits -nnoremap vch :History: -nnoremap vsh :History/ -" Use ripgrep to search for content in files -nnoremap / :Rg +" For Clap +nnoremap vf :Clap files +nnoremap vg :Clap gfiles +nnoremap vb :Clap buffers +nnoremap vL :Clap lines +nnoremap vl :Clap blines +nnoremap vc :Clap bcommits +nnoremap va :Clap commits +nnoremap vh :Clap history +nnoremap vm :Clap command +nnoremap / :Clap grep +nnoremap d :Clap grep ++query= +" Quick buffer switching nnoremap b :ls:b " Undo tree nnoremap u :UndotreeToggle @@ -221,8 +220,6 @@ nnoremap sv :vsp nnoremap x :x nnoremap q :q nnoremap qa :qa -" Search for the word under cursor -noremap d :exe ':Rg ' . expand('') " Open terminal nnoremap te :vsp :terminal " Tab navigation shortcuts @@ -458,7 +455,7 @@ autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk " Automatically resize the window autocmd VimResized * wincmd = -" CScope & skim integration +" CScope & fuzzy integration " Taken from https://gist.github.com/amitab/cd051f1ea23c588109c6cfcb7d1d5776 " However, the above gist has completely wrong mappings function! Cscope(option, query) @@ -475,7 +472,7 @@ function! Cscope(option, query) let file = split(data[0], ":") execute 'e ' . '+' . file[1] . ' ' . file[0] endfunction - call skim#run(opts) + call fzf#run(opts) endfunction function! CscopeQuery(option) @@ -530,30 +527,6 @@ nnoremap sf :call CscopeQuery('7') nnoremap si :call CscopeQuery('8') nnoremap sa :call CscopeQuery('9') -" Adapted from https://www.reddit.com/r/neovim/comments/djmehv/im_probably_really_late_to_the_party_but_fzf_in_a/ -let g:skim_layout = { 'window': 'call FloatingSkim()' } - -function! FloatingSkim() - let buf = nvim_create_buf(v:false, v:true) - call setbufvar(buf, '&signcolumn', 'no') - - let height = float2nr(&lines * 0.4) - let width = float2nr(&columns * 0.8) - let horizontal = float2nr((&columns - width) / 2) - let vertical = float2nr((&columns - width) / 2) - - let opts = { - \ 'relative': 'editor', - \ 'row': vertical, - \ 'col': horizontal, - \ 'width': width, - \ 'height': height, - \ 'style': 'minimal' - \ } - - call nvim_open_win(buf, v:true, opts) -endfunction - function! NvimGdbNoTKeymaps() tnoremap endfunction