mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 04:15:11 +00:00
LS: use home directory for language server installations
Added a migration logic that will omit unnecessary installation Used the correct LS installation path for clojure
This commit is contained in:
1 parent
2909c67d50
commit
fc71d71285
2 files changed
+17
-5
No files matched your search
@@ -95,17 +95,16 @@ class ClojureLSP(SolidLanguageServer):
|
||||
self.resolve_main_method_available = threading.Event()
|
||||
self.service_ready_event = threading.Event()
|
||||
|
||||
@staticmethod
|
||||
def _setup_runtime_dependencies(logger: LanguageServerLogger, config: LanguageServerConfig) -> str:
|
||||
@classmethod
|
||||
def _setup_runtime_dependencies(cls, logger: LanguageServerLogger, config: LanguageServerConfig) -> str:
|
||||
"""Setup runtime dependencies for clojure-lsp and return the command to start the server."""
|
||||
verify_clojure_cli()
|
||||
deps = ClojureLSP.runtime_dependencies
|
||||
dependency = deps.single_for_current_platform()
|
||||
|
||||
clojurelsp_ls_dir = os.path.join(os.path.dirname(__file__), "static", "clojure-lsp")
|
||||
clojurelsp_ls_dir = cls.ls_resources_dir()
|
||||
clojurelsp_executable_path = deps.binary_path(clojurelsp_ls_dir)
|
||||
if not os.path.exists(clojurelsp_executable_path):
|
||||
os.makedirs(clojurelsp_ls_dir, exist_ok=True)
|
||||
logger.log(
|
||||
f"Downloading and extracting clojure-lsp from {dependency.url} to {clojurelsp_ls_dir}",
|
||||
logging.INFO,
|
||||
|
||||
+14
-1
@@ -5,6 +5,7 @@ import logging
|
||||
import os
|
||||
import pathlib
|
||||
import pickle
|
||||
import shutil
|
||||
import subprocess
|
||||
import threading
|
||||
from abc import ABC, abstractmethod
|
||||
@@ -94,7 +95,19 @@ class SolidLanguageServer(ABC):
|
||||
Returns the directory where the language server resources are downloaded.
|
||||
This is used to store language server binaries, configuration files, etc.
|
||||
"""
|
||||
result = os.path.join(os.path.dirname(__file__), "language_servers", "static", cls.__name__)
|
||||
from serena.constants import SERENA_MANAGED_DIR_IN_HOME
|
||||
|
||||
result = os.path.join(SERENA_MANAGED_DIR_IN_HOME, "language_servers", "static", cls.__name__)
|
||||
|
||||
# Migration of previously downloaded LS resources that were downloaded to a subdir of solidlsp instead of to the user's home
|
||||
pre_migration_ls_resources_dir = os.path.join(os.path.dirname(__file__), "language_servers", "static", cls.__name__)
|
||||
if os.path.exists(pre_migration_ls_resources_dir):
|
||||
if os.path.exists(result):
|
||||
# if the directory already exists, we just remove the old resources
|
||||
shutil.rmtree(result, ignore_errors=True)
|
||||
else:
|
||||
# move old resources to the new location
|
||||
shutil.move(pre_migration_ls_resources_dir, result)
|
||||
if mkdir:
|
||||
os.makedirs(result, exist_ok=True)
|
||||
return result
|
||||
|
||||
Reference in new issue
Block a user