Skip to content

Commit

Permalink
chore(build): auto-generate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 13, 2024
1 parent 167586e commit 6c490bd
Show file tree
Hide file tree
Showing 12 changed files with 430 additions and 182 deletions.
38 changes: 25 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: API documentation for care.nvimcare.api

The API for care. This should be used for most interactions with the plugins.
The api can be accessed with the following code

---
```lua
local care_api = require("care").api
```
Expand All @@ -16,39 +16,46 @@ local care_api = require("care").api
# Methods

## Is Open
`api.is_open`
`api.is_open(): boolean`

This function returns a boolean which indicates whether the
completion menu is currently open or not. This is especially useful for mappings
which should fallback to other actions if the menu isn't open.

## Confirm
`api.confirm`
`api.confirm(): nil`

Used to confirm the currently selected entry. Note that
there is also `<Plug>(CareConfirm)` which should preferably be used in mappings.

## Complete
`api.complete`
`api.complete(source_filter?: fun(name: string): boolean): nil`

This function is used to manually trigger completion

## Close
`api.close`
`api.close(): nil`

Closes the completion menu and documentation view if it is open.
For mappings `<Plug>(CareClose)` should be used.

## Select Next
`api.select_next`
`api.select_next(count: integer): nil`

Select next entry in completion menu. If count is provided the selection
will move down `count` entries.
For mappings `<Plug>(CareSelectNext)` can be used where count defaults to 1.

## Select Prev
`api.select_prev`
`api.select_prev(count: integer): nil`

Select next entry in completion menu. If count is provided the selection
will move up `count` entries.
For mappings `<Plug>(CareSelectPrev)` can be used where count defaults to 1.

## Doc Is Open
`api.doc_is_open`
`api.doc_is_open(): boolean`

Indicates whether there is a documentation window open or not.
This is especially useful together with the
function to scroll docs to only trigger the mapping in certain cases.
Expand All @@ -61,17 +68,20 @@ end
```

## Scroll Docs
`api.scroll_docs`
`api.scroll_docs(delta: integer): nil`

Use `scroll_docs(delta)` to scroll docs by `delta` lines. When a negative
delta is provided the docs will be scrolled upwards.

## Set Index
`api.set_index`
`api.set_index(index: integer): nil`

Allows the index which represents which entry is selected to be directly set.
This allows to jump anywhere in the completion menu.

## Get Index
`api.get_index`
`api.get_index(): integer`

Returns the index of the currently selected entry, 0 representing no selection.
This is e.g. useful to determine if an entry is selected:
```lua
Expand All @@ -81,13 +91,15 @@ end
```

## Select Visible
`api.select_visible`
`api.select_visible(index: integer): nil`

This function is used to select the entry at index `index` where `index`
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).

## Is Reversed
`api.is_reversed`
`api.is_reversed(): boolean`

Indicated whether the menu is reversed
Only relevant when using sorting direction "away-from-cursor"
Loading

0 comments on commit 6c490bd

Please sign in to comment.