feat(daemon): serve bounded compile command entries to editor extensions
This commit is contained in:
1 parent
afea6f3fad
commit
40fef50a6f
9 files changed
+237
-2
No files matched your search
@@ -1471,6 +1471,8 @@ struct DaemonCmdOptions {
|
||||
std::string editor_arg{"all"};
|
||||
std::optional<std::string> member_arg;
|
||||
std::string graph_format_arg{"dot"};
|
||||
std::optional<std::string> file_filter_arg;
|
||||
std::string limit_arg{"50"};
|
||||
std::string timeout_ms_arg{"2000"};
|
||||
bool force{false};
|
||||
std::string max_bytes_arg{"0"};
|
||||
@@ -1558,6 +1560,12 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
Util::json_quote(opts.graph_format_arg));
|
||||
} else if (sub == "editor_status") {
|
||||
request_json = R"({"op":"editor_status"})";
|
||||
} else if (sub == "compdb_entries") {
|
||||
request_json =
|
||||
std::format(R"({{"op":"compdb_entries","limit":{}{}}})", opts.limit_arg,
|
||||
opts.file_filter_arg
|
||||
? std::format(",\"file\":{}", Util::json_quote(*opts.file_filter_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "watch_poll") {
|
||||
request_json = R"({"op":"watch_poll"})";
|
||||
} else if (sub == "watch_wait") {
|
||||
@@ -2629,6 +2637,14 @@ int main(int argc, char **argv) {
|
||||
daemon_opts.jobs_arg, "0");
|
||||
auto &daemon_compdb_cmd =
|
||||
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
|
||||
auto &daemon_compdb_entries_cmd = daemon_compdb_cmd.subcommand(
|
||||
"entries", "Query bounded compile_commands entries for editor extensions");
|
||||
configure_daemon_common(daemon_compdb_entries_cmd);
|
||||
daemon_compdb_entries_cmd
|
||||
.option("--file", "", "Only entries whose source path ends with this value",
|
||||
daemon_opts.file_filter_arg)
|
||||
.option_default("--limit", "", "Maximum entries returned (0-500)", daemon_opts.limit_arg,
|
||||
"50");
|
||||
auto &daemon_compdb_use_cmd =
|
||||
daemon_compdb_cmd.subcommand("use", "Select an already-published editor profile");
|
||||
configure_daemon_common(daemon_compdb_use_cmd);
|
||||
|
||||
Reference in new issue
Block a user