diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index b2c74b3c..2de9cd20 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -84,6 +84,8 @@ class SolidLanguageServer(ABC): It is used to communicate with Language Servers of different programming languages. """ + CACHE_FOLDER_NAME = "cache" + # To be overridden and extended by subclasses def is_ignored_dirname(self, dirname: str) -> bool: """ @@ -1640,7 +1642,13 @@ class SolidLanguageServer(ABC): """ The path to the cache file for the document symbols. """ - return Path(self.repository_root_path) / ".serena" / "cache" / self.language_id / "document_symbols_cache_v23-06-25.pkl" + return ( + Path(self.repository_root_path) + / self._solidlsp_settings.project_data_relative_path + / self.CACHE_FOLDER_NAME + / self.language_id + / "document_symbols_cache_v23-06-25.pkl" + ) def save_cache(self): with self._cache_lock: diff --git a/src/solidlsp/settings.py b/src/solidlsp/settings.py index 0b956bff..73acd2d6 100644 --- a/src/solidlsp/settings.py +++ b/src/solidlsp/settings.py @@ -10,6 +10,15 @@ from dataclasses import dataclass @dataclass class SolidLSPSettings: solidlsp_dir: str = str(pathlib.Path.home() / ".solidlsp") + """ + Path to the directory in which to store global Solid-LSP data (which is not project-specific) + """ + project_data_relative_path: str = ".solidlsp" + """ + Relative path within each project directory where Solid-LSP can store project-specific data, e.g. cache files. + For instance, if this is ".solidlsp" and the project is located at "/home/user/myproject", + then Solid-LSP will store project-specific data in "/home/user/myproject/.solidlsp". + """ def __post_init__(self): os.makedirs(str(self.solidlsp_dir), exist_ok=True) diff --git a/test/conftest.py b/test/conftest.py index 849af543..1ef2501c 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -4,7 +4,7 @@ from pathlib import Path import pytest from sensai.util.logging import configure -from serena.constants import SERENA_MANAGED_DIR_IN_HOME +from serena.constants import SERENA_MANAGED_DIR_IN_HOME, SERENA_MANAGED_DIR_NAME from serena.project import Project from serena.util.file_system import GitignoreParser from solidlsp.ls import SolidLanguageServer @@ -46,7 +46,10 @@ def create_ls( config = LanguageServerConfig(code_language=language, ignored_paths=ignored_paths, trace_lsp_communication=trace_lsp_communication) logger = LanguageServerLogger(log_level=log_level) return SolidLanguageServer.create( - config, logger, repo_path, solidlsp_settings=SolidLSPSettings(solidlsp_dir=SERENA_MANAGED_DIR_IN_HOME) + config, + logger, + repo_path, + solidlsp_settings=SolidLSPSettings(solidlsp_dir=SERENA_MANAGED_DIR_IN_HOME, project_data_relative_path=SERENA_MANAGED_DIR_NAME), )