diff --git a/README.md b/README.md index 8f4821f..b972a78 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,16 @@ or require("precognition").toggle() ``` +The return value indicating the visible state can be used to produce a notification. + +```lua +if require("precognition").toggle() then + vim.notify("precognition on") +else + vim.notify("precognition off") +end +``` + The subcommands and functions `show` and `hide` are also available. ### Peeking diff --git a/lua/precognition/init.lua b/lua/precognition/init.lua index b0b9d49..c4f5559 100644 --- a/lua/precognition/init.lua +++ b/lua/precognition/init.lua @@ -407,12 +407,14 @@ function M.hide() end --- Toggle automatic showing of hints +--- with return value indicating the visible state function M.toggle() if visible then M.hide() else M.show() end + return visible end ---@param opts Precognition.PartialConfig