nixd
Loading...
Searching...
No Matches
nixd.cpp
Go to the documentation of this file.
1#include "nixd-config.h"
2
4#include "lspserver/Logger.h"
5
8
9#include <llvm/ADT/ArrayRef.h>
10#include <llvm/Support/CommandLine.h>
11
12using namespace lspserver;
13using namespace nixd;
14
15namespace {
16
17using namespace llvm::cl;
18
19OptionCategory Misc("miscellaneous options");
20OptionCategory Debug("debug-only options (for developers)");
21
23
25 "input-style",
26 desc("Input JSON stream encoding"),
27 values(
28 clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"),
29 clEnumValN(JSONStreamStyle::Delimited, "delimited",
30 "messages delimited by `// -----` lines, "
31 "with // comment support")),
32 init(JSONStreamStyle::Standard),
33 cat(Debug),
34 Hidden,
35};
36
38 "log", desc("Verbosity of log messages written to stderr"),
39 values(
40 clEnumValN(Logger::Level::Error, "error", "Error messages only"),
41 clEnumValN(Logger::Level::Info, "info", "High level execution tracing"),
42 clEnumValN(Logger::Level::Debug, "debug", "Debugging details"),
43 clEnumValN(Logger::Level::Verbose, "verbose", "Low level details")),
44 init(Logger::Level::Info), cat(Misc)};
45opt<bool> PrettyPrint{"pretty", desc("Pretty-print JSON output"), init(false),
46 cat(Debug)};
47
48} // namespace
49
50int main(int argc, char *argv[]) {
51 SetVersionPrinter([](llvm::raw_ostream &OS) {
52 OS << "nixd, version: ";
53#ifdef NIXD_VCS_TAG
55#else
57#endif
58 OS << "\n";
59 });
60
62 ParseCommandLineOptions(argc, argv, "nixd language server", nullptr,
63 "NIXD_FLAGS");
64
65 if (LitTest) {
66 InputStyle = JSONStreamStyle::Delimited;
67 LogLevel = Logger::Level::Verbose;
68 PrettyPrint = true;
69 }
70
71 StreamLogger Logger(llvm::errs(), LogLevel);
73
74 auto In = std::make_unique<lspserver::InboundPort>(STDIN_FILENO, InputStyle);
75
76 auto Out = std::make_unique<lspserver::OutboundPort>(PrettyPrint);
77
78 auto Controller =
79 std::make_unique<nixd::Controller>(std::move(In), std::move(Out));
80
81 Controller->run();
82
83 return 0;
84}
Interface to allow custom logging in clangd.
Definition Logger.h:13
Only one LoggingSession can be active at a time.
Definition Logger.h:91
Whether current platform treats paths case insensitively.
Definition Connection.h:11
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
llvm::cl::OptionCategory NixdCategory
llvm::cl::opt< bool > LitTest
Indicating that we are in lit-test mode.
Definition Options.cpp:8
int main(int argc, char *argv[])
Definition nixd.cpp:50