From 2936d7e91b6769293ab2db815ab68ed906a41e32 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 5 Oct 2023 21:30:23 +0200 Subject: [PATCH] switching to fzf --- neovim/.config/nvim/init.vim | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/neovim/.config/nvim/init.vim b/neovim/.config/nvim/init.vim index f30ac79..9fa5b8c 100644 --- a/neovim/.config/nvim/init.vim +++ b/neovim/.config/nvim/init.vim @@ -1,6 +1,7 @@ call plug#begin('~/.config/nvim/plugins') -Plug 'cloudhead/neovim-fuzzy' Plug 'jnurmine/Zenburn' +Plug 'junegunn/fzf' +Plug 'junegunn/fzf.vim' Plug 'mhinz/vim-signify' Plug 'LnL7/vim-nix' call plug#end() @@ -12,9 +13,6 @@ endif filetype plugin indent on -" https://github.com/cloudhead/neovim-fuzzy/issues/50 -let g:fuzzy_rootcmds = [["git", "rev-parse", "--show-toplevel"]] - let g:markdown_fenced_languages = ['python', 'bash=sh', 'go', 'c', 'cpp', 'yaml', 'json', 'sql', 'haskell'] set autowrite @@ -36,9 +34,15 @@ set statusline=\(%n\)\ %<%.99f\ %y\ %w%m%r%=%-14.(%l,%c%V%)\ %P set textwidth=120 set wrapscan -nnoremap :FuzzyOpen -nnoremap :FuzzyGrep -nnoremap :buffers:buffer +" fzf mappings +nnoremap :Buffers +nnoremap :Files +nnoremap :Bd +if has('mac') + nnoremap :Rg +elseif has('linux') + nnoremap :Rg +endif nnoremap :nohls @@ -55,6 +59,24 @@ function! s:StripTrailing() call cursor(l, c) endfunction +" helper functions and command for `:bd` in fzf +function! s:ListBuffers() + redir => list + silent ls + redir END + return split(list, "\n") +endfunction + +function! s:DeleteBuffers(lines) + execute 'bwipeout' join(map(a:lines, {_, line -> split(line)[0]})) +endfunction + +command! Bd call fzf#run(fzf#wrap({ + \ 'source': s:ListBuffers(), + \ 'sink*': { lines -> s:DeleteBuffers(lines) }, + \ 'options': '--multi --reverse --bind ctrl-a:select-all+accept --prompt "Bd> "' +\ })) + augroup vimrc autocmd! autocmd BufWritePre * call s:StripTrailing()