Skip to content

Commit

Permalink
fix(api): better check in documentation and add types
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Nov 9, 2024
1 parent 08ef1a4 commit 1bcfbda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/care/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ care.api = {
return care.core and care.core.menu and care.core.menu:docs_visible()
end,
get_documentation = function()
return care.core.menu:docs_visible()
return (care.core and care.core.menu and care.core.menu:docs_visible())
and vim.api.nvim_buf_get_lines(care.core.menu.docs_window.buf, 0, -1, false)
or {}
end,
Expand Down
6 changes: 5 additions & 1 deletion lua/care/types/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@
--- indicates the visible position in the menu.
---
--- This is really useful to create shortcuts to certain entries like in the
--- [example in configuration recipes](/configuration_recipes#labels-and-shortcuts).
--- [Example usage](/configuration_recipes#labels-and-shortcuts).
---@field select_visible fun(index: integer): nil
--- Indicated whether the menu is reversed
--- Only relevant when using sorting direction "away-from-cursor"
---@field is_reversed fun(): boolean
--- Get the documentation of the currently selected entry.
--- Will return an empty table if no documentation is available.
--- [Example usage](/configuration_recipes#access-documentation)
---@field get_documentation fun(): string[]

0 comments on commit 1bcfbda

Please sign in to comment.