From 2f5651bd7846ebb6abde121223233bf975ce98ee Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 3 Jun 2025 17:22:00 +0200 Subject: [PATCH 1/2] multilspy 606542ed8766bfbcc6490b3115eb0aea78c693e5 commit 22c5579059355e98c674ce4d9b1a7642479126f4 Author: SunBK201 Date: Sat Apr 12 20:16:38 2025 +0800 feat: Add support for additional platforms (Windows&macOS) for CPP LSP src/multilspy/language_servers/clangd_language_server/clangd_language_server.py src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json commit 4b57979d9f662d50a37ffe4db0a0b0669d0a06c5 Author: themichaelusa Date: Wed Mar 12 14:51:52 2025 -0700 removed which/where as its no longer necessary src/multilspy/language_servers/solargraph/solargraph.py commit ea57d1a686159c09ebc2944c2f3b32e27d84d4a2 Author: themichaelusa Date: Wed Mar 12 14:47:49 2025 -0700 fixed solargraph install bug src/multilspy/language_servers/solargraph/solargraph.py --- src/multilspy/.syncCommitId.remote | 2 +- src/multilspy/.syncCommitId.this | 1 - .../clangd_language_server.py | 15 +++++++--- .../runtime_dependencies.json | 16 ++++++++++ .../language_servers/solargraph/solargraph.py | 29 ++++++++----------- 5 files changed, 40 insertions(+), 23 deletions(-) delete mode 100644 src/multilspy/.syncCommitId.this diff --git a/src/multilspy/.syncCommitId.remote b/src/multilspy/.syncCommitId.remote index da5f157..20a711e 100644 --- a/src/multilspy/.syncCommitId.remote +++ b/src/multilspy/.syncCommitId.remote @@ -1 +1 @@ -a75ff972714bf137a9b9318bc136070696be2451 \ No newline at end of file +606542ed8766bfbcc6490b3115eb0aea78c693e5 \ No newline at end of file diff --git a/src/multilspy/.syncCommitId.this b/src/multilspy/.syncCommitId.this deleted file mode 100644 index d1c4ca3..0000000 --- a/src/multilspy/.syncCommitId.this +++ /dev/null @@ -1 +0,0 @@ -e456c3dd71fc975a9ccf1cb87ba9fa0afd02c4ce \ No newline at end of file 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 8565825..8cb4798 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 @@ class ClangdLanguageServer(LanguageServer): 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_executable_path): clangd_url = dependency["url"] @@ -72,6 +77,8 @@ class ClangdLanguageServer(LanguageServer): FileUtils.download_and_extract_archive( logger, clangd_url, clangd_ls_dir, dependency["archiveType"] ) + else: + raise RuntimeError(f"Unsupported archive type: {dependency['archiveType']}") if not os.path.exists(clangd_executable_path): raise FileNotFoundError( f"Clangd executable not found at {clangd_executable_path}.\n" 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" } ] } diff --git a/src/multilspy/language_servers/solargraph/solargraph.py b/src/multilspy/language_servers/solargraph/solargraph.py index 057c5b8..645f40a 100644 --- a/src/multilspy/language_servers/solargraph/solargraph.py +++ b/src/multilspy/language_servers/solargraph/solargraph.py @@ -51,10 +51,6 @@ class Solargraph(LanguageServer): """ Setup runtime dependencies for Solargraph. """ - platform_id = PlatformUtils.get_platform_id() - which_cmd = "which" - if platform_id in [PlatformId.WIN_x64, PlatformId.WIN_arm64, PlatformId.WIN_x86]: - which_cmd = "where" with open(os.path.join(os.path.dirname(__file__), "runtime_dependencies.json"), "r", encoding="utf-8") as f: d = json.load(f) @@ -78,23 +74,22 @@ class Solargraph(LanguageServer): if result.stdout.strip() == "false": logger.log("Installing Solargraph...", logging.INFO) subprocess.run(dependency["installCommand"].split(), check=True, capture_output=True, cwd=repository_root_path) - except subprocess.CalledProcessError as e: - raise RuntimeError(f"Failed to check or install Solargraph. {e.stderr}") - - # Get the solargraph executable path - try: - result = subprocess.run([which_cmd, "solargraph"], check=True, capture_output=True, text=True, cwd=repository_root_path) - executeable_path = result.stdout.strip() - if not os.path.exists(executeable_path): - raise RuntimeError(f"Solargraph executable not found at {executeable_path}") + # Get the gem executable path directly + result = subprocess.run(["gem", "which", "solargraph"], check=True, capture_output=True, text=True, cwd=repository_root_path) + gem_path = result.stdout.strip() + bin_dir = os.path.join(os.path.dirname(os.path.dirname(gem_path)), "bin") + executable_path = os.path.join(bin_dir, "solargraph") + + if not os.path.exists(executable_path): + raise RuntimeError(f"Solargraph executable not found at {executable_path}") # Ensure the executable has the right permissions - os.chmod(executeable_path, os.stat(executeable_path).st_mode | stat.S_IEXEC) + os.chmod(executable_path, os.stat(executable_path).st_mode | stat.S_IEXEC) - return executeable_path - except subprocess.CalledProcessError: - raise RuntimeError("Failed to locate Solargraph executable.") + return executable_path + except subprocess.CalledProcessError as e: + raise RuntimeError(f"Failed to check or install Solargraph. {e.stderr}") def _get_initialize_params(self, repository_absolute_path: str) -> InitializeParams: """ From 222f996db6742a2fd2a76deb215b08bc55aa0b29 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 3 Jun 2025 17:22:00 +0200 Subject: [PATCH 2/2] Updated multilspy sync commit identifiers (push) --- src/multilspy/.syncCommitId.this | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/multilspy/.syncCommitId.this diff --git a/src/multilspy/.syncCommitId.this b/src/multilspy/.syncCommitId.this new file mode 100644 index 0000000..8467819 --- /dev/null +++ b/src/multilspy/.syncCommitId.this @@ -0,0 +1 @@ +2f5651bd7846ebb6abde121223233bf975ce98ee \ No newline at end of file