Skip to content

Commit

Permalink
feat(docs): add documentation for blocking core
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Jun 23, 2024
1 parent 18ffde7 commit a0101bd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
23 changes: 22 additions & 1 deletion docs/core.norg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ categories: [
types
]
created: 2023-11-15T17:42:46+0100
updated: 2024-06-09T10:21:16+0100
updated: 2024-06-23T15:31:35+0100
tangle: {
languages: {
lua: ../lua/neocomplete/types/core.lua
Expand Down Expand Up @@ -56,6 +56,18 @@ version: 1.1.1
---@field on_change fun(neocomplete.core): nil
@end

** Block
The `block` method can be used to temporarily disable neocomplete. 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.
#tangle
@code lua
--- Block neocomplete temporarily
--- Call return value to unblock
---@field block fun(neocomplete.core): fun(): nil
@end

** Setup
The setup function is used to setup neocomplete so it will actually provide autocompletion when
typing by setting up an autocommand.
Expand All @@ -82,3 +94,12 @@ version: 1.1.1
--- Menu instance of the core
---@field menu neocomplete.menu
@end

** Blocked
This field is used by the {** Block} method. It just completely disables autocompletion when set
to true.
#tangle
@code lua
--- Block autocompletion
---@field blocked boolean
@end
15 changes: 10 additions & 5 deletions lua/neocomplete/types/core.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
--- The core of neocomplete where the main api functions are defined
--- The core module of neocomplete
---@class neocomplete.core
--- Create a new instance of the core
---@field new fun(): neocomplete.core
--- Context instance of the core
---@field context neocomplete.context
--- Menu instance of the core
---@field menu neocomplete.menu
--- Complete
---@field complete fun(self: neocomplete.core, reason: neocomplete.completionReason?): nil
--- The function that gets invoked when the text changes
---@field on_change fun(neocomplete.core): nil
--- Block neocomplete temporarily
--- Call return value to unblock
---@field block fun(neocomplete.core): fun(): nil
--- Setup core (for now autocommands)
---@field setup fun(self: neocomplete.core): nil
--- Context instance of the core
---@field context neocomplete.context
--- Menu instance of the core
---@field menu neocomplete.menu
--- Block autocompletion
---@field blocked boolean

0 comments on commit a0101bd

Please sign in to comment.