mirror of
https://github.com/neovim/neovim.git
synced 2026-01-31 00:54:30 +00:00
feat(lua): add notify_once() (#17010)
Like vim.notify(), but only displays the notification once. This function prints a warning message to the user only once per Nvim session. This is useful for things we want the user to see without being overwhelmed with warning messages (for example, the deprecation messages in LSP diagnostics).
This commit is contained in:
committed by
GitHub
parent
11dafcaf05
commit
f365e68293
@@ -2200,6 +2200,40 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('vim.notify_once', function()
|
||||
local screen = Screen.new(60,5)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold=true, foreground=Screen.colors.Blue},
|
||||
[1] = {foreground=Screen.colors.Red},
|
||||
})
|
||||
screen:attach()
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]]}
|
||||
exec_lua [[vim.notify_once("I'll only tell you this once...", vim.log.levels.WARN)]]
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{1:I'll only tell you this once...} |
|
||||
]]}
|
||||
feed('<C-l>')
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]]}
|
||||
exec_lua [[vim.notify_once("I'll only tell you this once...")]]
|
||||
screen:expect_unchanged()
|
||||
end)
|
||||
|
||||
describe('vim.schedule_wrap', function()
|
||||
it('preserves argument lists', function()
|
||||
exec_lua [[
|
||||
|
||||
Reference in New Issue
Block a user