[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.
This commit is contained in:
parent
3575c147b2
commit
a390d14390
1 changed files with 10 additions and 27 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue