From a390d1439070997a46558acf8f54f6313c834c40 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 27 Feb 2020 10:06:38 +0100 Subject: [PATCH] [nvim] Simplify floating fzf window fzf already comes with its own floating window call function, so we don't have to use our own. Instead simply call the floating window when we are in compatible vim/nvim version and let fzf do its thing. --- nvim/.config/nvim/plugin/fzf.vim | 37 +++++++++----------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/nvim/.config/nvim/plugin/fzf.vim b/nvim/.config/nvim/plugin/fzf.vim index 256874a..efa3701 100644 --- a/nvim/.config/nvim/plugin/fzf.vim +++ b/nvim/.config/nvim/plugin/fzf.vim @@ -34,32 +34,15 @@ command! -bang -nargs=* FzfRgHidden " make fzf use the nvim floating window globally. (weee, technology!) " -let $FZF_DEFAULT_OPTS="--layout=reverse --margin=1,2" +let $FZF_DEFAULT_OPTS="--layout=reverse " " to use fzf in a floating window only conditionally, the best approach would -" probably be call fzf#run(fzf#wrap({ 'window': 'call FloatingFZF()' })) for " every command we want to floatize -let g:fzf_layout = { 'window': 'call FloatingFZF()' } - -function! FloatingFZF() - " create a minimal nofile scratch buffer - let buf = nvim_create_buf(v:false, v:true) - call setbufvar(buf, '&signcolumn', 'no') - - " this should probably change depending on fzf command - let height = float2nr(50) - let width = float2nr(200) - " center the window in editor - let horizontal = float2nr((&columns - width) / 2) - let vertical = float2nr((&lines - height) / 2) - - let opts = { - \ 'relative': 'editor', - \ 'row': vertical, - \ 'col': horizontal, - \ 'width': width, - \ 'height': height, - \ 'style': 'minimal' - \ } - - call nvim_open_win(buf, v:true, opts) -endfunction +if has('nvim-0.4.0') || has("patch-8.2.0191") + let g:fzf_layout = { 'window': { + \ 'width': 0.7, + \ 'height': 0.7, + \ 'highlight': 'PreProc', + \ 'border': 'rounded' } } +else " Fallback to a split window + let g:fzf_layout = { "window": "silent botright 16split enew" } +endif