Skip to content
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

feat: toggling returns visible value #73

Merged
merged 2 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading