From f0f7b33446cf6985f7eed3f410df494df4aee4f2 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 10 Aug 2014 10:16:38 -0700 Subject: [PATCH] Updated Customization (markdown) --- Customization.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Customization.md b/Customization.md index 87a0b5e..177a9ba 100644 --- a/Customization.md +++ b/Customization.md @@ -1,7 +1,7 @@ ## Callbacks for GVim ```vim -function! GoyoBefore() +function! s:goyo_enter() if has('gui_running') set fullscreen set background=light @@ -21,7 +21,8 @@ function! GoyoAfter() endif endfunction -let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] +autocmd User GoyoEnter call goyo_enter() +autocmd User GoyoLeave call goyo_leave() ``` ## Disabling plugins @@ -29,12 +30,12 @@ let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] ### MiniBufExpl with `g:miniBufExplBuffersNeeded` set ```vim -function! GoyoBefore() +function! s:goyo_enter() MBEClose wincmd w endfunction -let g:goyo_callbacks = [function('GoyoBefore')] +autocmd User GoyoEnter call goyo_enter() ``` ### ZoomWin @@ -42,17 +43,18 @@ let g:goyo_callbacks = [function('GoyoBefore')] - by [EPNGH](https://github.com/EPNGH) ```vim -function! GoyoBefore() +function! s:goyo_enter() delcommand ZoomWin delcommand ZoomWin endfunction -function! GoyoAfter() +function! s:goyo_leave() command! ZoomWin call ZoomWin() command! ZoomWin call ZoomWin() endfunction -let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] +autocmd User GoyoEnter call goyo_enter() +autocmd User GoyoLeave call goyo_leave() ``` ## Ensure `:q` to quit even when Goyo is active @@ -60,14 +62,14 @@ let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] Suggested by [mm2703](https://github.com/mm2703) and [axelGschaider](https://github.com/axelGschaider) in [#16](https://github.com/junegunn/goyo.vim/issues/16) ```vim -function! GoyoBefore() +function! s:goyo_enter() let b:quitting = 0 let b:quitting_bang = 0 autocmd QuitPre let b:quitting = 1 cabbrev q! let b:quitting_bang = 1 q! endfunction -function! GoyoAfter() +function! s:goyo_leave() " Quit Vim if this is the only remaining buffer if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 if b:quitting_bang @@ -78,5 +80,6 @@ function! GoyoAfter() endif endfunction -let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] +autocmd User GoyoEnter call goyo_enter() +autocmd User GoyoLeave call goyo_leave() ```