From 01470159ef4d9495e0e69e6c9ae5f14c0373c60d Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 7 Dec 2019 15:14:39 +0530 Subject: [PATCH] nvim: init.vim: Use floating window for FZF Signed-off-by: Sanchayan Maity --- nvim/init.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/nvim/init.vim b/nvim/init.vim index c241b7e..ea9f96c 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -611,3 +611,24 @@ endfunction function! NvimGdbNoTKeymaps() tnoremap endfunction + +let $FZF_DEFAULT_OPTS='--layout=reverse' +let g:fzf_layout = { 'window': 'call FloatingFZF()' } +function! FloatingFZF() + let buf = nvim_create_buf(v:false, v:true) + 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 + \ } + + " open the new window, floating, and enter to it + call nvim_open_win(buf, v:true, opts) +endfunction