From df68c1d59594eebaf0b8944e7c495e53b3552bdc Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Wed, 12 Dec 2018 15:07:51 -0800 Subject: [PATCH] Add Neovim fullscreen helper --- .config/nvim/init.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 092a2c3..9d0c0b3 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -141,6 +141,34 @@ nmap tm :tabmove " Misc nmap h :noh +nnoremap :call Fullscreen() + +function Fullscreen() + let view = winsaveview() + let buf = winbufnr(0) + let found = 0 + + for b in win_findbuf(buf) + let tabwin = win_id2tabwin(b) + if gettabwinvar(tabwin[0], tabwin[1], "fullscreen_buf") == buf + let found = 1 + let existing_tab = tabwin[0] + let existing_win = tabwin[1] + endif + endfor + if found == 1 + if existing_tab == tabpagenr() + tabclose + else + exec "tabnext".existing_tab + endif + else + exec "tabnew +buffer".buf + let w:fullscreen_buf = buf + end + + call winrestview(view) +endfunction " Plugin configuration