13 Commits
1.5.3 ... 1.6.0

Author SHA1 Message Date
Junegunn Choi
9e04ccdb9d Promote the use of User events instead of g:goyo_callbacks
This does not break backward compatibility, g:goyo_callbacks is still
allowed.
2014-08-11 02:16:31 +09:00
Junegunn Choi
da67185e4a Fix error when vim-signify is not installed (#39) 2014-07-26 23:50:54 +09:00
Junegunn Choi
e2c59124cb Merge pull request #39 from prurigro/toggle-signify
Added vim-signify to the list of toggled plugins
2014-07-26 23:46:18 +09:00
Kevin MacMartin
27ea8fa731 Following junegunn's advice, both checks are made together 2014-07-23 23:19:04 -04:00
Kevin MacMartin
ae04751e09 Added git-signify to the list of toggled plugins 2014-07-20 23:39:13 -04:00
Junegunn Choi
85c202264e Update callback examples in README 2014-07-21 01:42:04 +09:00
Junegunn Choi
2bc0604530 Update README 2014-07-05 23:18:51 +09:00
Junegunn Choi
549f865ab4 Add Goyo! command for turning it off 2014-07-05 23:13:13 +09:00
Junegunn Choi
a2b772fe58 Never allow cursor on pad windows 2014-07-04 02:56:46 +09:00
Junegunn Choi
7e318dbcce Fix winminwidth issue (#35) 2014-07-03 23:37:29 +09:00
Junegunn Choi
f303dc9307 Best served with limelight.vim 2014-07-03 01:41:31 +09:00
Junegunn Choi
ad87a5b35a Doc update: Function name must start with a capital
see: ftp://ftp.vim.org/pub/vim/patches/7.4/7.4.260
2014-06-03 10:14:27 +09:00
Junegunn Choi
5bea57ebf5 Retain cursor position on close (#27)
This however doesn't work if Goyo window is closed with `:q`
2014-04-28 12:29:33 +09:00
2 changed files with 67 additions and 25 deletions

View File

@@ -7,6 +7,8 @@ Distraction-free writing in Vim.
(Color scheme: [seoul256](https://github.com/junegunn/seoul256.vim))
Best served with [limelight.vim](https://github.com/junegunn/limelight.vim).
Installation
------------
@@ -19,12 +21,17 @@ Use your favorite plugin manager.
Usage
-----
`:Goyo [width]`
- `:Goyo`
- Toggle Goyo
- `:Goyo [width]`
- Turn on or resize Goyo
- `:Goyo!`
- Turn Goyo off
You might want to define a map for toggling it:
You might map this to a key combo in your `.vimrc` like so:
```vim
"" Map Goyo toggle to <Leader> + spacebar
nnoremap <Leader><Space> :Goyo<CR>
nnoremap <Leader>G :Goyo<CR>
```
Configuration
@@ -34,45 +41,49 @@ 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
By default, [vim-airline](https://github.com/bling/vim-airline),
[vim-powerline](https://github.com/Lokaltog/vim-powerline),
[powerline](https://github.com/Lokaltog/powerline),
[lightline.vim](https://github.com/itchyny/lightline.vim), and
[vim-gitgutter](https://github.com/airblade/vim-gitgutter) are temporarily
[lightline.vim](https://github.com/itchyny/lightline.vim),
[vim-signify](https://github.com/mhinz/vim-signify),
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! s:goyo_before()
function! s:goyo_enter()
silent !tmux set status off
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_after()
function! s:goyo_leave()
silent !tmux set status on
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
let g:goyo_callbacks = [function('s:goyo_before'), function('s:goyo_after')]
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:
[Customization](https://github.com/junegunn/goyo.vim/wiki/Customization)
(If you get the error `Unknown function: s:goyo_before`, define the callback
functions as globals. e.g. `g:goyo_before`)
Inspiration
-----------

View File

@@ -64,7 +64,7 @@ function! s:setup_pad(bufnr, vert, size)
execute win . 'wincmd w'
execute (a:vert ? 'vertical ' : '') . 'resize ' . max([0, a:size])
augroup goyop
autocmd WinEnter <buffer> call s:blank()
autocmd WinEnter,CursorMoved <buffer> call s:blank()
augroup END
" To hide scrollbars of pad windows in GVim
@@ -127,6 +127,7 @@ function! s:goyo_on(width)
\ { 'laststatus': &laststatus,
\ 'showtabline': &showtabline,
\ 'fillchars': &fillchars,
\ 'winminwidth': &winminwidth,
\ 'winwidth': &winwidth,
\ 'winminheight': &winminheight,
\ 'winheight': &winheight,
@@ -145,6 +146,12 @@ function! s:goyo_on(width)
silent! GitGutterDisable
endif
" vim-signify
let t:goyo_disabled_signify = exists('b:sy') && b:sy.active
if t:goyo_disabled_signify
SignifyToggle
endif
" vim-airline
let t:goyo_disabled_airline = exists("#airline")
if t:goyo_disabled_airline
@@ -177,10 +184,10 @@ function! s:goyo_on(width)
endif
" Global options
set winwidth=1
let &winheight = max([&winminheight, 1])
set winminheight=1
set winheight=1
set winminwidth=1 winwidth=1
set laststatus=0
set showtabline=0
set noruler
@@ -217,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()
@@ -241,9 +249,12 @@ function! s:goyo_off()
let goyo_revert = t:goyo_revert
let goyo_disabled_gitgutter = t:goyo_disabled_gitgutter
let goyo_disabled_signify = t:goyo_disabled_signify
let goyo_disabled_airline = t:goyo_disabled_airline
let goyo_disabled_powerline = t:goyo_disabled_powerline
let goyo_disabled_lightline = t:goyo_disabled_lightline
let goyo_orig_buffer = t:goyo_master
let [line, col] = [line('.'), col('.')]
if tabpagenr() == 1
tabnew
@@ -252,7 +263,14 @@ function! s:goyo_off()
endif
tabclose
execute 'normal! '.s:orig_tab.'gt'
if winbufnr(0) == goyo_orig_buffer
execute printf('normal! %dG%d|', line, col)
endif
let wmw = remove(goyo_revert, 'winminwidth')
let ww = remove(goyo_revert, 'winwidth')
let &winwidth = ww
let &winminwidth = wmw
let wmh = remove(goyo_revert, 'winminheight')
let wh = remove(goyo_revert, 'winheight')
let &winheight = max([wmh, 1])
@@ -268,6 +286,12 @@ function! s:goyo_off()
silent! GitGutterEnable
endif
if goyo_disabled_signify
silent! if !b:sy.active
SignifyToggle
endif
endif
if goyo_disabled_airline && !exists("#airline")
AirlineToggle
silent! AirlineRefresh
@@ -289,22 +313,29 @@ function! s:goyo_off()
if exists('g:goyo_callbacks[1]')
call g:goyo_callbacks[1]()
endif
silent! doautocmd User GoyoLeave
endfunction
function! s:goyo(...)
function! s:goyo(bang, ...)
let width = a:0 > 0 ? a:1 : get(g:, 'goyo_width', 80)
if exists('#goyo') == 0
call s:goyo_on(width)
elseif a:0 > 0
let t:goyo_width = width
call s:resize_pads()
if a:bang
if exists('#goyo')
call s:goyo_off()
endif
else
call s:goyo_off()
if exists('#goyo') == 0
call s:goyo_on(width)
elseif a:0 > 0
let t:goyo_width = width
call s:resize_pads()
else
call s:goyo_off()
end
end
endfunction
command! -nargs=? Goyo call s:goyo(<args>)
command! -nargs=? -bar -bang Goyo call s:goyo('<bang>' == '!', <args>)
let &cpo = s:cpo_save
unlet s:cpo_save