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 Aug 4, 2024
1 parent b3a531c commit edb3da2
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 81 deletions.
59 changes: 39 additions & 20 deletions docs/dev/context.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,71 @@
---
title: Index
description: Type description of context
author:
- max397574
categories:
- docs,
- types
title: Context
description: The context type in care.nvim
---

This is a class representing the current state. It includes buffer number and cursor position. It
is passed to completion sources to get completions.
# Context

This is a class representing the current state. It includes buffer number and
cursor position. It is passed to completion sources to get completions.

# Methods

## Changed

Whether the context changed in comparison to the previous one. This is used to check whether to
get new completions or not.
`context:changed(): bool`

Whether the context changed in comparison to the previous one. This is used to
check whether to get new completions or not when using autocompletion.

## New

Create a new context. This takes the previous one as argument. This one is stored to determine if
the context changed or not when completing.
The previous context of the previous one is deleted so this data structure doesn't grow really
large.
`Context.new(): care.context`

Create a new context. This takes a previous context as argument. This one is
stored to determine if the context changed or not when completing. The previous
context of the previous one is deleted so this data structure doesn't grow
really large.

# Fields

## Previous

The previous context which is used to determine whether the context changed or not.
`context.previous: care.context`

The previous context which is used to determine whether the context changed or
not. The `previous` field of the previous context should always be `nil` so the
data structure doesn't grow infinitely.

## Cursor

The cursor positon.
`context.cursor: {row: integer, col: integer}`

The cursor position. This will have a `col` and a `row` field and has 1-based
line and 0-based column indexes. This is the same as in
`nvim_win_{get, set}_cursor()` (`:h api-indexing`).

## Bufnr

`context.bufnr: integer`

Number of the buffer.

## Reason

Reason for triggering completion.
`context.reason: 1|2`

Reason for triggering completion. This is a `completionReason` so either 1 for
automatic triggering and 2 for manual triggering.

## Current line

The current line.
`context.current_line: string`

The complete line on which the cursor was when the context was created.

## Line before cursor

Part of the current line which is before the cursor.
`context.line_before_cursor: string`

The line before the cursor. This is mostly important to be correct in insert
mode. In normal mode the character on which the cursor is is not included.
70 changes: 43 additions & 27 deletions docs/dev/core.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,79 @@
---
title: Core
description: Type description of care.nvim source
author:
- max397574
categories:
- docs,
- types
description: The core module in care.nvim
---

# General
# Core

This module is for the core of care. There all comes together with the menu being opened
and the completion triggered.
This module is for the core of care. Here everything comes together with the
most important things being the menu being opened and the completion triggered.

# Methods

## New

Use this function to create a new instance.
`Core.new(): care.core`

# Methods
Use this function to create a new instance. It takes no arguments and should be
called only once when the plugin is first set up.

## Complete

This function starts the completion. It goes through all the sources, triggers them (completion
or sorting) and opens the menu with the result.
`core:complete(reason): nil`

This function starts the completion. It goes through all the sources, triggers
them (completion and sorting) and opens the menu with the result.

## On Change

This function is invoked on every text change. It updates the context field and triggers
completion if it changed.
`core:on_change(): nil`

This function is invoked on every text change (by default, see
`completion_events` in config). It updates the context field and triggers
completion if the context changed.

## Block

The `block` method can be used to temporarily disable care. It returns a function which is
used to unblock it again.
This is used for the `insert` selection behavior where you don't want to get new completions when
changing the text.
`core:block(): function`

The `block` method can be used to temporarily disable care. It returns a
function which is used to unblock it again. This is used for the `insert`
selection behavior where you don't want to get new completions when changing the
text.

## Setup

The setup function is used to setup care so it will actually provide autocompletion when
typing by setting up an autocommand.
`core:setup(): nil`

The setup function is used to setup care so it will actually provide
autocompletion when typing by setting up an autocommand with the
`completion_events` from the configuration.

# Fields

## Context

This is used to store the current context. There is always a new one created in `on_change` and
compared to see if it changed.
`core.context: care.context`

This is used to store the current context. There is always a new one created in
`on_change` and compared to see if it changed.

## Menu

`core.menu: care.menu`

In this field a menu instance which is used in core is stored.

## Blocked

