Giter VIP home page Giter VIP logo

goyo.vim's Introduction

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.

" Width
Goyo 120

" Height
Goyo x30

" Both
Goyo 120x30

" In percentage
Goyo 120x50%

" With offsets
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.

function! s:goyo_enter()
  if executable('tmux') && strlen($TMUX)
    silent !tmux set status off
    silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
  endif
  set noshowmode
  set noshowcmd
  set scrolloff=999
  Limelight
  " ...
endfunction

function! s:goyo_leave()
  if executable('tmux') && strlen($TMUX)
    silent !tmux set status on
    silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
  endif
  set showmode
  set showcmd
  set scrolloff=5
  Limelight!
  " ...
endfunction

autocmd! User GoyoEnter nested call <SID>goyo_enter()
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.

" In your Vim configuration file
" - Base color scheme
colorscheme molokai

" - Your color customizations
hi LineNr ctermfg=red guifg=red

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

" Switch to another color scheme
colorscheme Tomorrow-Night

" Switch back to the original one
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.

function! s:tweak_molokai_colors()
  " Your molokai customizations
  hi LineNr ...
  hi FoldColumn ...
endfunction

autocmd! ColorScheme molokai call s:tweak_molokai_colors()

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

goyo.vim's People

Contributors

benknoble avatar erichdongubler avatar gpanders avatar heylu avatar junegunn avatar mgaffney avatar mxdubois avatar orland0m avatar prurigro avatar starefossen avatar thirtythreeforty avatar tlvince avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goyo.vim's Issues

folding reverts to pre-goyo stage

When I enter goyo mode, unfold or fold some stuff, and then leave goyo mode, the folding comes back to what it was before I entered goyo mode.

relative line numbers

This plugin disables absolute line numbers by default, but leaves relative line numbers unchanged. In The spirit of the plugin would suggest disabling both of them together or none of them.

After using goyo, tabnew creates a nomodifiable buffer.

To reproduce:

:Goyo
:Goyo
:tabnew

Problem:
The new buffer is nomodifiable.

To fix:
Use setlocal in the two set statement in the function setup_pad.

I don't read the whle code well so I don't get why this function is called on tabnew.

Bar appears at bottom after exiting insert mode

I've got a weird bar that appears at the bottom of the screen with a single period all the way to the right of it. It doesn't show up when turning on goyo, but only after entering insert mode once, and then return to normal mode. Here's a screenshot:

screen shot 2014-06-25 at 10 48 59 am

Any idea what might be causing it or how to debug it?

Thanks!

Goyo on slower computers

I was wondering what the heaviest part of Goyo's code is. I thought maybe it would be possible to fork it with some removed functionality so as to make it run recently on slower machines (little atom netbooks).

different color for current and other paragraphs

One feature which was always a killer feature for me personally of distraction free writing environments was the usage of different font colors for the paragraph in which the cursor is operating and the other paragraphs. Normally it works the way that the paragraph with the cursor (in which I am writing) maintains the normal font color while the other paragraphs turn into a grey that does not raise attention anymore.

I wonder if it is possible to implement something like this by using the conceal feature or cursorline feature?

local settings for already opened buffers

