Use vim.notify as default console log#578
Open
lettertwo wants to merge 1 commit intonvim-lua:masterfrom
Open
Conversation
[vim.notify](https://neovim.io/doc/user/lua.html#vim.notify()) is arguably a more ergonomic way of showing level-filtered messages to the user, and it also allows for custom providers and handling, like [nvim-notify](https://github.com/rcarriga/nvim-notify) or [noice](https://github.com/folke/noice.nvim) , to integrate messages from `plenary.log`. I'm not sure if it's a bad idea to make this the new default; it could certainly be a breaking change, but i think that the _intention_ of an author who has not overridden the default config probably aligns with the behavior of `nvim.notify`. Fixes nvim-lua#540
wookayin
reviewed
May 18, 2024
| local level = vim.log.levels[level_config.name:upper()] | ||
| if level == nil then | ||
| level = vim.log.levels.ERROR | ||
| end |
Contributor
There was a problem hiding this comment.
Why ERROR by default? When can level be nil?
Author
There was a problem hiding this comment.
plenary's log config defines levels like:
modes = {
{ name = "trace", hl = "Comment" },
{ name = "debug", hl = "Comment" },
{ name = "info", hl = "None" },
{ name = "warn", hl = "WarningMsg" },
{ name = "error", hl = "ErrorMsg" },
{ name = "fatal", hl = "ErrorMsg" },
},while vim.log.levels is defined as:
vim.log.levels.DEBUG
vim.log.levels.ERROR
vim.log.levels.INFO
vim.log.levels.TRACE
vim.log.levels.WARN
vim.log.levels.OFFThese almost match, but plenary defines a level "fatal" that vim.log.levels does not. I figured vim.log.levels.ERROR was the closest analogue to it, but maybe it's not sensible to just assume any unknown level should be treated as such. Thoughts?
Contributor
There was a problem hiding this comment.
I wasn't aware of "fatal" in plenary. Makes sense, thanks for the explanation!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vim.notify is arguably a more ergonomic way of showing level-filtered messages to the user, and it also allows for custom providers and handling, like nvim-notify or noice , to integrate messages from
plenary.log.I'm not sure if it's a bad idea to make this the new default; it could certainly be a breaking change, but i think that the intention of an author who has not overridden the default config probably aligns with the behavior of
vim.notify.Fixes #540