Skip to content

feat: configurable notification level #1693

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

Merged
merged 3 commits into from
Oct 31, 2022

Conversation

kylo252
Copy link
Collaborator

@kylo252 kylo252 commented Oct 27, 2022

add notify.default_level to setup opts

fixes #1502

@ssiyad
Copy link
Contributor

ssiyad commented Oct 27, 2022

Shouldn't default_level be something like minimum_level?

@kylo252 kylo252 mentioned this pull request Oct 28, 2022
@alex-courtis
Copy link
Member

Shouldn't default_level be something like minimum_level?

threshold was proposed: #1502 (comment)

I like the use of the notify table as it will allow future additions like #1697

}

do
local has_notify, notify_plugin = pcall(require, "notify")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1697 will fit nicely in here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

threshold was proposed: #1502 (comment)

do you mean we should use threshold instead?

#1697 will fit nicely in here.

yeah, I had actually wanted to make the use of nvim-notify to be optional as well, but couldn't settle on a intuitive name for the option so I skipped it.

maybe something like this

  notify = {
	---@type function|string
	handler = vim.notify,
    ---@type enum
    default_level = vim.log.levels.INFO,
  },

tho I still think it's better to leave it for a separate PR :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, separate. This leave the door open nicely.

add `notify.threshold` to setup opts
@kylo252 kylo252 requested review from kyazdani42 and alex-courtis and removed request for kyazdani42 and alex-courtis October 29, 2022 08:32
@alex-courtis
Copy link
Member

The level does not apply to legacy / config warnings. Raised #1700 to be completed in a follow up PR.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works beautifully. Handles a variety of bad setup options.

I'm still not happy with the inconsistent pattern for notify.lua. Please git apply 0001-feat-configurable-notification-level-consistent-setu.patch, test and commit.

0001-feat-configurable-notification-level-consistent-setu.patch.txt

Many thanks for taking the initiative and putting in the work: the UX is greatly improved.

{ name = "error", level = vim.log.levels.ERROR },
}

do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect to see this block inside the setup function. Is it for the case of notifications before setup?

Please leave a comment explaining.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it needs to be done this way in case the module gets called before the setup function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in #1693 (comment), I prefer not dealing with that API here since it's a bit more nuanced than what's suggested in https://github.com/nvim-tree/nvim-tree.lua/files/9894883/0001-feat-configurable-notification-level-consistent-setu.patch.txt

Problems with the proposed changes:

  • it's not reusing the config.notify table (which was created for this specific purpose)
  • it's hard-coding the notify handler regardless
  • users can already override vim.notify so there's no point in creating yet another redirection layer on top of it
  • and it's (highly) unlikely that a user would have two separate wrappers for vim.notify at the same time

my idea of an alternative source was something similar to how |vim.lsp.util.get_progress_messages()| works, where a status message can be displayed anywhere.

I'm happy to create a separate PR to track that :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair enough. This is an unusual module.

We will be revisiting this shortly anyway.


*nvim-tree.notify.default_level*
Specify notification level, uses the values from |vim.log.levels|
Type: `enum`, Default: `vim.log.levels.INFO`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO is a good, if verbose, default that doesn't change current behaviour.

Perhaps we can indicate the type of messages that are INFO, so that users are comfortable bumping this to WARN.

Maybe "confirmation messages"? I'll think about it; doesn't block the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed 25f37c5

}

do
local has_notify, notify_plugin = pcall(require, "notify")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, separate. This leave the door open nicely.

@alex-courtis alex-courtis merged commit 6ca6f99 into nvim-tree:master Oct 31, 2022
@alex-courtis
Copy link
Member

Many thanks for your contribution @kylo252

The nvim-tree community would be very grateful if you took a look at #1697 #1700

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

Successfully merging this pull request may close these issues.

too many notifications
4 participants