diff --git a/CHANGELOG.md b/CHANGELOG.md index e5a26bc9..8284b3e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ Status of the `main` branch. Changes prior to the next official version change w coverage-report output, but matched by bare dirname and so also hid legitimate source directories named `coverage` (e.g. `src/routes/coverage/`) from symbol tools. Generated report dirs are already covered by gitignore. Fixes #1523. + - Fix: Restore `erlang` support (broken since v1.6.0 due to an implementation error) * Tools: - Fix: `search_for_pattern` marked one line too many as matched whenever a match ended with a line diff --git a/src/solidlsp/language_servers/erlang_language_server.py b/src/solidlsp/language_servers/erlang_language_server.py index 833e0c8d..a9c4897d 100644 --- a/src/solidlsp/language_servers/erlang_language_server.py +++ b/src/solidlsp/language_servers/erlang_language_server.py @@ -2,7 +2,6 @@ import logging import os -import pathlib import shutil import subprocess import threading @@ -76,6 +75,25 @@ class ErlangLanguageServer(SolidLanguageServer): except (subprocess.SubprocessError, FileNotFoundError): return False + def _create_base_initialize_params(self) -> dict: + """ + Returns the base initialize params for Erlang LS. + + processId, rootPath, rootUri, clientInfo and workspaceFolders are added by the builder. + """ + return { + "capabilities": { + "textDocument": { + "synchronization": {"didSave": True}, + "completion": {"dynamicRegistration": True}, + "definition": {"dynamicRegistration": True}, + "references": {"dynamicRegistration": True}, + "documentSymbol": {"dynamicRegistration": True}, + "hover": {"dynamicRegistration": True}, + } + }, + } + def _start_server(self) -> None: """Start Erlang LS server process with proper initialization waiting.""" @@ -132,25 +150,8 @@ class ErlangLanguageServer(SolidLanguageServer): log.info("Starting Erlang LS server process") self.server.start() - # Send initialize request - initialize_params = { - "processId": None, - "rootPath": self.repository_root_path, - "rootUri": pathlib.Path(self.repository_root_path).as_uri(), - "capabilities": { - "textDocument": { - "synchronization": {"didSave": True}, - "completion": {"dynamicRegistration": True}, - "definition": {"dynamicRegistration": True}, - "references": {"dynamicRegistration": True}, - "documentSymbol": {"dynamicRegistration": True}, - "hover": {"dynamicRegistration": True}, - } - }, - } - log.info("Sending initialize request to Erlang LS") - init_response = self.server.send.initialize(initialize_params) # type: ignore[arg-type] + init_response = self.server.send.initialize(self._create_initialize_params()) # Verify server capabilities if "capabilities" in init_response: