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