Skip to content

Commit

Permalink
feat: toggling returns visible value (tris203#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
osamuaoki authored Jun 16, 2024
1 parent 7a76d43 commit 6aab38a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lua/precognition/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6aab38a

Please sign in to comment.