This field is used by the [Block](#block) method. It just completely disables autocompletion when set
to true.
`core.blocked: boolean`

This field is used by the [block()](#block) method. It just completely disables
autocompletion when set to true.

## Last opened at

This variable is used to determine where a new completion window was opened for the last time.
This is used to determine when to reopen the completion window.
`core.last_opened_at: integer`

This variable is used to determine where a new completion window was opened for
the last time. This is used to determine when to reopen the completion window.
20 changes: 19 additions & 1 deletion docs/dev/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@ title: Developers
description: Ressources to devlop care.nvim or sources for it
---

Documentation for developing care.nvim or sources for it
# Developer documentation

This is the internal documentation of the care.nvim code base. It also includes
documentation for developing sources for care.nvim.

## Conventions used

For describing classes there is always a section for methods (functions) and one
for fields. The name and how to use the method/function is normally written
directly after the respective heading. Capital letters are used for accessing
the classes as lua modules (e.g. `Context.new`) and lowercase letters for
instances (e.g. `context.previous`). This should also be done in the codebase
like this.

A `.` or `:` indicates if the function is a method or a function. It also has to
be used this way.

After the `:` the return type of functions or the type of fields is indicated
(e.g. `context:changed(): bool`).
65 changes: 32 additions & 33 deletions docs/dev/menu.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
---
title: Menu
description: Type description of care.nvim menu
author:
- max397574
categories:
- docs,
- types
---

# General

This is the main class of the care completion menu. The menu is used to display completion
entries and also contains the logic for selecting and inserting the completions.
This is the main class of the care completion menu. The menu is used to display
completion entries and also contains the logic for selecting and inserting the
completions.

# Internals

## Index

The index is used to determine the selected entry. It is used to get this entry when confirming
the completion.
The function to select the next and previous entries simply change this index.
The index is used to determine the selected entry. It is used to get this entry
when confirming the completion. The function to select the next and previous
entries simply change this index.

# Methods

Expand All @@ -29,48 +25,51 @@ Creates a new instance of the completion menu.

## Draw

Draws the menu. This includes formatting the entries with the function from the config and
setting the virtual text used to display the labels. It also adds the highlights for the selected
entry and for the matched chars.
Draws the menu. This includes formatting the entries with the function from the
config and setting the virtual text used to display the labels. It also adds the
highlights for the selected entry and for the matched chars.

## Is open

This is a function which can be used to determine whether the completion menu is open or not.
This is especially useful for mappings which have a fallback action when the menu isn't visible.
This is a function which can be used to determine whether the completion menu is
open or not. This is especially useful for mappings which have a fallback action
when the menu isn't visible.

## Select next

This function can be used to select the next entry. It accepts a count to skip over some entries.
It automatically wraps at the bottom and jumps up again.
This function can be used to select the next entry. It accepts a count to skip
over some entries. It automatically wraps at the bottom and jumps up again.

## Select prev

This function is used to select the previous entry analogous to [Select next](#select-next)
This function is used to select the previous entry analogous to
[Select next](#select-next)

## Open

The `open` function is used to open the completion menu with a specified set of entries. This
includes opening the window and displaying the text.
The `open` function is used to open the completion menu with a specified set of
entries. This includes opening the window and displaying the text.

## Close

This function closes the menu and resets some internal things.

## Get active entry

With this function you can get the currently selected entry. This can be used for the docs view
or some other api functions. It is also used when the selection is confirmed.
With this function you can get the currently selected entry. This can be used
for the docs view or some other api functions. It is also used when the
selection is confirmed.

## Confirm

This is the function to trigger the completion with a selected entry. It gets the selected entry
closes the menu and completes.
This is the function to trigger the completion with a selected entry. It gets
the selected entry closes the menu and completes.

## Complete

This function completes with a given entry. That means it removes text used for filtering
(if necessary), expands snippet with the configured function, applies text edits and lsp
commands.
This function completes with a given entry. That means it removes text used for
filtering (if necessary), expands snippet with the configured function, applies
text edits and lsp commands.

## Readjust window

Expand Down Expand Up @@ -108,18 +107,18 @@ In this field the user config is stored for easier access.

## Buffer

This is the buffer used for the menu. It's just created once when initially creating a new
instance.
This is the buffer used for the menu. It's just created once when initially
creating a new instance.

## Window

Window number of the window used to display the menu. This is always newly created when the menu
gets opened and is only set if the menu is open.
Window number of the window used to display the menu. This is always newly
created when the menu gets opened and is only set if the menu is open.

## Index

The index is used to get and track the currently selected item. It gets modified by the functions
to select next and previous entry.
The index is used to get and track the currently selected item. It gets modified
by the functions to select next and previous entry.

## Scrollbar Buffer

Expand Down

0 comments on commit edb3da2

Please sign in to comment.