diff --git a/src/multilspy/language_servers/clangd_language_server/clangd_language_server.py b/src/multilspy/language_servers/clangd_language_server/clangd_language_server.py index 17253c4..a5e5326 100644 --- a/src/multilspy/language_servers/clangd_language_server/clangd_language_server.py +++ b/src/multilspy/language_servers/clangd_language_server/clangd_language_server.py @@ -52,17 +52,22 @@ def setup_runtime_dependencies(self, logger: MultilspyLogger, config: MultilspyC del d["_description"] assert platform_id.value in [ - "linux-x64" - ], "Only linux-x64 is supported for in multilspy at the moment" + "linux-x64", + "win-x64", + "osx-arm64", + ], "Unsupported platform: " + platform_id.value runtime_dependencies = d["runtimeDependencies"] runtime_dependencies = [ dependency for dependency in runtime_dependencies if dependency["platformId"] == platform_id.value ] assert len(runtime_dependencies) == 1 - dependency = runtime_dependencies[0] + # Select dependency matching the current platform + dependency = next((dep for dep in runtime_dependencies if dep["platformId"] == platform_id.value), None) + if dependency is None: + raise RuntimeError(f"No runtime dependency found for platform {platform_id.value}") - clangd_ls_dir = os.path.join(os.path.dirname(__file__), "static/clangd") + clangd_ls_dir = os.path.join(os.path.dirname(__file__), "static", "clangd") clangd_executable_path = os.path.join(clangd_ls_dir, "clangd_19.1.2", "bin", dependency["binaryName"]) if not os.path.exists(clangd_ls_dir): os.makedirs(clangd_ls_dir) @@ -70,7 +75,10 @@ def setup_runtime_dependencies(self, logger: MultilspyLogger, config: MultilspyC FileUtils.download_and_extract_archive( logger, dependency["url"], clangd_ls_dir, dependency["archiveType"] ) - assert os.path.exists(clangd_executable_path) + else: + raise RuntimeError(f"Unsupported archive type: {dependency['archiveType']}") + if not os.path.exists(clangd_executable_path): + raise FileNotFoundError(f"clangd executable was not found at {clangd_executable_path} after extraction") os.chmod(clangd_executable_path, stat.S_IEXEC) return clangd_executable_path diff --git a/src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json b/src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json index ab30fff..53f5b7f 100644 --- a/src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json +++ b/src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json @@ -8,6 +8,22 @@ "platformId": "linux-x64", "archiveType": "zip", "binaryName": "clangd" + }, + { + "id": "Clangd", + "description": "Clangd for Windows (x64)", + "url": "https://github.com/clangd/clangd/releases/download/19.1.2/clangd-windows-19.1.2.zip", + "platformId": "windows-x64", + "archiveType": "zip", + "binaryName": "clangd.exe" + }, + { + "id": "Clangd", + "description": "Clangd for macOS (Arm64)", + "url": "https://github.com/clangd/clangd/releases/download/19.1.2/clangd-mac-19.1.2.zip", + "platformId": "osx-arm64", + "archiveType": "zip", + "binaryName": "clangd" } ] }