diff --git a/README.md b/README.md index 013b468..77efa78 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,10 @@ Usage - `:Goyo!` - Turn Goyo off -You might map this to a key combo in your `.vimrc` like so: +You might want to define a map for toggling it: + ```vim -"" Map Goyo toggle to + spacebar -nnoremap :Goyo +nnoremap G :Goyo ``` Configuration @@ -41,7 +41,6 @@ Configuration - `g:goyo_margin_top` (default: 4) - `g:goyo_margin_bottom` (default: 4) - `g:goyo_linenr` (default: 0) -- `g:goyo_callbacks` ([before_funcref, after_funcref]) ### Callbacks @@ -54,11 +53,11 @@ and [vim-gitgutter](https://github.com/airblade/vim-gitgutter) are temporarily disabled while in Goyo mode. If you have other plugins that you want to disable/enable, or if you want to -change the default settings of Goyo window, you can define before and after -callbacks as follows in your .vimrc. +change the default settings of Goyo window, you can set up custom routines +to be triggered on `GoyoEnter` and `GoyoLeave` events. ```vim -function! GoyoBefore() +function! s:goyo_enter() silent !tmux set status off set noshowmode set noshowcmd @@ -67,7 +66,7 @@ function! GoyoBefore() " ... endfunction -function! GoyoAfter() +function! s:goyo_leave() silent !tmux set status on set showmode set showcmd @@ -76,7 +75,10 @@ function! GoyoAfter() " ... endfunction -let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] +autocmd! User GoyoEnter +autocmd! User GoyoLeave +autocmd User GoyoEnter call goyo_enter() +autocmd User GoyoLeave call goyo_leave() ``` More examples can be found here: diff --git a/plugin/goyo.vim b/plugin/goyo.vim index 5308326..4f8ef87 100644 --- a/plugin/goyo.vim +++ b/plugin/goyo.vim @@ -224,6 +224,7 @@ function! s:goyo_on(width) if exists('g:goyo_callbacks[0]') call g:goyo_callbacks[0]() endif + silent! doautocmd User GoyoEnter endfunction function! s:goyo_off() @@ -312,6 +313,7 @@ function! s:goyo_off() if exists('g:goyo_callbacks[1]') call g:goyo_callbacks[1]() endif + silent! doautocmd User GoyoLeave endfunction function! s:goyo(bang, ...)