Browse Source

Cleanup of rust-analyzer installation

pipelines/353213535
eidheim 4 years ago
parent
commit
09d569873f
  1. 9
      src/notebook.cpp

9
src/notebook.cpp

@ -191,7 +191,8 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
boost::system::error_code ec;
if(boost::filesystem::exists(nightly_rust_analyzer, ec))
source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, filesystem::escape_argument(nightly_rust_analyzer.string())));
else {
}
if(source_views_previous_size == source_views.size()) {
auto install_rust_analyzer = [this](const std::string &command) {
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(get_toplevel()), "Install rust-analyzer (Rust language server)", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_default_response(Gtk::RESPONSE_YES);
@ -220,16 +221,15 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
std::stringstream stdin_stream, stdout_stream;
if(Terminal::get().process(stdin_stream, stdout_stream, "rustup component list") == 0) {
std::string line;
bool found = false;
while(std::getline(stdout_stream, line)) {
if(starts_with(line, "rust-analyzer")) {
if(install_rust_analyzer(std::string("rustup component add rust-src ") + (starts_with(line, "rust-analyzer-preview") ? "rust-analyzer-preview" : "rust-analyzer")))
source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, filesystem::escape_argument(rust_analyzer.string())));
found = true;
break;
}
}
if(!found && install_rust_analyzer("rustup component add rust-src && rustup toolchain install nightly && rustup component add --toolchain nightly rust-src rust-analyzer-preview"))
if(source_views_previous_size == source_views.size() &&
install_rust_analyzer("rustup component add rust-src && rustup toolchain install nightly && rustup component add --toolchain nightly rust-src rust-analyzer-preview"))
source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, "rustup run nightly rust-analyzer"));
}
}
@ -238,7 +238,6 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
}
}
}
}
if(source_views_previous_size == source_views.size()) {
if(!language_id.empty()) {
static std::set<std::string> shown;

Loading…
Cancel
Save