项目作者: junegunn

项目描述 :
:tulip: Distraction-free writing in Vim
高级语言: Vim script
项目地址: git://github.com/junegunn/goyo.vim.git
创建时间: 2013-11-30T11:50:38Z
项目社区:https://github.com/junegunn/goyo.vim

开源协议:

下载


goyo.vim (고요)

Distraction-free writing in Vim.

(Color scheme: seoul256)

Best served with limelight.vim.

Installation

Use your favorite plugin manager.

  • vim-plug
    1. Add Plug 'junegunn/goyo.vim' to .vimrc
    2. Run :PlugInstall

Usage

  • :Goyo
    • Toggle Goyo
  • :Goyo [dimension]
    • Turn on or resize Goyo
  • :Goyo!
    • Turn Goyo off

The window can be resized with the usual [count]<CTRL-W> + >, <, +,
- keys, and <CTRL-W> + = will resize it back to the initial size.

Dimension expression

The expected format of a dimension expression is
[WIDTH][XOFFSET][x[HEIGHT][YOFFSET]]. XOFFSET and YOFFSET should be
prefixed by + or -. Each component can be given in percentage.

  1. " Width
  2. Goyo 120
  3. " Height
  4. Goyo x30
  5. " Both
  6. Goyo 120x30
  7. " In percentage
  8. Goyo 120x50%
  9. " With offsets
  10. Goyo 50%+25%x50%-25%

Configuration

  • g:goyo_width (default: 80)
  • g:goyo_height (default: 85%)
  • g:goyo_linenr (default: 0)

Callbacks

By default, vim-airline,
vim-powerline,
powerline,
lightline.vim,
vim-signify,
and 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 set up custom routines
to be triggered on GoyoEnter and GoyoLeave events.

  1. function! s:goyo_enter()
  2. if executable('tmux') && strlen($TMUX)
  3. silent !tmux set status off
  4. silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
  5. endif
  6. set noshowmode
  7. set noshowcmd
  8. set scrolloff=999
  9. Limelight
  10. " ...
  11. endfunction
  12. function! s:goyo_leave()
  13. if executable('tmux') && strlen($TMUX)
  14. silent !tmux set status on
  15. silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
  16. endif
  17. set showmode
  18. set showcmd
  19. set scrolloff=5
  20. Limelight!
  21. " ...
  22. endfunction
  23. autocmd! User GoyoEnter nested call <SID>goyo_enter()
  24. autocmd! User GoyoLeave nested call <SID>goyo_leave()

More examples can be found here:
Customization

FAQ

“My custom colors are lost when I exit Goyo!”

That’s because Goyo restores the base color scheme using :colorscheme CURRENT_COLOR_SCHEME command on exit, and it resets your tweaks. Goyo can try
to remember all your customizations and restore them on exit, but it doesn’t,
because there is a better, more robust way to address the issue.

The real problem here is that you will lose all your changes when you switch
between color schemes, even when you’re not using Goyo.

  1. " In your Vim configuration file
  2. " - Base color scheme
  3. colorscheme molokai
  4. " - Your color customizations
  5. hi LineNr ctermfg=red guifg=red

It works, only when you stick to a single color scheme. When you switch
between color schemes,

  1. " Switch to another color scheme
  2. colorscheme Tomorrow-Night
  3. " Switch back to the original one
  4. colorscheme molokai

And all the customizations you have made are lost.

What you should to do is to customize the colors on autocmd ColorScheme,
which is automatically triggered whenever you change color schemes.

  1. function! s:tweak_molokai_colors()
  2. " Your molokai customizations
  3. hi LineNr ...
  4. hi FoldColumn ...
  5. endfunction
  6. autocmd! ColorScheme molokai call s:tweak_molokai_colors()
  7. colorscheme molokai

Inspiration

Pros.

  1. Works well with splits. Doesn’t mess up with the current window arrangement
  2. Works well with popular statusline plugins
  3. Prevents accessing the empty windows around the central buffer
  4. Can be closed with any of :q[uit], :clo[se], :tabc[lose], or :Goyo
  5. Can dynamically change the width of the window
  6. Adjusts its colors when color scheme is changed
  7. Realigns the window when the terminal (or window) is resized or when the size
    of the font is changed
  8. Correctly hides colorcolumns and Emojis in statusline
  9. Highly customizable with callbacks

License

MIT