Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mitinarseny opened this issue Jun 11, 2022 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@mitinarseny
Copy link

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...

@mitinarseny mitinarseny changed the title Bring notification windows up top when old ones expire [FEATURE] Bring notification windows up top when old ones expire Jun 11, 2022
@rcarriga rcarriga added the enhancement New feature or request label Jun 14, 2022
@AlexvZyl
Copy link

+1 For this feature!

@rcarriga
Copy link
Owner

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
Copy link

AlexvZyl commented Jul 21, 2022

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

@gegoune
Copy link

gegoune commented Jul 29, 2022

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

@rcarriga
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants