Add completion support to load-module
This commit is contained in:
parent
91386a535c
commit
4916471029
|
@ -624,6 +624,13 @@ Completions CommandManager::complete_command_name(const Context& context, String
|
||||||
return {0, query.length(), Kakoune::complete(query, query.length(), concatenated(commands, aliases))};
|
return {0, query.length(), Kakoune::complete(query, query.length(), concatenated(commands, aliases))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Completions CommandManager::complete_module_name(StringView query) const
|
||||||
|
{
|
||||||
|
return {0, query.length(),
|
||||||
|
Kakoune::complete(query, query.length(), m_modules | filter([](auto&& item) { return not item.value.loaded; })
|
||||||
|
| transform(&ModuleMap::Item::key))};
|
||||||
|
}
|
||||||
|
|
||||||
Completions CommandManager::complete(const Context& context,
|
Completions CommandManager::complete(const Context& context,
|
||||||
CompletionFlags flags,
|
CompletionFlags flags,
|
||||||
StringView command_line,
|
StringView command_line,
|
||||||
|
|
|
@ -129,6 +129,8 @@ public:
|
||||||
|
|
||||||
void load_module(StringView module_name, Context& context);
|
void load_module(StringView module_name, Context& context);
|
||||||
|
|
||||||
|
Completions complete_module_name(StringView query) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void execute_single_command(CommandParameters params,
|
void execute_single_command(CommandParameters params,
|
||||||
Context& context,
|
Context& context,
|
||||||
|
|
|
@ -2448,7 +2448,10 @@ const CommandDesc require_module_cmd = {
|
||||||
ParameterDesc{ {}, ParameterDesc::Flags::None, 1, 1 },
|
ParameterDesc{ {}, ParameterDesc::Flags::None, 1, 1 },
|
||||||
CommandFlags::None,
|
CommandFlags::None,
|
||||||
CommandHelper{},
|
CommandHelper{},
|
||||||
CommandCompleter{},
|
make_completer(
|
||||||
|
[](const Context&, CompletionFlags, const String& prefix, ByteCount cursor_pos) {
|
||||||
|
return CommandManager::instance().complete_module_name(prefix.substr(0, cursor_pos));
|
||||||
|
}),
|
||||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
{
|
{
|
||||||
CommandManager::instance().load_module(parser[0], context);
|
CommandManager::instance().load_module(parser[0], context);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user