aboutsummaryrefslogtreecommitdiff
path: root/vim/.vim/autoload/dyamon/goyo.vim
blob: 45a122b404d9c425c54c080e075d447c0d41a6a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
" Autoload functions for Goyo plugin.
" Last Changed: 2021-02-15
" Author: Federico Igne <>
" License: This file is placed in the public domain.

function! dyamon#goyo#enter() abort
    " Tmux zoom on Goyo toggle.
    " `#` needs to be escaped to avoid expansion into alternate file.
    "silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
    " Hide all statusline features
    setlocal noruler noshowcmd laststatus=0
    " Change the line number column color
    highlight LineNr ctermbg=0
    " Disable `colorcolumn` when in Goyo.
    let b:guides = 1
    " Simulate re-focus on Goyo windows (a focus event is not triggered
    " on Goyo enter apparently)
    call dyamon#guides#off()
    call dyamon#guides#on()
    " Goyo is enabled. This is also used to limit the statusbar updates
    " during focus/unfocus events.
    let b:disable_statusline = 1
endfunction

function! dyamon#goyo#leave() abort
    " Goyo is disabled
    unlet b:disable_statusline
    " Re-enable guides
    unlet b:guides
    " Untoggle Tmux Zoom if necessary
    " `#` needs to be escaped to avoid expansion into alternate file.
    "silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
    " Reset statusline
    setlocal ruler showcmd laststatus=2
    " Reset line number column color
    highlight LineNr ctermbg=18
    " Reset statusline (focused)
    call dyamon#statusline#focus()
endfunction