After `:Goyo``, the local settings of already openend buffers are not reset. For example, the lightline statusline will rest active in all the opened buffers other than the currently edited one.

Is there a way to coerce the current buffer's setttings onto all the other open buffers?

:q only disables Goyo

Hi,

First of all, this is an excellent plugin. There's just one minor problem I'm having with it, it's that when Goyo is active :q doesn't quit but simply closes Goyo. Therefore two quits are needed to really quit. I've "fixed" it this way but I'm thinking maybe there is a cleaner way to do it?

" Quitting whether Goyo is active or not
ca wq :w<cr>:call Quit()<cr>
ca q :call Quit()<cr>
function! Quit()
    if winnr('$') > 3
        Goyo
    endif
    quit
endfunction

What do you think?

Thank you and best regards,
Maxime.

Goyo and line number toggle

Hi!

It often makes sense to toggle between relative and absolute line numbers, i. g. using

autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber

Therefore, I updated goyo.vim as follows.

  augroup goyo
    autocmd!
    autocmd BufWinLeave <buffer> call s:goyo_off()
    autocmd TabLeave    *        call s:goyo_off()
    autocmd VimResized  *        call s:resize_pads()
    autocmd ColorScheme *        call s:tranquilize()
    autocmd InsertEnter * :set nonumber
    autocmd InsertLeave * :set norelativenumber
  augroup END

Do you think this makes sense as a general enhancement?

Override default commands for Goyo

Disallow commands that break Goyo layout

nnoremap <C-W>R <nop>
nnoremap <C-W>H <nop>
nnoremap <C-W>J <nop>
nnoremap <C-W>K <nop>
nnoremap <C-W>L <nop>
nnoremap <C-W>| <nop>
nnoremap <C-W>_ <nop>
  • Only when they are not mapped to something else
  • Restore on exit

Override resizing commands

  • <C-W>>
  • <C-W><
  • <C-W>+
  • <C-W>-

set goyo mode only for markdown files ?

Is there a way (or if there isn't, I'd like to suggest it) to enable goyo mode only for markdown files and disable it when switching to some other files ?
I tried au Filetype markdown Goyo but it doesn't work, doesn't have any effect.

winminheight error

I'm getting this error when running :Goyo

Error detected while processing function <SNR>62_goyo..<SNR>62_goyo_on:
line   56:
E591: 'winheight' cannot be smaller than 'winminheight': winheight=1

I assume it's because I have these lines setting those settings in my vimrc

Use autoload-ing

Thank you for this plugin!

Are you interested in making goyo.vim use vim's autoload-ing? I've modified goyo.vim here https://github.com/edkolev/goyo.vim. Basically, I just

  • moved plugin/goyo.vim => autoload/goyo.vim
  • changed the command Goyo call s:goyo(..) => command Goyo call goyo#execute(..)

I haven't run into any issues yet, but I suspect there may be some lurking around. In particular, I suspect some autocommands may not be working properly.

BTW yes, I know this is completely unnecessary if you're using a lazy-loading plugin manager like vim-plug :)

Again, thanks!

Hide signs

It would be a nice feature to hide signs too when in distraction free mode.

Window scrolls as text reaches margin

Is there a way to prevent the following horizontal scrolling? (Ignore the completion flickers; that's YCM going wild).

goyo

(NB, I also notice a few seconds delay after Goyo is called. Is this expected?).

SignColumn color not restored when leaving Goyo

I noticed that the SignColumn's background is set wrong when leaving Goyo.

Before entering Goyo:

screen shot 2015-01-21 at 6 57 52 pm

After leaving Goyo

screen shot 2015-01-21 at 6 58 14 pm

I was able to help a little bit by re-setting the SignColumn color upon leaving Goyo, but it only affected rows where the gutter wasn't being used; any rows that actually were making use of the gutter (for Git status, for example) remained the wrong color.

Making vim fullscreen and back to window hides buffer.

Steps to reproduce:

  1. Open vim in windowed-mode
  2. Execute :Goyo
  3. Make vim fullscreen
  4. Make vim windowed

After fullscreen, the buffer is aligned left and when vim is returned to window, the buffer stays outside the screen.

This happens in both gvim and vim (with urxvt). VimResized-event works as expected.

Statusline visibility on urxvt

I'm using lightline and already tried your trick in customization page. But I still can't hide statusline when I run goyo.
2014-04-23-205346_1366x768_scrot

Toggling goyo on and off ignores custom colors?

I'm not sure if this is a bug in goyo, or if I should be doing something differently. I'm using this color scheme, but I have a couple of adjustments in my .vimrc:

highlight LineNr ctermbg=234
highlight NonText ctermbg=234

Here is a screenshot before toggling Goyo:

screen shot 2014-07-15 at 3 45 12 pm

After toggling:

screen shot 2014-07-15 at 3 45 31 pm

After toggling off:
screen shot 2014-07-15 at 3 46 13 pm

It looks like it's reloading the color scheme, but not my adjustments. Can this be changed in goyo? Or is there another place I could put these two lines to have it work correctly?

Leaves Airline's tabline visible with only one buffer/tab

This is minor, and I'll see if I can find a workaround myself when I have a few minutes to grok the Goyo code, but just wanted to make note when I saw it.

I use the following settings for Airline:

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline#extensions#tabline#show_tab_type = 0
let g:airline#extensions#tabline#tab_min_count = 2

Basically this means show a line for tabs at the top, only for real tabpages, and only when there is more than one. If I edit a single file in a Vim session and toggle Goyo on and off, the Airline tabline is left visible for only one tab.

Width becomes wrong from fullscreen mode in linux

If I open gvim, go to fullscreen mode, issue :Goyo, then the window with becomes much less than the default 80. If I instead issue :Goyo before I go to fullscreen mode, then it works as expected.

My vimrc settings are:

let g:goyo_margin_top = 0
let g:goyo_margin_bottom = 0
map <F8> :Goyo<cr>

function! s:goyo_enter()
  let b:quitting = 0
  let b:quitting_bang = 0
  autocmd QuitPre <buffer> let b:quitting = 1
  cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
function! s:goyo_leave()
  if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
    if b:quitting_bang
      qa!
    else
      qa
    endif
  endif
endfunction

autocmd! User GoyoEnter
autocmd  User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave
autocmd  User GoyoLeave call <SID>goyo_leave()

Note that the current workaround works (although it should not be necessary):

autocmd User GoyoEnter Goyo 80

Can't open a new tab when Goyo is active

I'm having another minor issue with Goyo. I have my Vim set up to open new files in tabs. Oftentimes, when I'm writing, I want to quickly check something out in another file. But when Goyo is on, if I do that, all it will do is to disable Goyo. I have to open the file once again to actually load it and to reenable Goyo when I'm done with it and back to my writing tab. Do you think there would be a way to fix this?

Thanks again for a great plugin!

Maxime

Random '.' at the bottom right corner of Goyo mode

screen shot 2015-02-21 at 2 39 56 am

I have this really annoying period character in the bottom right of my screen... I'm sure it's something on my end. Do you have any idea how I could troubleshoot this?

Only shows up in Goyo, here's my vimrc, if that helps.

Typing lag

I've noticed that when using Goyo I often experience fairly extreme typing lag (sometime up to around five seonice discussions before words appear on the screen) with documents of any substantial length (say 10000 words or more). Is this an expected problem?

I write mainly in pandoc-flavor markdown and use the vim-pandoc syntax highlighting plugin.

ZoomWin incompatability

This plugin understandbly does not play well together with ZoomWin. If one accidently hits a key mapped to the ZoomWin command, this gives a slew of error messages.

Perhaps the ZoomWin should be disabled by default.

Goyo was not centering the buffer horizontally

I was having issues with Goyo not centering the buffer horizontally. I learned it was being caused by these two commands tucked away in my vim config:

set splitbelow
set splitright

These naturally affect the way windows are split, which Goyo uses to create the pad scratch buffers for horizontal centering. Removing them "fixed" the Goyo issue.

Terminal vim uses gvim colorscheme on exit

Hi, thanks for this excellent plugin.
Though I'm not sure if it's me, when i exit the Goyo mode in terminal vim, my colorscheme changed to what's set up for gvim. I guess it has something to do with my vimrc, since i overwrite the highlight of some groups,
Would it be possible to reload vimrc rather than only the colorscheme? maybe i should add a keybiding to restore the original colors.

Scrolloff settings seems not to work in Goyo

I'm trying to set up a writing environment as close to iA Writer as possible, and Goyo gets me about 98% of the way there. The one thing that I can't get right, and the one thing that is actually important to me, is that the current line remains centered on the screen. I've heard about the

set scrolloff=999

trick, but it doesn't seem to be working. No what I do, it seems that my scrolloff setting stays around 3 or so. Is there some trick to getting it to play nicely with Goyo?

cursorline and columnline

Columnline is not deactivated, but merely made invisible. This looks strange when the cursor line is enabled, leaving a light square at their crossing.

How to add the width / margin configs in .vimrc?

In the readme, it is just stated that configuration is done with

g:goyo_width (default: 80)
g:goyo_margin_top (default: 4)
g:goyo_margin_bottom (default: 4)
g:goyo_linenr (default: 0)

... but for me as a non-vim-expert, I'm unsure about how to set this?

I've tried with

let g:goyo_width = 96
let g:goyo_margin_top = 0
let g:goyo_margin_bottom = 0
let g:goyo_linenr = 0

... which does not give errors, but does not seem to take effect either ...

Any help appreciated!

Running :Goyo prompts winwidth error

Error detected while processing function <SNR>53_goyo..<SNR>53_goyo_on:
line   63:
E592: 'winwidth' cannot be smaller than 'winminwidth': winwidth=1

got any clues? the irony is that once I escape out the error message, it seems to work just fine.

Display width issue

One character less than the specified width is displayed. This truncates the last character on a line if you $, and also hides the extends listchar for long lines.

For example: Goyou 30 will display 29 characters only

fullscreen

The set fullscreen option seems proprietary to MacVim. There is the FullScreen command of the plugin vim-shell, which seems to be OS independent.

It works just fine when toggling it s:goyo_before(), but messes slightly up when disabling it again in s:goyo_after(). The momentary workaround is two invoke it three times instead, which usually fixes the window setup.

In all these new issues raised, I'm just scrupulously mentioning one by one what struck me when trying your wonderful plugin. It might be of help to others.

Quit Goyo *and* vim with :q

Hey @junegunn. Thanks a lot for writing Goyo! I'm using it on a daily basis (e.g. with Mutt). One little thing keeps bugging me:

Is there a way to keep Goyo from grabbing the :q shortcut? At the moment I have to hit :q twice to get out of Goyo-mode and quit vim.

issues with NrrwRgn and Gundo

Hello,
I know of the possibility of disabling them when using Goyo but i really want to use it along with those tools, so are there any hints on how achieving it or it's not a configuration matter?

Prevent Goyo to close on `bd`

hey @junegunn, first of all, thanks so much for Goyo.
It is all I ever wanted in a text editor and I am happy I found this for Vim.

There is one small thing which is bothering a little bit.
That happens when calling :Goyo, I am taken to Goyo mode as expected, so all my tabs are affect. That's all great, however, when closing one tab with bd Goyo closes and the next tab previously open is now back to normal vim mode.

How do I prevent Goyo to close when closing a tab with bd?

thanks in advance

Question: Activate Goyo doesn't disable NERDTree

Mac OS X 10.9.4, MacVim 7.4, installed NERDTree and NERDTreeTabs plugins

When activate Goyo, NERDTree still exists, wanner know it's a problem of myself or not. However, NERDTree is reopened after quitting if been manually disabled in Goyo mode. Thanks!

Statuslines visible when using powerline/airline

It's awesome to see what you've built here, and I love how everything is properly centered. However, this doesn't work well with users of powerline/airline.

The statusline is hidden for the primary window, but remains visible in all the scratch windows. Setting laststatus to 0 doesn't help either.

powerline issue

window navigation

Hello,

In Goyo mode, Is there a way to avoid navigating to one of those windows surrounding the central one where text editing takes place?

Go back to the correct tab when disabling Goyo

If you have more than one tab open and you enable Goyo in any of them but the last one, if you then disable Goyo, Vim goes back to the last tab of the list, not to the tab you were working on. I have fixed it this way but I don't know if there's a cleaner way to do it?

function! s:goyo_before()
    let g:tab_number = tabpagenr()-1
endfunction

function! s:goyo_after()
    exe 'norm '.g:tab_number.'gt'
endfunction

Some problems with tmux and Airline

First, thanks for goyo.Today, I installed goyo using vundle plugin.and have configured vimrc as follows:

function! g:goyo_before()
  silent !tmux set status off
endfunction

function! g:goyo_after()
  silent !tmux set status on
endfunction

let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]

but when I exit Goyo,get the error messages:

Error detected while processing function <SNR>56_blank..<SNR>56_goyo_off:
line   50:
E492: Not an editor command:     AirlineRefreshset option: status -> on

Press ENTER or type command to continue

after I type any command, my status bar looks like this:
workspace 1_025

before adding Goyo,it looks like as follows:
workspace 1_026

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.