nyngwang / NeoZoom.lua

A simple usecase of floating window to help you focus.
MIT License
184 stars 15 forks source link

Can try `vim.wo.winblend` #81

Closed nyngwang closed 1 year ago

nyngwang commented 1 year ago

Maybe I should enable this by default if the user might jump out of the zoom-in window. This way they can, to some degree, see the buffer behind the floating window.

effect preview:

nyngwang commented 1 year ago

Good news: just found a workaround that always work:

require('neo-zoom').setup {
  -- many options omitted.
  callbacks = {
    function ()
      if vim.wo.winhl == '' then vim.wo.winhl = 'Normal:' end -- this is the key.
    end,
    -- many callbacks omitted.
  }
} -- end of `setup`

-- define the companion `autocmd` for this effect.
vim.api.nvim_create_autocmd({ 'WinEnter' }, {
  group = curfile_augroup,
  callback = function ()
    local did_zoom = require('neo-zoom').did_zoom()
    if not did_zoom[1] then return end

    -- wait for upstream: https://github.com/neovim/neovim/issues/23542.
    if vim.api.nvim_get_current_win() == did_zoom[2]
    then vim.api.nvim_win_set_option(did_zoom[2], 'winbl', 0)
    else vim.api.nvim_win_set_option(did_zoom[2], 'winbl', 20) end
  end
})
nyngwang commented 1 year ago

This can be closed once https://github.com/neovim/neovim/pull/23555 is merged upstream.