mirror of
https://github.com/junegunn/goyo.vim.git
synced 2025-11-13 13:53:50 -05:00
Promote the use of User events instead of g:goyo_callbacks
This does not break backward compatibility, g:goyo_callbacks is still allowed.
This commit is contained in:
20
README.md
20
README.md
@@ -28,10 +28,10 @@ Usage
|
|||||||
- `:Goyo!`
|
- `:Goyo!`
|
||||||
- Turn Goyo off
|
- 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
|
```vim
|
||||||
"" Map Goyo toggle to <Leader> + spacebar
|
nnoremap <Leader>G :Goyo<CR>
|
||||||
nnoremap <Leader><Space> :Goyo<CR>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
@@ -41,7 +41,6 @@ Configuration
|
|||||||
- `g:goyo_margin_top` (default: 4)
|
- `g:goyo_margin_top` (default: 4)
|
||||||
- `g:goyo_margin_bottom` (default: 4)
|
- `g:goyo_margin_bottom` (default: 4)
|
||||||
- `g:goyo_linenr` (default: 0)
|
- `g:goyo_linenr` (default: 0)
|
||||||
- `g:goyo_callbacks` ([before_funcref, after_funcref])
|
|
||||||
|
|
||||||
### Callbacks
|
### Callbacks
|
||||||
|
|
||||||
@@ -54,11 +53,11 @@ and [vim-gitgutter](https://github.com/airblade/vim-gitgutter) are temporarily
|
|||||||
disabled while in Goyo mode.
|
disabled while in Goyo mode.
|
||||||
|
|
||||||
If you have other plugins that you want to disable/enable, or if you want to
|
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
|
change the default settings of Goyo window, you can set up custom routines
|
||||||
callbacks as follows in your .vimrc.
|
to be triggered on `GoyoEnter` and `GoyoLeave` events.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
function! GoyoBefore()
|
function! s:goyo_enter()
|
||||||
silent !tmux set status off
|
silent !tmux set status off
|
||||||
set noshowmode
|
set noshowmode
|
||||||
set noshowcmd
|
set noshowcmd
|
||||||
@@ -67,7 +66,7 @@ function! GoyoBefore()
|
|||||||
" ...
|
" ...
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! GoyoAfter()
|
function! s:goyo_leave()
|
||||||
silent !tmux set status on
|
silent !tmux set status on
|
||||||
set showmode
|
set showmode
|
||||||
set showcmd
|
set showcmd
|
||||||
@@ -76,7 +75,10 @@ function! GoyoAfter()
|
|||||||
" ...
|
" ...
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')]
|
autocmd! User GoyoEnter
|
||||||
|
autocmd! User GoyoLeave
|
||||||
|
autocmd User GoyoEnter call <SID>goyo_enter()
|
||||||
|
autocmd User GoyoLeave call <SID>goyo_leave()
|
||||||
```
|
```
|
||||||
|
|
||||||
More examples can be found here:
|
More examples can be found here:
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ function! s:goyo_on(width)
|
|||||||
if exists('g:goyo_callbacks[0]')
|
if exists('g:goyo_callbacks[0]')
|
||||||
call g:goyo_callbacks[0]()
|
call g:goyo_callbacks[0]()
|
||||||
endif
|
endif
|
||||||
|
silent! doautocmd User GoyoEnter
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:goyo_off()
|
function! s:goyo_off()
|
||||||
@@ -312,6 +313,7 @@ function! s:goyo_off()
|
|||||||
if exists('g:goyo_callbacks[1]')
|
if exists('g:goyo_callbacks[1]')
|
||||||
call g:goyo_callbacks[1]()
|
call g:goyo_callbacks[1]()
|
||||||
endif
|
endif
|
||||||
|
silent! doautocmd User GoyoLeave
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:goyo(bang, ...)
|
function! s:goyo(bang, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user