forked from qt-creator/qt-creator
Copilot: Register settings aspects more directly
Also simplify a search. Change-Id: I2ba511ca3250c624fb7dbc2b44f845a5757e72ce Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -32,11 +32,8 @@ CopilotSettings::CopilotSettings()
|
|||||||
FilePath::fromUserInput(
|
FilePath::fromUserInput(
|
||||||
"~/AppData/Local/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js")};
|
"~/AppData/Local/nvim/pack/github/start/copilot.vim/copilot/dist/agent.js")};
|
||||||
|
|
||||||
const FilePath distFromVim = Utils::findOrDefault(searchDirs, [](const FilePath &fp) {
|
const FilePath distFromVim = Utils::findOrDefault(searchDirs, &FilePath::exists);
|
||||||
return fp.exists();
|
|
||||||
});
|
|
||||||
|
|
||||||
registerAspect(&nodeJsPath);
|
|
||||||
nodeJsPath.setExpectedKind(PathChooser::ExistingCommand);
|
nodeJsPath.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
nodeJsPath.setDefaultFilePath(nodeFromPath);
|
nodeJsPath.setDefaultFilePath(nodeFromPath);
|
||||||
nodeJsPath.setSettingsKey("Copilot.NodeJsPath");
|
nodeJsPath.setSettingsKey("Copilot.NodeJsPath");
|
||||||
@@ -47,7 +44,6 @@ CopilotSettings::CopilotSettings()
|
|||||||
Tr::tr("Select path to node.js executable. See https://nodejs.org/de/download/"
|
Tr::tr("Select path to node.js executable. See https://nodejs.org/de/download/"
|
||||||
"for installation instructions."));
|
"for installation instructions."));
|
||||||
|
|
||||||
registerAspect(&distPath);
|
|
||||||
distPath.setExpectedKind(PathChooser::File);
|
distPath.setExpectedKind(PathChooser::File);
|
||||||
distPath.setDefaultFilePath(distFromVim);
|
distPath.setDefaultFilePath(distFromVim);
|
||||||
distPath.setSettingsKey("Copilot.DistPath");
|
distPath.setSettingsKey("Copilot.DistPath");
|
||||||
@@ -58,7 +54,6 @@ CopilotSettings::CopilotSettings()
|
|||||||
"Select path to agent.js in copilot neovim plugin. See "
|
"Select path to agent.js in copilot neovim plugin. See "
|
||||||
"https://github.com/github/copilot.vim#getting-started for installation instructions."));
|
"https://github.com/github/copilot.vim#getting-started for installation instructions."));
|
||||||
|
|
||||||
registerAspect(&autoComplete);
|
|
||||||
autoComplete.setDisplayName(Tr::tr("Auto Complete"));
|
autoComplete.setDisplayName(Tr::tr("Auto Complete"));
|
||||||
autoComplete.setLabelText(Tr::tr("Request completions automatically"));
|
autoComplete.setLabelText(Tr::tr("Request completions automatically"));
|
||||||
autoComplete.setDefaultValue(true);
|
autoComplete.setDefaultValue(true);
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ public:
|
|||||||
|
|
||||||
static CopilotSettings &instance();
|
static CopilotSettings &instance();
|
||||||
|
|
||||||
Utils::FilePathAspect nodeJsPath;
|
Utils::FilePathAspect nodeJsPath{this};
|
||||||
Utils::FilePathAspect distPath;
|
Utils::FilePathAspect distPath{this};
|
||||||
Utils::BoolAspect autoComplete;
|
Utils::BoolAspect autoComplete{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Copilot
|
} // namespace Copilot
|
||||||
|
|||||||
Reference in New Issue
Block a user