MCPcopy Index your code
hub / github.com/DevBlocky/zed-asm / language_server_binary_path

Method language_server_binary_path

src/lib.rs:11–103  ·  view source on GitHub ↗
(
        &mut self,
        language_server_id: &LanguageServerId,
        worktree: &zed::Worktree,
    )

Source from the content-addressed store, hash-verified

9
10impl Assembly {
11 fn language_server_binary_path(
12 &mut self,
13 language_server_id: &LanguageServerId,
14 worktree: &zed::Worktree,
15 ) -> zed::Result<String> {
16 if let Some(path) = worktree.which("asm-lsp") {
17 return Ok(path);
18 }
19
20 if let Some(path) = &self.cached_binary_path {
21 if fs::metadata(path).is_ok_and(|stat| stat.is_file()) {
22 return Ok(path.clone());
23 }
24 }
25
26 zed::set_language_server_installation_status(
27 language_server_id,
28 &zed::LanguageServerInstallationStatus::CheckingForUpdate,
29 );
30 let release = zed::latest_github_release(
31 "bergercookie/asm-lsp",
32 zed::GithubReleaseOptions {
33 require_assets: true,
34 pre_release: false,
35 },
36 )?;
37
38 let (platform, arch) = zed::current_platform();
39 let asset_name = format!(
40 "asm-lsp-{arch}-{os}.{ext}",
41 arch = match arch {
42 zed::Architecture::Aarch64 => "aarch64",
43 zed::Architecture::X86 => "x86",
44 zed::Architecture::X8664 => "x86_64",
45 },
46 os = match platform {
47 zed::Os::Mac => "apple-darwin",
48 zed::Os::Linux => "unknown-linux-gnu",
49 zed::Os::Windows => "pc-windows-msvc",
50 },
51 ext = match platform {
52 zed::Os::Mac | zed::Os::Linux => "tar.gz",
53 zed::Os::Windows => "zip",
54 },
55 );
56
57 let asset = release
58 .assets
59 .iter()
60 .find(|asset| asset.name == asset_name)
61 .ok_or_else(|| {
62 let mut msg = format!("no asset found matching {asset_name:?}");
63 if platform == zed::Os::Windows {
64 msg.push_str(
65 "\nprebuilt binaries are not available for Windows:\
66 \nhttps://github.com/bergercookie/asm-lsp/issues/134",
67 );
68 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected