switching to fzf
This commit is contained in:
@@ -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 <silent> <C-o> :FuzzyOpen<CR>
|
||||
nnoremap <silent> <C-_> :FuzzyGrep<CR>
|
||||
nnoremap <silent> <C-b> :buffers<CR>:buffer<Space>
|
||||
" fzf mappings
|
||||
nnoremap <silent> <C-g> :Buffers<CR>
|
||||
nnoremap <silent> <C-o> :Files<CR>
|
||||
nnoremap <silent> <C-q> :Bd<CR>
|
||||
if has('mac')
|
||||
nnoremap <silent> <C-/> :Rg<CR>
|
||||
elseif has('linux')
|
||||
nnoremap <silent> <C-_> :Rg<CR>
|
||||
endif
|
||||
|
||||
nnoremap <silent> <esc><esc> :nohls<CR>
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user