mirror of
https://github.com/tiennm99/serena.git
synced 2026-07-18 06:17:57 +00:00
@@ -1 +1 @@
|
||||
a75ff972714bf137a9b9318bc136070696be2451
|
||||
606542ed8766bfbcc6490b3115eb0aea78c693e5
|
||||
@@ -1 +1 @@
|
||||
e456c3dd71fc975a9ccf1cb87ba9fa0afd02c4ce
|
||||
2f5651bd7846ebb6abde121223233bf975ce98ee
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user