lapce-rust icon indicating copy to clipboard operation
lapce-rust copied to clipboard

question about plugin

Open LollipopFt opened this issue 2 years ago • 1 comments

is this line meant to be "download.lock" instead? https://github.com/lapce/lapce-rust/blob/e7510356a4fe41b8e2b75de32ba4fa7044441ff8/src/main.rs#L46 also, is it possible to use octocrab (or something preferably much more lightweight?) to auto download the latest version? https://github.com/lapce/lapce-rust/blob/e7510356a4fe41b8e2b75de32ba4fa7044441ff8/src/main.rs#L55 e.g.

use octocrab::models::repos::Release;

async fn main() {
    let ranalyzer = octocrab
        .repos("rust-lang", "rust-analyzer")
        .releases()
        .list()
        .per_page(5)
        .page(1u32)
        .send()
        .await
        .expect("failed to get rust-analyzer");
    for release in ranalyzer {
        if let Some(name) = &release.name {
            if !name.contains("nightly") {
                get_asset(release, "{asset name here}", aspath).await;
                break;
            }
        }
    }
}

async fn get_asset(release: Release, name: &str, path: &Path) {
    for asset in release.assets {
        if asset.name.contains(name) {
            let url_load: String = asset.browser_download_url.into();
            let response = reqwest::get(url_load).await.expect("");
            let mut file = File::create(path).expect("could not create file.");
            let content = response.bytes().await.expect("failed response");
            file.write_all(content.as_ref())
                .expect("could not write content.");
        }
    }
}

LollipopFt avatar Jul 28 '22 14:07 LollipopFt

is this line meant to be "download.lock" instead?

It is a spelling mistake we haven't bothered to fix :p

also, is it possible to use octocrab (or something preferably much more lightweight?) to auto download the latest version?

It would probably be easier just to make a script that updates this repo with the newest version whenever it comes out, and then Lapce users can just upgrade the plugin that way.

MinusGix avatar Jul 28 '22 17:07 MinusGix