Skip to content

Commit 37f2e89

Browse files
Merge pull request #102 from SunBK201/support-cpp-mac-win
feat: Add support for additional platforms (Windows&macOS) for CPP LSP
2 parents ab58821 + 22c5579 commit 37f2e89

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/multilspy/language_servers/clangd_language_server/clangd_language_server.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,33 @@ def setup_runtime_dependencies(self, logger: MultilspyLogger, config: MultilspyC
5252
del d["_description"]
5353

5454
assert platform_id.value in [
55-
"linux-x64"
56-
], "Only linux-x64 is supported for in multilspy at the moment"
55+
"linux-x64",
56+
"win-x64",
57+
"osx-arm64",
58+
], "Unsupported platform: " + platform_id.value
5759

5860
runtime_dependencies = d["runtimeDependencies"]
5961
runtime_dependencies = [
6062
dependency for dependency in runtime_dependencies if dependency["platformId"] == platform_id.value
6163
]
6264
assert len(runtime_dependencies) == 1
63-
dependency = runtime_dependencies[0]
65+
# Select dependency matching the current platform
66+
dependency = next((dep for dep in runtime_dependencies if dep["platformId"] == platform_id.value), None)
67+
if dependency is None:
68+
raise RuntimeError(f"No runtime dependency found for platform {platform_id.value}")
6469

65-
clangd_ls_dir = os.path.join(os.path.dirname(__file__), "static/clangd")
70+
clangd_ls_dir = os.path.join(os.path.dirname(__file__), "static", "clangd")
6671
clangd_executable_path = os.path.join(clangd_ls_dir, "clangd_19.1.2", "bin", dependency["binaryName"])
6772
if not os.path.exists(clangd_ls_dir):
6873
os.makedirs(clangd_ls_dir)
6974
if dependency["archiveType"] == "zip":
7075
FileUtils.download_and_extract_archive(
7176
logger, dependency["url"], clangd_ls_dir, dependency["archiveType"]
7277
)
73-
assert os.path.exists(clangd_executable_path)
78+
else:
79+
raise RuntimeError(f"Unsupported archive type: {dependency['archiveType']}")
80+
if not os.path.exists(clangd_executable_path):
81+
raise FileNotFoundError(f"clangd executable was not found at {clangd_executable_path} after extraction")
7482
os.chmod(clangd_executable_path, stat.S_IEXEC)
7583

7684
return clangd_executable_path

src/multilspy/language_servers/clangd_language_server/runtime_dependencies.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
"platformId": "linux-x64",
99
"archiveType": "zip",
1010
"binaryName": "clangd"
11+
},
12+
{
13+
"id": "Clangd",
14+
"description": "Clangd for Windows (x64)",
15+
"url": "https://github.com/clangd/clangd/releases/download/19.1.2/clangd-windows-19.1.2.zip",
16+
"platformId": "windows-x64",
17+
"archiveType": "zip",
18+
"binaryName": "clangd.exe"
19+
},
20+
{
21+
"id": "Clangd",
22+
"description": "Clangd for macOS (Arm64)",
23+
"url": "https://github.com/clangd/clangd/releases/download/19.1.2/clangd-mac-19.1.2.zip",
24+
"platformId": "osx-arm64",
25+
"archiveType": "zip",
26+
"binaryName": "clangd"
1127
}
1228
]
1329
}

0 commit comments

Comments
 (0)