1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-16 05:51:05 +01:00

nix flake: Add completion support

This commit is contained in:
Eelco Dolstra 2020-05-11 22:10:33 +02:00
parent 27d34ef770
commit 649c2db308
3 changed files with 27 additions and 10 deletions

View file

@ -109,8 +109,6 @@ Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
void SourceExprCommand::completeInstallable(std::string_view prefix)
{
completeDir(0, prefix);
if (file) return; // FIXME
/* Look for flake output attributes that match the
@ -176,6 +174,23 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
warn(e.msg());
}
completeFlakeRef(prefix);
}
ref<EvalState> EvalCommand::getEvalState()
{
if (!evalState)
evalState = std::make_shared<EvalState>(searchPath, getStore());
return ref<EvalState>(evalState);
}
void EvalCommand::completeFlakeRef(std::string_view prefix)
{
if (prefix == "")
completions->insert(".");
completeDir(0, prefix);
/* Look for registry entries that match the prefix. */
for (auto & registry : fetchers::getRegistries(getStore())) {
for (auto & entry : registry->entries) {
@ -192,13 +207,6 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
}
}
ref<EvalState> EvalCommand::getEvalState()
{
if (!evalState)
evalState = std::make_shared<EvalState>(searchPath, getStore());
return ref<EvalState>(evalState);
}
Buildable Installable::toBuildable()
{
auto buildables = toBuildables();