[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!)
|
" 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
|
" 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
|
" every command we want to floatize
|
||||||
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
|
if has('nvim-0.4.0') || has("patch-8.2.0191")
|
||||||
|
let g:fzf_layout = { 'window': {
|
||||||
function! FloatingFZF()
|
\ 'width': 0.7,
|
||||||
" create a minimal nofile scratch buffer
|
\ 'height': 0.7,
|
||||||
let buf = nvim_create_buf(v:false, v:true)
|
\ 'highlight': 'PreProc',
|
||||||
call setbufvar(buf, '&signcolumn', 'no')
|
\ 'border': 'rounded' } }
|
||||||
|
else " Fallback to a split window
|
||||||
" this should probably change depending on fzf command
|
let g:fzf_layout = { "window": "silent botright 16split enew" }
|
||||||
let height = float2nr(50)
|
endif
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in a new issue