From 2c9c0b2d8f1c756faaae5ce1508d712d3811ea3d Mon Sep 17 00:00:00 2001 From: csh Date: Sun, 14 Dec 2025 13:08:50 +0800 Subject: [PATCH] :bug: fix(server): load interpreter funcext symbols - Wire `--interpreter=...` into server startup. - Auto-load `/funcext` as a system library via Symbol::LoadSystemLibrary. --- lsp-server/src/cli/launcher.cppm | 2 +- lsp-server/src/core/server.cppm | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lsp-server/src/cli/launcher.cppm b/lsp-server/src/cli/launcher.cppm index 5bc23bd..e4361ec 100644 --- a/lsp-server/src/cli/launcher.cppm +++ b/lsp-server/src/cli/launcher.cppm @@ -24,7 +24,7 @@ export int Run(int argc, char* argv[]) try { spdlog::info("TSL-LSP server starting..."); - lsp::core::LspServer server(config.thread_count); + lsp::core::LspServer server(config.thread_count, config.interpreter_path); server.Run(); } catch (const std::exception& e) diff --git a/lsp-server/src/core/server.cppm b/lsp-server/src/core/server.cppm index 6104ea0..133f5a9 100644 --- a/lsp-server/src/core/server.cppm +++ b/lsp-server/src/core/server.cppm @@ -15,6 +15,7 @@ import lsp.core.dispacther; import lsp.protocol; import lsp.codec.facade; import lsp.manager.manager_hub; +import lsp.manager.bootstrap; import lsp.scheduler.async_executor; import lsp.provider.base.interface; import lsp.provider.base.registry; @@ -37,7 +38,8 @@ export namespace lsp::core class LspServer { public: - LspServer(std::size_t concurrency = std::thread::hardware_concurrency()); + explicit LspServer(std::size_t concurrency = std::thread::hardware_concurrency(), + std::string interpreter_path = ""); ~LspServer(); void Run(); @@ -80,6 +82,7 @@ export namespace lsp::core RequestDispatcher dispatcher_; scheduler::AsyncExecutor async_executor_; manager::ManagerHub manager_hub_; + std::string interpreter_path_; std::atomic is_initialized_ = false; std::atomic is_shutting_down_ = false; @@ -89,7 +92,8 @@ export namespace lsp::core namespace lsp::core { - LspServer::LspServer(std::size_t concurrency) : async_executor_(concurrency) + LspServer::LspServer(std::size_t concurrency, std::string interpreter_path) : async_executor_(concurrency), + interpreter_path_(std::move(interpreter_path)) { spdlog::info("Initializing LSP server with {} worker threads", concurrency); @@ -378,6 +382,23 @@ namespace lsp::core void LspServer::InitializeManagerHub() { manager_hub_.Initialize(); + + if (!interpreter_path_.empty()) + { + std::filesystem::path base = interpreter_path_; + std::filesystem::path funcext_path = base / "funcext"; + if (std::filesystem::exists(funcext_path)) + { + manager::bootstrap::InitializeManagerHub( + manager_hub_, + async_executor_, + { funcext_path.string() }); + } + else + { + spdlog::warn("Interpreter funcext path does not exist: {}", funcext_path.string()); + } + } } void LspServer::RegisterProviders()