" fzf - the fuzzy finder of all the things

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'

let g:fzf_files_options =
  \ '--reverse ' .
  \ '--preview "(coderay {} || cat {}) 2> /dev/null | head -'.&lines.'"'
let g:fzf_layout = { 'down': '~60%' }
nnoremap <C-p> :Files<cr>
let $FZF_DEFAULT_COMMAND = 'ag -g "" --hidden --ignore .git'

" let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Todo', 'border': 'sharp' } }
" " Creates a floating window with a most recent buffer to be used
" function! CreateCenteredFloatingWindow()
"     let width = float2nr(&columns * 0.75)
"     let height = float2nr(&lines * 0.6)
"     let top = ((&lines - height) / 2) - 1
"     let left = (&columns - width) / 2
"     let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}

    " let top = "╭" . repeat("─", width - 2) . "╮"
    " let mid = "│" . repeat(" ", width - 2) . "│"
    " let bot = "╰" . repeat("─", width - 2) . "╯"
    " let lines = [top] + repeat([mid], height - 2) + [bot]
    " let s:buf = nvim_create_buf(v:false, v:true)
    " call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines)
    " call nvim_open_win(s:buf, v:true, opts)
    " set winhl=Normal:Floating
    " let opts.row += 1
    " let opts.height -= 2
    " let opts.col += 2
    " let opts.width -= 4
    " call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
    " au BufWipeout <buffer> exe 'bw '.s:buf
" endfunction

" function! OpenTerm(cmd)
"     call CreateCenteredFloatingWindow()
"     call termopen(a:cmd, { 'on_exit': function('OnTermExit') })
" endfunction

" let g:fzf_layout = { 'window': 'call CreateCenteredFloatingWindow()' }

nnoremap <leader>ga :Files app/<cr>
nnoremap <leader>gm :Files app/models/<cr>
nnoremap <leader>gv :Files app/views/<cr>
nnoremap <leader>gc :Files app/controllers/<cr>
nnoremap <leader>gy :Files app/assets/stylesheets/<cr>
nnoremap <leader>gj :Files app/assets/javascripts/<cr>
nnoremap <leader>gs :Files spec/<cr>
nnoremap <leader>. :Files %:p:h<cr>

" vim:ft=vim