diff --git a/docs/config.md b/docs/config.md index fc59886..7ce5316 100644 --- a/docs/config.md +++ b/docs/config.md @@ -3,6 +3,7 @@ title: Config description: Configuration for care.nvim --- +# Config
Full Default Config @@ -94,24 +95,20 @@ config.defaults = { ```
-# Config -The config of care is used to configure the ui and care itself. +The config of care is used to configure the UI and care itself. -There are two main parts to the config. The first one is the `ui` field and the -second on is the rest of the configuration which is for configuring the general -behavior of care. +The configuration consists of two main parts. The UI Configuration and the +configuration of the completion behaviors of care. # `care.config` # Methods ## Snippet Expansion -`config.snippet_expansion(string): nil` - -Here a function for expanding snippets is defined. By default this is the -builtin `vim.snippet.expand()`. You can also use a plugin like luasnip for this -like this: +`config.snippet_expansion(body: string): nil` +With this field a function for expanding snippets is defined. By default this is the +builtin `vim.snippet.expand()`. You can also use a plugin like luasnip for this: ```lua snippet_expansion = function(body) require("luasnip").lsp_expand(body) @@ -128,15 +125,10 @@ disables care in prompts. ## Ui `config.ui care.config.ui` -The [ui configuration](#Ui-Configuration) is used to configure the whole ui of care. One of the main -goals of this is to be as extensible as possible. This is especially important +The [UI Configuration](#Ui-Configuration) is used to configure the whole UI of care. +One of the main goals of this is to be as extensible as possible. This is especially important for the completion entries. Read more about that under [Configuration of item display](/design/#configuration-of-item-display). -The most important part for many users will be the `menu` field. It's used to -configure the completion menu. -You can also configure the documentation view just like the main menu. -Lastly the users can also configure the icons which will be used for the -different items. ## Selection Behavior `config.selection_behavior "select"|"insert"` @@ -149,33 +141,35 @@ the entry (this is not necessarily the whole text). ## Confirm Behavior `config.confirm_behavior "insert"|"replace"` -Behavior when confirming entry +This field controls the behavior when confirming an entry. ## Sources `config.sources care.config.source[]` -Configuration for the different sources +This field is used to configure the sources for care.nvim. ## Completion Events `config.completion_events string[]` -The `completion_events` table is used to set events for completion. By default +The `completion_events` table is used to set events for autocompletion. By default it just contains `"TextChangedI"`. You can set it to an empty table (`{}`) to disable autocompletion. ## Keyword Pattern `config.keyword_pattern string` -Pattern used to determine keywords, used to determine what to use for filtering -and what to remove if insert text is used. +The keyword pattern is used to determine keywords. These are used to determine what +to use for filtering and what to remove if insert text is used. +It should essentially just describe the entries of a source. ## Preselect `config.preselect boolean` -Whether items should be preselected or not +Whether items should be preselected or not. Which items are preselected is determined +by the source. # Ui Configuration -The main class for the ui configuration of care.nvim +This is used to configure the whole UI of care. # `care.config.ui` # Fields @@ -200,9 +194,9 @@ This is a table which defines the different icons. ## Ghost Text `config.ui.ghost_text care.config.ui.ghost_text` -Configuration of ghost text +Configuration of ghost text. -Configuration for the ghost text +With this field the user can control how ghost text is displayed. # `care.config.ui.ghost_text` # Fields @@ -211,14 +205,14 @@ Configuration for the ghost text `config.ui.ghost_text.enabled boolean` You can use the `enabled` field to determine whether the ghost text should be -enabled or not. The `position` can either be `"inline"` or `"overlay"`. Inline -will add the text inline right where the cursor is. With the overlay position -the text will overlap with existing text after the cursor. +enabled or not. ## Position `config.ui.ghost_text.position "inline"|"overlay"` - +The `position` can either be `"inline"` or `"overlay"`. Inline +will add the text inline right where the cursor is. With the overlay position +the text will overlap with existing text after the cursor. This configuration should allow you to completely adapt the completion menu to your likings. @@ -232,7 +226,8 @@ scrollbar. Set `scrollbar` to `nil` value to disable the scrollbar. ## Format Entry `config.ui.menu.format_entry(entry: care.entry): { [1]: string, [2]: string }[][]` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) Another field is `format_entry`. This is a function which recieves an entry of the completion menu and determines how it's formatted. For that a table with @@ -300,7 +295,8 @@ Whether the source is enabled (default true) ## Filter `config.source.filter(entry: care.entry): boolean` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) Filter function for entries by the source # Fields diff --git a/docs/dev/context.md b/docs/dev/context.md index ad607d1..4a58985 100644 --- a/docs/dev/context.md +++ b/docs/dev/context.md @@ -13,14 +13,16 @@ cursor position. It is passed to completion sources to get completions. ## Changed `context.changed(care.context): boolean` -See: [care.context](/dev/context) + +See [care.context](/dev/context) 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 `Context.new(previous: care.context?): care.context` -See: [care.context](/dev/context) + +See [care.context](/dev/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 @@ -30,7 +32,8 @@ really large. ## Previous `context.previous care.context?` -See: [care.context](/dev/context) + +See [care.context](/dev/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 @@ -38,7 +41,8 @@ data structure doesn't grow infinitely. ## Cursor `context.cursor care.context.cursor` -See: [care.context](/dev/context) + +See [care.context](/dev/context) 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 diff --git a/docs/dev/core.md b/docs/dev/core.md index 1c46a47..9ed111e 100644 --- a/docs/dev/core.md +++ b/docs/dev/core.md @@ -13,7 +13,8 @@ most important things being the menu being opened and the completion triggered. ## New `Core.new(): care.core` -See: [care.core](/dev/core) + +See [care.core](/dev/core) 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. @@ -54,14 +55,16 @@ Filter currently visible menu. This is used when moving the cursor. ## Context `core.context care.context` -See: [care.context](/dev/context) + +See [care.context](/dev/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` -See: [care.menu](/dev/menu) + +See [care.menu](/dev/menu) In this field a menu instance which is used in core is stored. diff --git a/docs/dev/entry.md b/docs/dev/entry.md index 5ea385a..d40ee9e 100644 --- a/docs/dev/entry.md +++ b/docs/dev/entry.md @@ -13,7 +13,8 @@ completion item for which the lsp type is used. ## New `Entry.new(completion_item: lsp.CompletionItem, source: care.internal_source, context: care.context): care.entry` -See: [care.entry](/dev/entry), [care.context](/dev/context), [care.internal_source](/dev/internal_source) + +See [care.entry](/dev/entry), [care.context](/dev/context), [care.internal_source](/dev/internal_source) The new function is the constructor for a new completion entry. @@ -59,14 +60,16 @@ Gets the default range for entry (if there is no textEdit) ## Source `entry.source care.internal_source` -See: [care.internal_source](/dev/internal_source) + +See [care.internal_source](/dev/internal_source) This is the source from which the entry came. This is important for using the right keyword pattern and getting the right offset. ## Context `entry.context care.context` -See: [care.context](/dev/context) + +See [care.context](/dev/context) This is the context in which the entry was completed. This is important to now what context text- edits of the entry target. diff --git a/docs/dev/internal_source.md b/docs/dev/internal_source.md index 444abd7..fc3f14f 100644 --- a/docs/dev/internal_source.md +++ b/docs/dev/internal_source.md @@ -13,7 +13,8 @@ metadata about which the source author doesn't have to care and sometimes can't ## New `Internal_source.new(completion_source: care.source): care.internal_source` -See: [care.internal_source](/dev/internal_source), [care.source](/dev/source) + +See [care.internal_source](/dev/internal_source), [care.source](/dev/source) This function creates a new instance. @@ -25,7 +26,8 @@ method to get it and as fallback the one from the config. ## Get Offset `internal_source:get_offset(context: care.context): integer` -See: [care.context](/dev/context) + +See [care.context](/dev/context) With this function the offset of the source is determined. The offset describes at which point the completions for this source start. This is required to be able to remove that text if needed @@ -45,13 +47,15 @@ This function checks whether the function is enabled or not based on it's config ## Source `internal_source.source care.source` -See: [care.source](/dev/source) + +See [care.source](/dev/source) This field is used to store the source written by the source author. ## Entries `internal_source.entries care.entry[]` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) In the entries field entries gotten from the source are stored. This is used to be able to sort and filter the entries when not getting new ones. diff --git a/docs/dev/menu.md b/docs/dev/menu.md index 0593701..f06ea56 100644 --- a/docs/dev/menu.md +++ b/docs/dev/menu.md @@ -14,7 +14,8 @@ completions. ## New `Menu.new(): care.menu` -See: [care.menu](/dev/menu) + +See [care.menu](/dev/menu) Creates a new instance of the completion menu. @@ -46,7 +47,8 @@ This function is used to select the previous entry analogous to ## Open `menu:open(entries: care.entry[], offset: integer): nil` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) 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. @@ -58,7 +60,8 @@ This function closes the menu and resets some internal things. ## Get Active Entry `menu:get_active_entry(): care.entry?` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/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 @@ -72,7 +75,8 @@ the selected entry closes the menu and completes. ## Complete `menu:complete(entry: care.entry): nil` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) This function completes with a given entry. That means it removes text used for filtering (if necessary), expands snippet with the configured function, applies @@ -96,13 +100,15 @@ Scroll up or down in the docs window by `delta` lines. ## Menu Window `menu.menu_window care.window` -See: [care.window](/dev/window) + +See [care.window](/dev/window) Wrapper for utilities for the window of the menu ## Docs Window `menu.docs_window care.window` -See: [care.window](/dev/window) + +See [care.window](/dev/window) Wrapper for utilities for the window of the docs @@ -113,7 +119,8 @@ The ghost text instance used to draw the ghost text. ## Entries `menu.entries care.entry[]` -See: [care.entry](/dev/entry) + +See [care.entry](/dev/entry) This field is used to store all the entries of the completion menu. diff --git a/docs/dev/window.md b/docs/dev/window.md index edff9aa..98f2fb4 100644 --- a/docs/dev/window.md +++ b/docs/dev/window.md @@ -12,7 +12,8 @@ Utility class for working with windows in care ## New `Window.new(): care.window` -See: [care.window](/dev/window) + +See [care.window](/dev/window) Creates a new instance of the menu window @@ -63,7 +64,8 @@ Change scroll of window ## Get Data `window:get_data(): care.window.data` -See: [care.window](/dev/window) + +See [care.window](/dev/window) # Fields