completion
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| CommandCompleter slashed.completion Main command completion implementation. |
||
| CompletionContext slashed.completion Context for completion operations. |
||
| CompletionItem slashed.completion Single completion suggestion. |
||
| CompletionProvider slashed.completion Base class for completion providers. |
🛈 DocStrings¶
Command completion system.
CommandCompleter
¶
Main command completion implementation.
Source code in src/slashed/completion.py
__init__
¶
__init__(commands: dict[str, BaseCommand]) -> None
Initialize command completer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
dict[str, BaseCommand]
|
Mapping of command names to command instances |
required |
Source code in src/slashed/completion.py
add_global_provider
¶
add_global_provider(provider: CompletionProvider) -> None
get_completions
async
¶
get_completions(context: CompletionContext[Any]) -> AsyncIterator[CompletionItem]
Get completions for the current context.
Source code in src/slashed/completion.py
CompletionContext
¶
Context for completion operations.
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
TCommandData
|
Type of the data in the associated CommandContext. Used when completions need to access the command context data. |
required |
Source code in src/slashed/completion.py
command_context
property
¶
command_context: CommandContext[TCommandData]
Get command execution context.
Returns:
| Type | Description |
|---|---|
CommandContext[TCommandData]
|
Command context |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If command context is not set |
__init__
¶
__init__(document: Document, command_context: CommandContext[TCommandData] | None = None) -> None
Initialize completion context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
document
|
Document
|
Current document being completed |
required |
command_context
|
CommandContext[TCommandData] | None
|
Optional command execution context |
None
|
Source code in src/slashed/completion.py
CompletionItem
dataclass
¶
Single completion suggestion.
Source code in src/slashed/completion.py
display
class-attribute
instance-attribute
¶
Optional display text (defaults to text)
kind
class-attribute
instance-attribute
¶
Type of completion item
metadata
class-attribute
instance-attribute
¶
Additional information to show
sort_text
class-attribute
instance-attribute
¶
Optional text to use for sorting (defaults to text)
CompletionProvider
¶
Bases: ABC
Base class for completion providers.
Source code in src/slashed/completion.py
get_completions
abstractmethod
¶
get_completions(context: CompletionContext[Any]) -> AsyncIterator[CompletionItem]