rcarriga / nvim-notify

A fancy, configurable, notification manager for NeoVim
MIT License
3k stars 80 forks source link

[FEATURE] Bring notification windows up top when old ones expire #105

Closed mitinarseny closed 2 years ago

mitinarseny commented 2 years ago

Thank you for this plugin!

Is it possible to configure to bring existing notification up (to the top right of the window) when old ones expire? Because it is inconvenient to have hanging notification at the middle of the screen for 5 sec just after my LSP has been ready...

AlexvZyl commented 2 years ago

+1 For this feature!

rcarriga commented 2 years ago

OK now implemented by default for the fade_in_slide_out stages, and can easily be added to other stages using a utility function

AlexvZyl commented 2 years ago

It is very nice! I think these neovim notifications look better than any other IDE.

gegoune commented 2 years ago

@rcarriga is there an example somewhere showing how to set it up for static stage?

rcarriga commented 2 years ago

Sure, the only thing needed is to use the slot_after_previous util function which can be used for going any direction. Vertical scrolling requires setting the row value, horizontal requires setting col.

Here are the static stages adapted:

  local notify = require("notify")
  local stages_util = require("notify.stages.util")
  notify.setup({
    stages = {
      function(state)
        local next_height = state.message.height + 2
        local next_row = stages_util.available_slot(
          state.open_windows,
          next_height,
          stages_util.DIRECTION.TOP_DOWN
        )
        if not next_row then
          return nil
        end
        return {
          relative = "editor",
          anchor = "NE",
          width = state.message.width,
          height = state.message.height,
          col = vim.opt.columns:get(),
          row = next_row,
          border = "rounded",
          style = "minimal",
        }
      end,
      function(state, win)
        return {
          row = {
            stages_util.slot_after_previous(win, state.open_windows, stages_util.DIRECTION.TOP_DOWN),
            frequency = 3,
            complete = function()
              return true
            end,
          },
          col = { vim.opt.columns:get() },
          time = true,
        }
      end,
    },
  })

You can tweak frequency to adjust how quickly windows will move.

The complete option is to prevent windows from remaining open just because they're moving upwards.