summaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins/goyo.lua
blob: 7de715058071d575ac99d6c1e4d518ba55bc5975 (plain)
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
41
42
43
return {
  {
    'junegunn/goyo.vim',
    cond = function() return vim.fn.exists('g:gui_vimr') == 1 end,
    dependencies = {
      {
        'junegunn/limelight.vim',
      },
    },
    keys = {
      { '<leader>z', '<cmd>Goyo<CR>', desc = 'Goyo' },
    },
    config = function()
      local goyo_enter = function()
        vim.opt.showmode = false
        vim.opt.showcmd = false
        vim.opt.scrolloff = 999
        vim.cmd('Limelight')
      end

      local goyo_leave = function()
        vim.opt.showmode = true
        vim.opt.showcmd = true
        vim.opt.scrolloff = 5
        vim.cmd('Limelight!')
      end

      local goyo_augroup = vim.api.nvim_create_augroup('Goyo', { clear = true })
      vim.api.nvim_create_autocmd('User',
        {
          pattern = 'GoyoEnter',
          group = goyo_augroup,
          callback = goyo_enter,
        })
      vim.api.nvim_create_autocmd('User',
        {
          pattern = 'GoyoLeave',
          group = goyo_augroup,
          callback = goyo_leave,
        })
    end,
  },
}