diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-02-22 20:14:47 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-03-06 10:13:14 +1100 |
| commit | 70610017284af7effd675bd927ae25b084b3e4b9 (patch) | |
| tree | a7c883a919f64d4d3828b074f4707b3272460cd0 /src/command_manager.cc | |
| parent | b915e4e11b666b72607b8c22044f5e20d9107cdd (diff) | |
Add a complete-command command to configure command completion
This makes it possible to change command completion in hooks and
paves the way to more flexibility in how custom commands can be
completed
Diffstat (limited to 'src/command_manager.cc')
| -rw-r--r-- | src/command_manager.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index 5663b1e3..0f3cb749 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -41,6 +41,15 @@ void CommandManager::register_command(String command_name, std::move(completer) }; } +void CommandManager::set_command_completer(StringView command_name, CommandCompleter completer) +{ + auto it = m_commands.find(command_name); + if (it == m_commands.end()) + throw runtime_error(format("no such command '{}'", command_name)); + + it->value.completer = std::move(completer); +} + bool CommandManager::module_defined(StringView module_name) const { return m_modules.find(module_name) != m_modules.end(); |
