diff --git a/nvim/.config/nvim/plugin/fzf.vim b/nvim/.config/nvim/plugin/fzf.vim index 77eb58a..256874a 100644 --- a/nvim/.config/nvim/plugin/fzf.vim +++ b/nvim/.config/nvim/plugin/fzf.vim @@ -1,7 +1,5 @@ " PLUGIN: fzf.vim " set some fzf defaults -" windows drops down from above, 40% of the screen -let g:fzf_layout = { 'up': '~40%' } " any Fzf command is prefixed with Fzf " this groups them nicely together, and avoids confusion when suddenly :Buffer " or :Files would appear as a command otherwise @@ -13,6 +11,7 @@ let g:fzf_colors = \ 'hl': ['fg', 'Comment'], \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'gutter': ['bg', 'Normal'], \ 'hl+': ['fg', 'Statement'], \ 'info': ['fg', 'PreProc'], \ 'border': ['fg', 'Ignore'], @@ -30,5 +29,37 @@ let g:fzf_action = { " FzfRg but also search through hidden files command! -bang -nargs=* FzfRgHidden \ call fzf#vim#grep( - \ 'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(), 1, + \ "rg --column --line-number --no-heading --color=always --smart-case --hidden --glob '!.git' ".shellescape(), 1, \ fzf#vim#with_preview(), 0) + +" make fzf use the nvim floating window globally. (weee, technology!) +" +let $FZF_DEFAULT_OPTS="--layout=reverse --margin=1,2" +" 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