Merge pull request #150 from oraios/multilspy-update

Multilspy update
This commit is contained in:
Dominik Jain authored and GitHub committed 2025-06-05 01:24:30 +02:00
commit 11bcdb00f3
5 files changed
+41 -23

No files matched your search

+1 -1
View File
@@ -1 +1 @@
a75ff972714bf137a9b9318bc136070696be2451 606542ed8766bfbcc6490b3115eb0aea78c693e5
+1 -1
View File
@@ -1 +1 @@
e456c3dd71fc975a9ccf1cb87ba9fa0afd02c4ce 2f5651bd7846ebb6abde121223233bf975ce98ee
@@ -52,17 +52,22 @@ class ClangdLanguageServer(LanguageServer):
del d["_description"] del d["_description"]
assert platform_id.value in [ assert platform_id.value in [
"linux-x64" "linux-x64",
], "Only linux-x64 is supported for in multilspy at the moment" "win-x64",
"osx-arm64",
], "Unsupported platform: " + platform_id.value
runtime_dependencies = d["runtimeDependencies"] runtime_dependencies = d["runtimeDependencies"]
runtime_dependencies = [ runtime_dependencies = [
dependency for dependency in runtime_dependencies if dependency["platformId"] == platform_id.value dependency for dependency in runtime_dependencies if dependency["platformId"] == platform_id.value
] ]
assert len(runtime_dependencies) == 1 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"]) clangd_executable_path = os.path.join(clangd_ls_dir, "clangd_19.1.2", "bin", dependency["binaryName"])
if not os.path.exists(clangd_executable_path): if not os.path.exists(clangd_executable_path):
clangd_url = dependency["url"] clangd_url = dependency["url"]
@@ -72,6 +77,8 @@ class ClangdLanguageServer(LanguageServer):
FileUtils.download_and_extract_archive( FileUtils.download_and_extract_archive(
logger, clangd_url, clangd_ls_dir, dependency["archiveType"] 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): if not os.path.exists(clangd_executable_path):
raise FileNotFoundError( raise FileNotFoundError(
f"Clangd executable not found at {clangd_executable_path}.\n" f"Clangd executable not found at {clangd_executable_path}.\n"
@@ -8,6 +8,22 @@
"platformId": "linux-x64", "platformId": "linux-x64",
"archiveType": "zip", "archiveType": "zip",
"binaryName": "clangd" "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"
} }
] ]
} }
@@ -51,10 +51,6 @@ class Solargraph(LanguageServer):
""" """
Setup runtime dependencies for Solargraph. 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: with open(os.path.join(os.path.dirname(__file__), "runtime_dependencies.json"), "r", encoding="utf-8") as f:
d = json.load(f) d = json.load(f)
@@ -78,23 +74,22 @@ class Solargraph(LanguageServer):
if result.stdout.strip() == "false": if result.stdout.strip() == "false":
logger.log("Installing Solargraph...", logging.INFO) logger.log("Installing Solargraph...", logging.INFO)
subprocess.run(dependency["installCommand"].split(), check=True, capture_output=True, cwd=repository_root_path) 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): # Get the gem executable path directly
raise RuntimeError(f"Solargraph executable not found at {executeable_path}") 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 # 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 return executable_path
except subprocess.CalledProcessError: except subprocess.CalledProcessError as e:
raise RuntimeError("Failed to locate Solargraph executable.") raise RuntimeError(f"Failed to check or install Solargraph. {e.stderr}")
def _get_initialize_params(self, repository_absolute_path: str) -> InitializeParams: def _get_initialize_params(self, repository_absolute_path: str) -> InitializeParams:
""" """