Skip to content

Instantly share code, notes, and snippets.

@eduardoarandah
Last active July 9, 2020 23:08
Show Gist options
  • Save eduardoarandah/ec65038531d85f431dbf55fdcf2fcbdd to your computer and use it in GitHub Desktop.
Save eduardoarandah/ec65038531d85f431dbf55fdcf2fcbdd to your computer and use it in GitHub Desktop.
neovim easy buffer movement. FZF floating window and vim airline to see them
" This mapping combination with FZF feels great!
" See how this works: https://gfycat.com/wellgroomedofficialblueandgoldmackaw
" Buffers change with index and middle
nnoremap <C-j> :bn<CR>
nnoremap <C-k> :bp<CR>
" Index finger to filter lines in all buffers with jump to line
nnoremap <leader>j :Lines<CR>
" Middle finger to go back to alternate buffer
nnoremap <leader>k :b#<CR>
" Find buffer
nnoremap <C-f> :Buffers<CR>
" Using floating windows of Neovim to start fzf
if has('nvim')
let $FZF_DEFAULT_OPTS .= ' --border --margin=0,2'
function! FloatingFZF()
let width = float2nr(&columns * 0.9)
let height = float2nr(&lines * 0.6)
let opts = { 'relative': 'editor',
\ 'style': 'minimal',
\ 'row': (&lines - height) / 2,
\ 'col': (&columns - width) / 2,
\ 'width': width,
\ 'height': height }
let win = nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
call setwinvar(win, '&winhighlight', 'NormalFloat:Normal')
endfunction
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
else
let g:fzf_layout = { 'window': 'enew' }
endif
""""""""""""""""""""""""""""
" vim-airline to see your buffers and look nice
""""""""""""""""""""""""""""
Plug 'vim-airline/vim-airline'
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" Show terminal buffers
let g:airline#extensions#tabline#ignore_bufadd_pat = 'defx|gundo|nerd_tree|startify|tagbar|undotree|vimfiler'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment