4#include <boost/asio/post.hpp>
8using llvm::json::ObjectMapper;
9using llvm::json::Value;
14 return O && O.mapOptional(
"suppress", R.
suppress);
25 return O && O.mapOptional(
"command", R.
command);
31 return O && O.mapOptional(
"expr", R.
expr);
37 return O && O.mapOptional(
"expr", R.
expr);
44 && O.mapOptional(
"options", R.
options)
45 && O.mapOptional(
"nixpkgs", R.
nixpkgs)
50void Controller::onDidChangeConfiguration(
57 std::lock_guard
G(ConfigLock);
62 if (nixpkgsClient()) {
63 evalExprWithProgress(*nixpkgsClient(), Config.
nixpkgs.
expr,
68 std::lock_guard
_(OptionsLock);
70 for (
const auto &[Name,
Opt] : Config.options) {
71 auto &Client = Options[Name];
77 evalExprWithProgress(*Client->client(),
Opt.expr, Name);
86 for (
const auto &[
File,
TU] : TUs) {
87 publishDiagnostics(
File, std::nullopt,
TU->src(),
TU->diagnostics());
91void Controller::fetchConfig() {
92 auto Action = [
this](llvm::Expected<llvm::json::Value>
Resp)
mutable {
94 elog(
"workspace/configuration: {0}",
Resp.takeError());
99 if (
Resp->kind() != llvm::json::Value::Array) {
100 lspserver::elog(
"workspace/configuration response is not an array: {0}",
110 llvm::json::Path::Root P;
112 elog(
"workspace/configuration: parse error {0}", P.getError());
126void Controller::workspaceConfiguration(
Whether current platform treats paths case insensitively.
llvm::unique_function< void(llvm::Expected< T >)> Callback
llvm::Error error(std::error_code EC, const char *Fmt, Ts &&...Vals)
void elog(const char *Fmt, Ts &&...Vals)
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
void startOption(const std::string &Name, std::unique_ptr< AttrSetClientProc > &Worker)
bool WorkspaceConfiguration
std::optional< std::string > section
std::vector< std::string > suppress
std::string expr
Expression to eval. Treat it as "import <nixpkgs> { }".
std::string expr
Expression to eval. Select this attrset as eval .options.
struct nixd::Configuration::Formatting formatting
std::map< std::string, OptionProvider > options
struct nixd::Configuration::Diagnostic diagnostic
struct nixd::Configuration::NixpkgsProvider nixpkgs