-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3a531c
commit edb3da2
Showing
4 changed files
with
133 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters